Forum Replies Created

Check out all your contributions and responses across the community.

Viewing 15 posts - 1 through 15 (of 93 total)
  • Author
    Posts
  • Yes, you can create a Supertrend indicator in Pine Script very easily using the built-in ta.supertrend() function.

    The code below creates a Supertrend with an ATR Multiplier of 3 and an ATR Length of 10. It returns two values:

    supertrend – The Supertrend line.
    direction – The current trend direction.

    The plot() functions then display the Supertrend on the chart. When the trend is bullish, the line is plotted in green, and when the trend is bearish, it is plotted in red.

    The script also includes a custom function named pine_supertrend(). This function manually calculates the Supertrend using ATR, upper band, lower band, and trend direction. It produces the same result as the built-in ta.supertrend() function and is useful if you want to understand or customize the Supertrend calculation.

    You can simply copy the code below into the Pine Script Editor and click Add to Chart to see the Supertrend indicator in action.

    //@version=6
    indicator("My super trend", overlay = true)
    
    [supertrend, direction] = ta.supertrend(3, 10)
    plot(direction < 0 ? supertrend : na, "Up direction", color = color.green, style = plot.style_linebr)
    plot(direction > 0 ? supertrend : na, "Down direction", color = color.red, style = plot.style_linebr)
    
    // The same on Pine Script®
    pine_supertrend(factor, atrPeriod) =>
        src = hl2
        atr = ta.atr(atrPeriod)
        upperBand = src + factor * atr
        lowerBand = src - factor * atr
        prevLowerBand = nz(lowerBand[1])
        prevUpperBand = nz(upperBand[1])
    
        lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ? lowerBand : prevLowerBand
        upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ? upperBand : prevUpperBand
    
        int _direction = na
        float superTrend = na
        prevSuperTrend = superTrend[1]
    
        if na(atr[1])
            _direction := 1
        else if prevSuperTrend == prevUpperBand
            _direction := close > upperBand ? -1 : 1
        else
            _direction := close < lowerBand ? 1 : -1
    
        superTrend := _direction == -1 ? lowerBand : upperBand
        [superTrend, _direction]
    
    [Pine_Supertrend, pineDirection] = pine_supertrend(3, 10)
    
    plot(pineDirection < 0 ? Pine_Supertrend : na, "Up direction", color = color.green, style = plot.style_linebr)
    plot(pineDirection > 0 ? Pine_Supertrend : na, "Down direction", color = color.red, style = plot.style_linebr)

    Also, if you want the code of tradingview provided for the supertrend then just visit the refrance manual and search for the supertrend in that example you will find the code of the supertrend.

    I hope this helps! If you have any questions about the code or want to customize the Supertrend settings, feel free to ask in the comments.

    Yes, this is completely possible in Pine Script.

    Normally, when you create an indicator with:

    indicator("My Indicator", overlay = false)

    the entire indicator is displayed in a separate pane below the price chart.

    However, Pine Script allows individual plots and drawings to be forced onto the main chart by using the force_overlay parameter.

    For example:

    indicator("My Indicator", overlay = false)
    plot(close, force_overlay = true)

    In this example, the indicator itself still lives in the separate pane because overlay = false, but the plot() is forced to appear on the main price chart using force_overlay = true.

    The same concept can be used with other drawing functions that support the force_overlay parameter, allowing you to keep your calculations in a separate pane while displaying important signals or visual elements directly on the chart.

    This approach is useful when you want the best of both worlds:

    Keep oscillators like RSI, MACD, or custom calculations in a separate pane.
    Display buy/sell signals, labels, or important plots on the main price chart.

    This keeps your indicator organized while still making the important trading signals easy to see.

    Below is an example showing how this works in practice.

    In the ATM Based selection type, you don’t manually select an option contract or a premium. Instead, you choose how far away from the current ATM (At-The-Money) strike you want the platform to select the option.

    This is done using the ATM Gap value.

    For example:

    -ATM Gap = 0 → Current ATM Strike

    -ATM Gap = +1 → One strike OTM

    -ATM Gap = +2 → Two strikes OTM

    -ATM Gap = -1 → One strike ITM

    -ATM Gap = -2 → Two strikes ITM

    Suppose NIFTY is trading around 22,500, making 22,500 the ATM strike.

    If the Script Type is CE, then:

    -ATM Gap = 0 → 22500 CE

    -ATM Gap = +1 → 22550 CE

    -ATM Gap = +2 → 22600 CE

    -ATM Gap = -1 → 22450 CE

    -ATM Gap = -2 → 22400 CE

    This selection type is useful when you always want to trade a strike relative to the current ATM level, regardless of market movement.

    (Refer to the image below for the ATM Based configuration.)

    In the Premium Based selection type, you do not manually choose an option contract. Instead, you enter your desired premium, and the platform automatically searches the option chain for the contract whose premium is closest to that value.

    You will also see a setting called Max Variation. This defines how far above or below your target premium the platform is allowed to search while looking for the closest matching option.

    For example, suppose you enter:

    -Target Premium = ₹100

    -Max Variation = ₹20

    Assume the option chain is:

    -22400 CE → ₹135

    -22450 CE → ₹112

    -22500 CE → ₹98

    -22550 CE → ₹75

    Since ₹98 is the closest premium to ₹100, the platform will automatically select 22500 CE, and that contract will be used in the generated JSON.

    This selection type is useful when your strategy is based on the option premium rather than a fixed strike price.

    (Refer to the image below for the Premium Based configuration.)

    In the Symbol Based selection type, you manually choose the exact option contract that you want to trade. The platform does not search for another contract or make any automatic selection.

    For example, suppose the available option contracts are:

    -NIFTY21JUL2622500CE

    -NIFTY21JUL2622550CE

    -NIFTY21JUL2622600CE

    If you select NIFTY21JUL2622550CE, then the generated JSON will always contain that exact option contract.

    Even if the premium changes from ₹120 to ₹180 or drops to ₹90, the platform will still use NIFTY21JUL2622550CE because you selected the symbol manually.

    In simple words, Symbol Based is useful when you already know exactly which option contract you want to trade.

    (Refer to the image below for the Symbol Based configuration.)

    Yes sir, you can definitely do that.

    The JSON Bridge is designed exactly for this type of integration.

    You simply need to generate your JSON syntax from the JSON Bridge and send the appropriate JSON payload to the JSON Bridge webhook whenever your strategy conditions are satisfied.

    For example, suppose you have generated the following syntaxes.

    Buy Signal Syntax:

    {
        "type": "strategy_order",
        "exit_on_opposite": true,
        "is_tgt": false,
        "is_sl": false,
        "is_trail_set": false,
        "position_size": "{{strategy.position_size}}",
        "transaction_type": "BUY",
        "script_type": "CE",
        "is_rollover": false,
        "option_selection": "ATM_BASED",
        "script": "NIFTY-N",
        "atm_gap": 0,
        "expiry_gap": 0,
        "expiry_type": "weekly",
        "product": "CARRYFORWARD",
        "quantity": 1
    }

    Sell Signal Syntax:

    {
        "type": "strategy_order",
        "exit_on_opposite": true,
        "is_tgt": false,
        "is_sl": false,
        "is_trail_set": false,
        "position_size": "{{strategy.position_size}}",
        "transaction_type": "BUY",
        "script_type": "PE",
        "is_rollover": false,
        "option_selection": "ATM_BASED",
        "script": "NIFTY-N",
        "atm_gap": 0,
        "expiry_gap": 0,
        "expiry_type": "weekly",
        "product": "CARRYFORWARD",
        "quantity": 1
    }

    Then you can integrate it with Python like below: 

    import requests
    WEBHOOK_URL = "https://apiv4.algodelta.com/api/v4/users/jsonbridge/webhook/212602030/0b73f099933"
    
    BUY_JSON = {
        "type": "strategy_order",
        "exit_on_opposite": True,
        "is_tgt": False,
        "is_sl": False,
        "is_trail_set": False,
        "position_size": "{{strategy.position_size}}",
        "transaction_type": "BUY",
        "script_type": "CE",
        "is_rollover": False,
        "option_selection": "ATM_BASED",
        "script": "NIFTY-N",
        "atm_gap": 0,
        "expiry_gap": 0,
        "expiry_type": "weekly",
        "product": "CARRYFORWARD",
        "quantity": 1
    }
    
    SELL_JSON = {
        "type": "strategy_order",
        "exit_on_opposite": True,
        "is_tgt": False,
        "is_sl": False,
        "is_trail_set": False,
        "position_size": "{{strategy.position_size}}",
        "transaction_type": "BUY",
        "script_type": "PE",
        "is_rollover": False,
        "option_selection": "ATM_BASED",
        "script": "NIFTY-N",
        "atm_gap": 0,
        "expiry_gap": 0,
        "expiry_type": "weekly",
        "product": "CARRYFORWARD",
        "quantity": 1
    }
    
    
    def send_signal(payload):
        response = requests.post(
            WEBHOOK_URL,
            json=payload
        )
    
        print(response.status_code)
        print(response.text)
    
    
    if buy_signal:
        send_signal(BUY_JSON)
    
    elif sell_signal:
        send_signal(SELL_JSON)
    

    That’s it.

    Now whenever your Python strategy generates a Buy signal, the Call Option syntax will be executed automatically.

    Similarly, whenever a Sell signal is generated, the Put Option syntax will be sent to AlgoDelta and executed.

    This is one of the easiest ways to integrate your Python strategies directly with AlgoDelta’s JSON Bridge.

    Yes sir, you can definitely do that.

    The Custom Bridge is designed exactly for these kinds of integrations.

    You simply need to send a webhook request from your Python code whenever your trading conditions are satisfied.

    The important part is:

    -UP → Executes the configured Upside Execution

    -DOWN → Executes the configured Downside Execution

    -EXIT → Squares off the existing position

    Below is a simple Python example:

    import requests
    
    WEBHOOK_URL = "https://apiv4.algodelta.com/api/v4/users/bridge/webhook/151841/Test123"
    
    def send_signal(signal):
        response = requests.post(
            WEBHOOK_URL,
            data=signal,
            headers={
                "Content-Type": "text/plain"
            }
        )
        print(response.status_code)
        print(response.text)
    
    # Buy Signal
    send_signal("UP")
    
    # Sell Signal
    send_signal("DOWN")
    
    # Exit Existing Position
    send_signal("EXIT")

    Now you just have to call the function wherever your strategy conditions are met. 

    Example:

    if buy_signal:
        send_signal("UP")
    
    elif sell_signal:
        send_signal("DOWN")
    
    elif exit_signal:
        send_signal("EXIT")

    That’s it.

    Whenever your Python strategy sends:

    -UP → AlgoDelta executes the Upside configuration

    -DOWN → AlgoDelta executes the Downside configuration

    -EXIT → AlgoDelta exits the active position

    This is one of the easiest ways to integrate Python strategies with AlgoDelta’s Custom Bridge.

    Yes sir, you are absolutely right.

    When using an indicator in TradingView, you generally need to create two separate alerts because indicators do not provide the {{strategy.position_size}} variable like strategies do.

    Step 1:

    Create and configure a Custom Bridge in AlgoDelta if you don’t already have one.

    Configure both the Up Side and Down Side executions as per your requirements.

    Step 2:

    Copy the webhook URL from the Custom Bridge using the yellow copy icon.

    Step 3:

    Open TradingView and apply your indicator on the chart. Let’s say we apply the “UT Bot Alerts” Indicator.

    Step 4:

    Create the first alert for the Upside execution.

    Configure it as follows:

    -Condition:
    Select your indicator

    -Crossing:
    Crossing Up

    -Value:
    Select the value or plot generated by your indicator

    -Trigger:
    Once Per Bar Close

    -Expiration:
    Keep it as per your requirement

    -Message Section:

    -Alert Name:
    UP Alert (You can put the other name also)

    -Message:
    UP (Always in capital letters)

    Click on “Apply”.

    Step 5:

    Go to the Notification section.

    -Enable Webhook URL

    -Paste the webhook URL copied from the Custom Bridge

    Click on “Apply”.

    Then click on “Create”.

    Step 6:

    Create another alert for the Down Side execution.

    Keep all the settings the same except:

    -Crossing:
    Crossing Down

    -Alert Name:
    DOWN Alert

    -Message:
    DOWN

    Then click on “Create”.

    That’s it.

    Now whenever the indicator generates an Up signal, TradingView will send the message UP and the Upside execution configured in the Custom Bridge will be executed.

    Similarly, whenever the indicator generates a Down signal, TradingView will send the message DOWN and the Downside execution configured in the Custom Bridge will be executed.

    This is the standard and recommended approach for connecting TradingView indicators with AlgoDelta’s Custom Bridge.

    Yes sir, it’s very easy and can be configured in just a few steps.

    Step 1:

    Create and configure a Custom Bridge in AlgoDelta if you don’t already have one.

    Configure both the Up Side and Down Side executions as per your requirements.

    Step 2:

    Copy the webhook URL from the Custom Bridge using the yellow copy icon.

    Step 3:

    Open TradingView and apply your strategy on the chart.

    Step 4:

    Create an alert and configure it as follows:

    -Condition:
    Select your strategy.
    For example: Supertrend Strategy

    -Interval:
    Same as Chart
    (You can choose a different interval if required.)

    -Expiration:
    Keep it as per your requirement.

    -Message Section:

    -Alert Name:
    Custom Alert
    (You can give any name you prefer.)

    -Message:
    {{strategy.position_size}}

    Click on “Apply”.

    Step 5:

    Go to the Notification section.

    -Enable Webhook URL

    -Paste the webhook URL copied from the Custom Bridge.

    You can also configure the other notification settings according to your preference.

    Click on “Apply”.

    Step 6:

    Click on “Create”.

    That’s it.

    Your alert is now configured successfully.

    From now on, whenever the strategy generates a signal:

    -If the strategy position size becomes positive, the Upside execution configured in the Custom Bridge will be triggered.

    -If the strategy position size becomes negative, the Downside execution configured in the Custom Bridge will be triggered.

    This is the recommended and most commonly used way to connect a TradingView strategy with AlgoDelta’s Custom Bridge.

    Yes sir, this is definitely possible using AlgoDelta’s Custom Bridge.

    If you don’t have a strategy or indicator and want to trade based on manually drawn lines, you can simply create TradingView alerts on those lines and connect them with a Custom Bridge.

    Follow the steps below:

    Step 1:
    Create and configure a Custom Bridge in AlgoDelta if you haven’t already done so.

    Configure the Up Side and Down Side executions according to your requirements.

    Step 2:
    Copy the webhook URL from the yellow copy icon available on the Custom Bridge page.

    Step 3:
    Open your TradingView chart and draw the line you want to use as an entry level.

    Step 4:
    Select the line and click on the Alert icon.

    Step 5:
    Configure the alert as follows:

    -Condition:
    Price

    -Crossing:
    Crossing Up (for Buy)

    -Object:
    Your selected Trendline

    -Trigger:
    Once Per Bar Close

    -Expiration:
    Keep default or configure as needed

    -> In Message : 

    -Alert Name:
    Custom Alert

    -Message:
    UP

    Note: In message text box – always write things “UP” and “DOWN” means in capital while using the custom bridge.

    Step 6:
    Go to the Notifications section.

    Enable:
    -WebHook URL

    Paste the webhook copied from the Custom Bridge.

    You may also enable optional notifications like:
    -Notify in App
    -Show Toast Notification
    -Send Email
    -Play Sound

    Step 7:
    Click Create.

    That’s it.

    Now whenever the price crosses above your line, TradingView will send the message “UP” to AlgoDelta and the configured Upside execution will be triggered.

    Similarly, for sell-side execution:

    -Select Crossing Down instead of Crossing Up
    -Set the message as DOWN
    -Use the same webhook URL

    Now whenever price crosses below the line, AlgoDelta will trigger the Downside execution automatically.

    This is a simple way to automate trades from manually drawn levels without writing any Pine Script strategy or indicator.

    Yes sir, you can definitely do paper trading in TradingView. It is a great way to learn without risking real capital.

    -Step 1:

    Open TradingView and open any chart on which you want to practice trading.

    -Step 2:

    Click on the “Trade” button available at the top right corner.

    -Step 3:

    You will see a list of brokers and available connections.

    Select “Paper Trading by TradingView”, which is usually the first option in the list.

    -Step 4:

    Click on “Connect”.

    Once connected, the Paper Trading panel will automatically appear below the chart.

    -Step 5:

    Open any Forex chart that you want to trade.

    Then click on the “Trade” button at the top right corner, click on “Order” and choose the order type you want to place.

    You can place:

    -Market Orders
    -Limit Orders
    -Stop Orders

    TradingView provides a virtual balance of $100,000 by default, so you can practice trading in real market conditions without using actual money.

    After placing trades, you will also be able to monitor:

    -Open Positions
    -Pending Orders
    -Order History
    -Account Balance
    -Trading Performance
    -Trading Journal

    You can even reset the account balance or create additional paper trading accounts whenever needed.

    So in simple terms, Paper Trading in TradingView gives you a complete trading experience without risking real funds, making it ideal for learning and testing strategies.

    Yes sir, your understanding is absolutely correct.

    The JSON Bridge supports multiple order types apart from Strategy Orders, such as:

    -Limit Order

    -SL Order

    -Square Off Position

    -Modify Order

    -Cancel Order

    These order types can also be used with TradingView, MT5, or any platform capable of sending JSON data to AlgoDelta.

    If you are already using a Strategy Order, you may have noticed that options like Target, Stop Loss, Trailing Stop Loss, and Exit on Opposite are already available within the Strategy Order syntax itself.

    However, if you want to place a Limit Order or an SL Order separately, you can generate their dedicated JSON syntax from the Syntax Generator and use it exactly the same way you use a Strategy Order syntax.

    So in simple terms:

    -Strategy Order → Used for direct strategy-based execution with built-in target, SL, and trailing options.

    -Limit Order → Used when you want execution only at a specific price.

    -SL Order → Used for stop entry or stop-loss based execution.

    -Square Off Position → Used to close existing positions through JSON commands.

    If you have any doubts regarding which order type is best suited for your use case, you can also reach out to the support team for further guidance.

    Yes sir, this is a valid question and can be a little confusing.

    Changing the Bridge Key does not affect positions that are already open. Those orders have already been executed and will continue to remain active as usual.

    However, changing the Bridge Key also changes the webhook URL associated with that Custom Bridge.

    So, if your TradingView alerts are still using the old webhook URL, then any new signals generated after changing the Bridge Key will not reach AlgoDelta, and therefore no new orders will be placed.

    In simple terms:

    -Existing open positions will remain unaffected.

    -Pending or future signals sent to the old webhook will fail.

    -You will need to update the new webhook URL wherever the old webhook is being used, such as TradingView, MT5, AmiBroker, or any other external platform.

    For a smooth experience, it is generally recommended to change the Bridge Key only when the bridge is not actively being used for live signal execution.

    Yes sir, one common thing that is often missed is the Trading Flag on the Demat Connection itself.

    Even if the Trading Flag is enabled inside the Group for both the Master and Child accounts, orders may still not be placed if the Trading Flag is disabled on the connected demat account.

    Please verify the following:

    -Trading Flag is enabled in the Group.

    -Trading Flag is enabled for all Child accounts.

    -Trading Flag is enabled on the connected Demat Account from the Demat Connect page.

    -The broker account is connected properly and is active.

    In many cases, enabling the Trading Flag from the Demat Connect section resolves the issue immediately.

    If everything is enabled and the issue still persists, you can contact the support team for further assistance.

    Yes sir, the Trailing feature in AlgoDelta works very similar to a normal trailing stop loss, but it gives you more control through three parameters:

    -Trail Trigger

    -Trail Point

    -Trail Gap

    Let’s understand it with an example.

    Suppose you enter a trade at a price of 100 and configure the trailing settings as follows:

    -Trail Trigger = 10

    -Trail Point = 5

    -Trail Gap = 3

    Initially, the trailing stop loss remains inactive.

    Once the price moves 10 points in your favour and reaches 110, the trailing gets activated.

    At this point, the stop loss becomes: 110 – 3 = 107

    So, your stop loss is now moved to 107.

    The Trail Point determines when the stop loss should move again.

    Since the Trail Point is set to 5, the stop loss will only adjust after the price moves another 5 points.

    For example:

    -Price reaches 115

    -New Stop Loss = 115 – 3 = 112

    If price reaches 120:

    -New Stop Loss = 120 – 3 = 117

    And this process continues as long as the trade keeps moving in your favour.

    So, in simple terms:

    -Trail Trigger → The profit required before trailing starts.

    -Trail Point → The number of points the price must move before the stop loss is adjusted again.

    -Trail Gap → The distance maintained between the current price and the trailing stop loss.

    This is how Trailing works inside AlgoDelta’s Order Manager.

Viewing 15 posts - 1 through 15 (of 93 total)
×

Start a Discussion

Get help from the AlgoDelta community.

×

Welcome Back!

Enter your email to sign in or create an account. No passwords needed.

Pending Approval

⚠️

Delete This?

Are you sure you want to delete this? This action is permanent and cannot be undone.

Scroll to Top