Zeal Terminal Open Zeal Terminal

Pine Script v4 · Strategy

supertrend advance

A Pine Script v4 strategy built on SMA (tr, 10) and ATR (10). It has 8 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 46 settings; defaults include Broker Fyers, CALL & PUT BUY and CALL Symbol BANKNIFTY21MAY.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does supertrend advance repaint?
No
No repainting patterns were found in the source.
Can supertrend advance be converted to Pine Script v5?
Not tested
The steps are shown below, but the original does not run in Zeal Terminal's engine, so they could not be checked.
Does supertrend advance use a stop loss?
Yes
strategy.exit sets a stop on line 211, 212.
Does supertrend advance run in Zeal Terminal?
No
Not yet: Pine Script v4 Error at @L59:C24: 'str.format' is not available in Pine Script v4. It was added in a later version.
Does not run in Zeal Terminal yetPine Script v4 Error at @L59:C24: 'str.format' is not available in Pine Script v4. It was added in a later version. The settings, logic and review below are read from the source, which does not need a run.

Review

What a careful reader of this script would point out, found by checking the source.

  • Check

    1 setting does nothing

    “OutPut_Syntax” is declared but never read.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

  • Note

    Uses an argument v6 removed

    when = on line 183, 185, 186, 187, 209, 210. The upgraded version below moves each call inside an if block.

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

  • Upgrading to v5 renames tostring → str.tostring, sma → ta.sma, atr → ta.atr, max → math.max, min → math.min, security → request.security, heikinashi → ticker.heikinashi, tickerid → ticker.new, change → ta.change, round → math.round, abs → math.abs.
  • 6 strategy calls use the when = argument (line 183, 185, 186, 187, 209, 210). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Not verified

The v4 script does not run in Zeal Terminal's engine (Pine Script v4 Error at @L59:C24: 'str.format' is not available in Pine Script v4. It was added in a later version.), so this step could not be checked.

  • Line 3: //@version=4 → //@version=5
  • Line 20: input(type = input.string) → input.string()
  • Line 21: input(type = input.string) → input.string()
  • Line 22: input(type = input.string) → input.string()
  • Line 23: input(type = input.string) → input.string()
  • Line 24: input(type = input.string) → input.string()
60 more edits
  • Line 28: tostring → str.tostring
  • Line 29: tostring → str.tostring
  • Line 29: tostring → str.tostring
  • Line 30: tostring → str.tostring
  • Line 30: tostring → str.tostring
  • Line 33: tostring → str.tostring
  • Line 33: tostring → str.tostring
  • Line 34: tostring → str.tostring
  • Line 34: tostring → str.tostring
  • Line 38: tostring → str.tostring
  • Line 38: tostring → str.tostring
  • Line 39: tostring → str.tostring
  • Line 39: tostring → str.tostring
  • Line 42: tostring → str.tostring
  • Line 42: tostring → str.tostring
  • Line 43: tostring → str.tostring
  • Line 43: tostring → str.tostring
  • Line 59: tostring → str.tostring
  • Line 60: tostring → str.tostring
  • Line 61: tostring → str.tostring
  • Line 62: tostring → str.tostring
  • Line 76: input(type = input.integer) → input.int()
  • Line 78: input(type = input.float) → input.float()
  • Line 79: input(type = input.bool) → input.bool()
  • Line 80: input(type = input.bool) → input.bool()
  • Line 81: input(type = input.bool) → input.bool()
  • Line 84: sma → ta.sma
  • Line 84: tr → ta.tr
  • Line 85: atr → ta.atr
  • Line 88: max → math.max
  • Line 91: min → math.min
  • Line 98: security → request.security
  • Line 98: heikinashi → ticker.heikinashi
  • Line 98: tickerid → ticker.new
  • Line 99: security → request.security
  • Line 116: input(type = input.bool) → input.bool()
  • Line 117: input(type = input.integer) → input.int()
  • Line 118: input(type = input.integer) → input.int()
  • Line 119: input(type = input.bool) → input.bool()
  • Line 122: input(type = input.integer) → input.int()
  • Line 123: input(type = input.integer) → input.int()
  • Line 124: input(type = input.bool) → input.bool()
  • Line 155: change → ta.change
  • Line 157: change → ta.change
  • Line 161: change → ta.change
  • Line 190: input(type = input.float) → input.float()
  • Line 191: input(type = input.float) → input.float()
  • Line 192: input(type = input.bool) → input.bool()
  • Line 193: input(type = input.float) → input.float()
  • Line 195: round → math.round
  • Line 195: abs → math.abs
  • Line 198: round → math.round
  • Line 199: round → math.round
  • Line 201: min → math.min
  • Line 202: round → math.round
  • Line 203: round → math.round
  • Line 207: input(type = input.bool) → input.bool()
  • Line 208: input(type = input.bool) → input.bool()
  • Line 209: strategy.entry(…, true) → strategy.entry(…, strategy.long)
  • Line 210: strategy.entry(…, false) → strategy.entry(…, strategy.short)
⋯// AAKASHPARIKH787-//@version=4+//@version=5////////⋯tt = input("BUY", "CALL & PUT", options=["BUY", "SELL"], group=group_algo_syntax)-ts = input("BANKNIFTY21MAY", "CALL Symbol", input.string, group=group_algo_syntax)+ts = input.string("BANKNIFTY21MAY", "CALL Symbol", group=group_algo_syntax)-ts_1 = input("BANKNIFTY21MAY", "PUT Symbol", input.string, group=group_algo_syntax)+ts_1 = input.string("BANKNIFTY21MAY", "PUT Symbol", group=group_algo_syntax)-nearby = input("100", "Both side Nearby", input.string, group=group_algo_syntax)+nearby = input.string("100", "Both side Nearby", group=group_algo_syntax)-cal = input("+0", "CALL Side Calculation", input.string, group=group_algo_syntax)+cal = input.string("+0", "CALL Side Calculation", group=group_algo_syntax)-cal_1 = input("+0", "PUT Side Calculation", input.string, group=group_algo_syntax)+cal_1 = input.string("+0", "PUT Side Calculation", group=group_algo_syntax)product = input("INTRADAY", "Product", options=["INTRADAY","NRML"], group=group_algo_syntax)⋯functions_algo_syntax(qty_ALGOX, result)=>-    qty = tostring(qty_ALGOX)+    qty = str.tostring(qty_ALGOX)-    Buy_Call_f = '[{"AS":"' + ts + '","P":"' + product           +'","AT":"FYERSV2"},{"TT":"'      + "BUY"            + '","TS":"' + ts   +'{' +tostring(close) +'}CE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal   +'","AT":"FYERSV2"' + ',"DL":"'+ tostring(DL_Time) +'"}]'+    Buy_Call_f = '[{"AS":"' + ts + '","P":"' + product           +'","AT":"FYERSV2"},{"TT":"'      + "BUY"            + '","TS":"' + ts   +'{' +str.tostring(close) +'}CE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal   +'","AT":"FYERSV2"' + ',"DL":"'+ str.tostring(DL_Time) +'"}]'-    Buy_Call_z = '[{"AS":"' + ts + '","P":"' + product +'","E":"NFO","AT":"ZERODHA"},' + '{"TT":"' + "BUY"  + '","E":"NFO","TS":"' + ts   +'{' +tostring(close) +'}CE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal   +'","AT":"ZERODHA"' + ',"DL":"'+ tostring(DL_Time) +'"}]'+    Buy_Call_z = '[{"AS":"' + ts + '","P":"' + product +'","E":"NFO","AT":"ZERODHA"},' + '{"TT":"' + "BUY"  + '","E":"NFO","TS":"' + ts   +'{' +str.tostring(close) +'}CE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal   +'","AT":"ZERODHA"' + ',"DL":"'+ str.tostring(DL_Time) +'"}]'    Buy_Call = syntax_broker== "Fyers" ? Buy_Call_f   : Buy_Call_z    -    Buy_Put_f = '[{"AS":"' + ts_1+'","P":"' + product           +'","AT":"FYERSV2"},{"TT":"'      + "BUY"            + '","TS":"' + ts_1 +'{' +tostring(close) +'}PE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal_1 +'","AT":"FYERSV2"'  + ',"DL":"'+ tostring(DL_Time) +'"}]'+    Buy_Put_f = '[{"AS":"' + ts_1+'","P":"' + product           +'","AT":"FYERSV2"},{"TT":"'      + "BUY"            + '","TS":"' + ts_1 +'{' +str.tostring(close) +'}PE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal_1 +'","AT":"FYERSV2"'  + ',"DL":"'+ str.tostring(DL_Time) +'"}]'-    Buy_Put_z = '[{"AS":"' + ts_1+'","P":"' + product +'","E":"NFO","AT":"ZERODHA"},' + '{"TT":"' + "BUY"  + '","E":"NFO","TS":"' + ts_1 +'{' +tostring(close) +'}PE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal_1 +'","AT":"ZERODHA"'  + ',"DL":"'+ tostring(DL_Time) +'"}]'+    Buy_Put_z = '[{"AS":"' + ts_1+'","P":"' + product +'","E":"NFO","AT":"ZERODHA"},' + '{"TT":"' + "BUY"  + '","E":"NFO","TS":"' + ts_1 +'{' +str.tostring(close) +'}PE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal_1 +'","AT":"ZERODHA"'  + ',"DL":"'+ str.tostring(DL_Time) +'"}]'    Buy_Put = syntax_broker== "Fyers" ? Buy_Put_f   : Buy_Put_z⋯    -    Sell_Call_f = '[{"AS":"' + ts + '","P":"' + product                +'","AT":"FYERSV2"},{"TT":"' + "SELL" +           '","TS":"' + ts   +'{' +tostring(close) +'}PE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal   +'","AT":"FYERSV2"' + ',"DL":"'+ tostring(DL_Time) +'"}]'+    Sell_Call_f = '[{"AS":"' + ts + '","P":"' + product                +'","AT":"FYERSV2"},{"TT":"' + "SELL" +           '","TS":"' + ts   +'{' +str.tostring(close) +'}PE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal   +'","AT":"FYERSV2"' + ',"DL":"'+ str.tostring(DL_Time) +'"}]'-    Sell_Call_z = '[{"AS":"' + ts + '","P":"' + product +'","E":"NFO","AT":"ZERODHA"},' + '{"TT":"' + "SELL" + '","E":"NFO","TS":"' + ts   +'{' +tostring(close) +'}PE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal   +'","AT":"ZERODHA"' + ',"DL":"'+ tostring(DL_Time) +'"}]'+    Sell_Call_z = '[{"AS":"' + ts + '","P":"' + product +'","E":"NFO","AT":"ZERODHA"},' + '{"TT":"' + "SELL" + '","E":"NFO","TS":"' + ts   +'{' +str.tostring(close) +'}PE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal   +'","AT":"ZERODHA"' + ',"DL":"'+ str.tostring(DL_Time) +'"}]'    Sell_Call = syntax_broker== "Fyers" ? Sell_Call_f   : Sell_Call_z    -    Sell_Put_f = '[{"AS":"' + ts_1+'","P":"' + product +'","E":"NFO","AT":"ZERODHA"},' + '{"TT":"' + "SELL" + '","E":"NFO","TS":"' + ts_1 +'{' +tostring(close) +'}CE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal_1 +'","AT":"ZERODHA"'  + ',"DL":"'+ tostring(DL_Time) +'"}]'+    Sell_Put_f = '[{"AS":"' + ts_1+'","P":"' + product +'","E":"NFO","AT":"ZERODHA"},' + '{"TT":"' + "SELL" + '","E":"NFO","TS":"' + ts_1 +'{' +str.tostring(close) +'}CE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal_1 +'","AT":"ZERODHA"'  + ',"DL":"'+ str.tostring(DL_Time) +'"}]'-    Sell_Put_z = '[{"AS":"' + ts_1+'","P":"' + product +'","E":"NFO","AT":"ZERODHA"},' + '{"TT":"' + "SELL" + '","E":"NFO","TS":"' + ts_1 +'{' +tostring(close) +'}CE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal_1 +'","AT":"ZERODHA"' + ',"DL":"'+ tostring(DL_Time) +'"}]'+    Sell_Put_z = '[{"AS":"' + ts_1+'","P":"' + product +'","E":"NFO","AT":"ZERODHA"},' + '{"TT":"' + "SELL" + '","E":"NFO","TS":"' + ts_1 +'{' +str.tostring(close) +'}CE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal_1 +'","AT":"ZERODHA"' + ',"DL":"'+ str.tostring(DL_Time) +'"}]'    Sell_Put = syntax_broker== "Fyers" ? Sell_Put_f   : Sell_Put_z⋯    -    buy_s_entry_msg_i = str.format(ZX_buy_s_entry_msg_i  ,  qty, tostring(close)  )+    buy_s_entry_msg_i = str.format(ZX_buy_s_entry_msg_i  ,  qty, str.tostring(close)  )-    sell_s_entry_msg_i = str.format(ZX_sell_s_entry_msg_i ,  qty, tostring(close)  )+    sell_s_entry_msg_i = str.format(ZX_sell_s_entry_msg_i ,  qty, str.tostring(close)  )-    buy_s_exit_msg = str.format(ZX_buy_s_exit_msg     ,  qty, tostring(close)  )+    buy_s_exit_msg = str.format(ZX_buy_s_exit_msg     ,  qty, str.tostring(close)  )-    sell_s_exit_msg = str.format(ZX_sell_s_exit_msg    ,  qty, tostring(close)  )+    sell_s_exit_msg = str.format(ZX_sell_s_exit_msg    ,  qty, str.tostring(close)  )    Buy_Entry_msg      := Want_PaperTrading   ? buy_s_entry_msg_i   : Buy_Entry_msg    ⋯group_indicator_1 = "🟥 🟥 🟥 🟥 Indicator Settings 🟥 🟥 🟥 🟥 "-Periods_spt = input(title="ATR Period",     type=input.integer,               defval=10,     group=group_indicator_1)+Periods_spt = input.int(title="ATR Period",               defval=10,     group=group_indicator_1)src_spt = input(title="Source",                                           defval=hl2,    group=group_indicator_1)-Multiplier_spt = input(title="ATR Multiplier", type=input.float, step=0.1,       defval=3.0,    group=group_indicator_1)+Multiplier_spt = input.float(title="ATR Multiplier", step=0.1,       defval=3.0,    group=group_indicator_1)-changeATR_spt = input(title="Change ATR Calculation Method ?", type=input.bool, defval=true,   group=group_indicator_1)+changeATR_spt = input.bool(title="Change ATR Calculation Method ?", defval=true,   group=group_indicator_1)-showsignals_spt = input(title="Show Buy/Sell Signals ?",         type=input.bool, defval=true,   group=group_indicator_1)+showsignals_spt = input.bool(title="Show Buy/Sell Signals ?", defval=true,   group=group_indicator_1)-highlighting_spt = input(title="Highlighter On/Off ?",            type=input.bool, defval=true,   group=group_indicator_1)+highlighting_spt = input.bool(title="Highlighter On/Off ?", defval=true,   group=group_indicator_1)candle_type_ssl = input(defval="HeikenAshi", title="Candle_Type_Filter", options = ["HeikenAshi", "CandleStick", "Same as Chart"],    group=group_indicator_1)f_spt()=>    -    atr2_spt = sma(tr, Periods_spt)+    atr2_spt = ta.sma(ta.tr, Periods_spt)-    atr_spt = changeATR_spt ? atr(Periods_spt) : atr2_spt+    atr_spt = changeATR_spt ? ta.atr(Periods_spt) : atr2_spt    up_spt =    src_spt  -  (Multiplier_spt*atr_spt)    up1_spt =    nz(up_spt[1],up_spt)-    up_spt     :=   close[1] > up1_spt ? max(up_spt,up1_spt) : up_spt+    up_spt     :=   close[1] > up1_spt ? math.max(up_spt,up1_spt) : up_spt    dn_spt =    src_spt+(Multiplier_spt*atr_spt)    dn1_spt =    nz(dn_spt[1], dn_spt)-    dn_spt     :=   close[1] < dn1_spt ? min(dn_spt, dn1_spt) : dn_spt+    dn_spt     :=   close[1] < dn1_spt ? math.min(dn_spt, dn1_spt) : dn_spt    trend_spt =    1⋯[trend_spt_1, up_spt_1, dn_spt_1] = f_spt()-[trend_spt_2, up_spt_2, dn_spt_2] = security(heikinashi(tickerid(syminfo.prefix,syminfo.ticker)), timeframe.period, f_spt())    +[trend_spt_2, up_spt_2, dn_spt_2] = request.security(ticker.heikinashi(ticker.new(syminfo.prefix,syminfo.ticker)), timeframe.period, f_spt())    -[trend_spt_3, up_spt_3, dn_spt_3] = security(syminfo.tickerid, timeframe.period, f_spt())    +[trend_spt_3, up_spt_3, dn_spt_3] = request.security(syminfo.tickerid, timeframe.period, f_spt())    trend_spt =  candle_type_ssl=="HeikenAshi" ?  trend_spt_2    : candle_type_ssl=="CandleStick" ? trend_spt_2   : trend_spt_1  ⋯fill(mPlot_spt, dnPlot_spt, title="DownTrend Highligter", color=shortFillColor_spt)-want_intraday = input(defval=false, type=input.bool,    title="Want_Intraday",                                      group=" ════╣ Entry Time ↓╠════")+want_intraday = input.bool(defval=false,    title="Want_Intraday",                                      group=" ════╣ Entry Time ↓╠════")-start_hours = input(defval=9 ,    type=input.integer, title="Hours",   minval=0, maxval=23, inline="Entry_Time",  group=" ════╣ Entry Time ↓╠════")+start_hours = input.int(defval=9 , title="Hours",   minval=0, maxval=23, inline="Entry_Time",  group=" ════╣ Entry Time ↓╠════")-start_minutes = input(defval=0 ,    type=input.integer, title="Minutes", minval=0, maxval=59, inline="Entry_Time",  group=" ════╣ Entry Time ↓╠════")+start_minutes = input.int(defval=0 , title="Minutes", minval=0, maxval=59, inline="Entry_Time",  group=" ════╣ Entry Time ↓╠════")-draw_entry_area = input(defval=false, type=input.bool,    title="Highlight",                    inline="Entry_Time",  group=" ════╣ Entry Time ↓╠════")+draw_entry_area = input.bool(defval=false,    title="Highlight",                    inline="Entry_Time",  group=" ════╣ Entry Time ↓╠════")time_entry()   =>  want_intraday ? ((hour > start_hours   ) ? true   :  (hour < start_hours   ) ? false   :  (hour == start_hours   )  ?  minute >= start_minutes   : false) : truebgcolor(time_entry()   and draw_entry_area                               ? color.red  : na, title="Entry_Time Area")-end_hours = input(defval=14,    type=input.integer, title="Hours",   minval=0, maxval=23, inline="Exit_Time",  group=" ════╣ Exit Time ↓╠════")+end_hours = input.int(defval=14, title="Hours",   minval=0, maxval=23, inline="Exit_Time",  group=" ════╣ Exit Time ↓╠════")-end_minutes = input(defval=55,    type=input.integer, title="Minutes", minval=0, maxval=59, inline="Exit_Time",  group=" ════╣ Exit Time ↓╠════")+end_minutes = input.int(defval=55, title="Minutes", minval=0, maxval=59, inline="Exit_Time",  group=" ════╣ Exit Time ↓╠════")-draw_exit_area = input(defval=false, type=input.bool,    title="Highlight",                    inline="Exit_Time",  group=" ════╣ Exit Time ↓╠════")+draw_exit_area = input.bool(defval=false,    title="Highlight",                    inline="Exit_Time",  group=" ════╣ Exit Time ↓╠════")time_exit()  =>  want_intraday ? ((hour > end_hours   ) ? true   :  (hour < end_hours   ) ? false   :  (hour == end_hours   )  ?  minute >= end_minutes   : false) : false⋯        -    if change(strategy.losstrades) and (strategy.losstrades+strategy.wintrades)>1+    if ta.change(strategy.losstrades) and (strategy.losstrades+strategy.wintrades)>1        loss_trade    := true-    if change(strategy.wintrades)  and (strategy.losstrades+strategy.wintrades)>1+    if ta.change(strategy.wintrades)  and (strategy.losstrades+strategy.wintrades)>1        loss_trade    := false⋯    -    if  loss_trade  and change(strategy.losstrades) and  qty_1_x_max > qty_1+    if  loss_trade  and ta.change(strategy.losstrades) and  qty_1_x_max > qty_1        qty_1         := qty_1 * 2⋯tp_sl_type = input(defval="Percent",title="TP-SL Type",             options=["Points","Percent"],  group=group_strategy_tp_sl_1)-target_points_1_00 = input(defval=20,       title="Target     ",            type=input.float, minval=0 ,   group=group_strategy_tp_sl_1)+target_points_1_00 = input.float(defval=20,       title="Target     ", minval=0 ,   group=group_strategy_tp_sl_1)-sl_points_1_00 = input(defval=30,       title="Stop-Loss ",             type=input.float, minval=0 ,   group=group_strategy_tp_sl_1 )+sl_points_1_00 = input.float(defval=30,       title="Stop-Loss ", minval=0 ,   group=group_strategy_tp_sl_1 )-want_spt_tp = input(defval=true,     title="Want Supertrend TP ",    type=input.bool,   inline="aabjbdkjbsk",  group=group_strategy_tp_sl_1 )+want_spt_tp = input.bool(defval=true,     title="Want Supertrend TP ",   inline="aabjbdkjbsk",  group=group_strategy_tp_sl_1 )-spt_tp_factor = input(defval=1,        title="X-times ",               type=input.float,  inline="aabjbdkjbsk",  group=group_strategy_tp_sl_1 )+spt_tp_factor = input.float(defval=1,        title="X-times ",  inline="aabjbdkjbsk",  group=group_strategy_tp_sl_1 )SPT_value = buySignal_spt  ? up_spt : sellSignal_spt ? dn_spt : na-spt_sl_x = round(   (  abs(close -  SPT_value) *spt_tp_factor ) /syminfo.mintick  )+spt_sl_x = math.round(   (  math.abs(close -  SPT_value) *spt_tp_factor ) /syminfo.mintick  )spt_sl = 0spt_sl              := buy_time or sell_time ? spt_sl_x :    spt_sl[1]-target_points_1_01 = round(  ( close* (target_points_1_00*0.01) )/syminfo.mintick)+target_points_1_01 = math.round(  ( close* (target_points_1_00*0.01) )/syminfo.mintick)-target_points_1_02 = round(target_points_1_00/syminfo.mintick)+target_points_1_02 = math.round(target_points_1_00/syminfo.mintick)target_points_1 = tp_sl_type=="Points" ? target_points_1_02 : target_points_1_01-target_points_1     := want_spt_tp  ? min(target_points_1, spt_sl ) : target_points_1+target_points_1     := want_spt_tp  ? math.min(target_points_1, spt_sl ) : target_points_1-sl_points_1_01 = round(  ( close* (sl_points_1_00*0.01) )/syminfo.mintick)+sl_points_1_01 = math.round(  ( close* (sl_points_1_00*0.01) )/syminfo.mintick)-sl_points_1_02 = round(sl_points_1_00/syminfo.mintick)+sl_points_1_02 = math.round(sl_points_1_00/syminfo.mintick)sl_points_1 = tp_sl_type=="Points" ? sl_points_1_02 : sl_points_1_01⋯group_strategy_2 = "🟧 🟧 🟧  SL-Trailing- Settings 🟧 🟧 🟧 "-want_buy = input(title="Want_Buy_Side",     defval=true,     type=input.bool, group=group_strategy_1)+want_buy = input.bool(title="Want_Buy_Side",     defval=true, group=group_strategy_1)-want_sell = input(title="Want_Sell_Side",    defval=true,     type=input.bool, group=group_strategy_1)+want_sell = input.bool(title="Want_Sell_Side",    defval=true, group=group_strategy_1)-strategy.entry("Buy",  true,  when= buy_time    and  want_buy ,     qty = f_martangle_qty_1() , alert_message=functions_algo_syntax(f_martangle_qty_1(), 1 ))+strategy.entry("Buy",  strategy.long,  when= buy_time    and  want_buy ,     qty = f_martangle_qty_1() , alert_message=functions_algo_syntax(f_martangle_qty_1(), 1 ))-strategy.entry("Sell", false, when= sell_time   and  want_sell,     qty = f_martangle_qty_1() , alert_message=functions_algo_syntax(f_martangle_qty_1(), 2 ))+strategy.entry("Sell", strategy.short, when= sell_time   and  want_sell,     qty = f_martangle_qty_1() , alert_message=functions_algo_syntax(f_martangle_qty_1(), 2 ))strategy.exit('Buy_Exit' ,  'Buy',   loss=sl_points_1,  profit=target_points_1 , alert_message=functions_algo_syntax(f_martangle_qty_1(), 3 ) )⋯

Clean v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 9: input() → input.string()
  • Line 10: input() → input.string()
  • Line 13: input() → input.bool()
  • Line 14: input() → input.string()
  • Line 15: input() → input.string()
  • Line 16: input() → input.string()
23 more edits
  • Line 17: input() → input.string()
  • Line 19: input() → input.string()
  • Line 25: input() → input.string()
  • Line 26: input() → input.int()
  • Line 77: input() → input.source()
  • Line 82: input() → input.string()
  • Line 128: input() → input.int()
  • Line 129: input() → input.int()
  • Line 130: input() → input.int()
  • Line 132: input() → input.int()
  • Line 133: input() → input.int()
  • Line 134: input() → input.int()
  • Line 140: input() → input.bool()
  • Line 141: input() → input.bool()
  • Line 142: input() → input.float()
  • Line 143: input() → input.float()
  • Line 183: when = time_exit() and want_intraday → if block
  • Line 185: when = time_exit() and want_intraday → if block
  • Line 186: when = sell_time → if block
  • Line 187: when = buy_time → if block
  • Line 189: input() → input.string()
  • Line 209: when = buy_time and want_buy → if block
  • Line 210: when = sell_time and want_sell → if block
⋯ -SYNTAX_Output = input("{{strategy.order.alert_message}}",   title= "OutPut_Syntax")+SYNTAX_Output = input.string("{{strategy.order.alert_message}}",   title= "OutPut_Syntax")-syntax_broker = input("Fyers", title=   "Broker", options=["Fyers", "Zerodha"])+syntax_broker = input.string("Fyers", title=   "Broker", options=["Fyers", "Zerodha"])tooltip_1_algo = "In Algo Syntax Type  '{0}'  in place of Quantity\n&& remove '{' & '}' the Bracket from the Syntax"group_buy_syntax_2= "🟩🟩🟩🟩 Algo-Syntax-2 🟩🟩🟩🟩"-Want_PaperTrading = input(true,    title=   "Want Custom Syntax",         group=group_buy_syntax_2, tooltip=tooltip_1_algo       )+Want_PaperTrading = input.bool(true,    title=   "Want Custom Syntax",         group=group_buy_syntax_2, tooltip=tooltip_1_algo       )-ZX_buy_s_entry_msg_i = input("",    title=   "Buy Entry Syntax",  group=group_buy_syntax_2, tooltip=tooltip_1_algo)+ZX_buy_s_entry_msg_i = input.string("",    title=   "Buy Entry Syntax",  group=group_buy_syntax_2, tooltip=tooltip_1_algo)-ZX_sell_s_entry_msg_i = input("",    title=   "Sell Entry Syntax", group=group_buy_syntax_2, tooltip=tooltip_1_algo)+ZX_sell_s_entry_msg_i = input.string("",    title=   "Sell Entry Syntax", group=group_buy_syntax_2, tooltip=tooltip_1_algo)-ZX_buy_s_exit_msg = input("",    title=   "Buy Exit Syntax",   group=group_buy_syntax_2, tooltip=tooltip_1_algo)+ZX_buy_s_exit_msg = input.string("",    title=   "Buy Exit Syntax",   group=group_buy_syntax_2, tooltip=tooltip_1_algo)-ZX_sell_s_exit_msg = input("",    title=   "Sell Exit Syntax",  group=group_buy_syntax_2, tooltip=tooltip_1_algo)+ZX_sell_s_exit_msg = input.string("",    title=   "Sell Exit Syntax",  group=group_buy_syntax_2, tooltip=tooltip_1_algo)group_algo_syntax = "🟥 🟥 🟥Options Algo-Syntax 🟥 🟥 🟥"-tt = input("BUY", "CALL & PUT", options=["BUY", "SELL"], group=group_algo_syntax)+tt = input.string("BUY", "CALL & PUT", options=["BUY", "SELL"], group=group_algo_syntax)ts = input.string("BANKNIFTY21MAY", "CALL Symbol", group=group_algo_syntax)⋯cal_1 = input.string("+0", "PUT Side Calculation", group=group_algo_syntax)-product = input("INTRADAY", "Product", options=["INTRADAY","NRML"], group=group_algo_syntax)+product = input.string("INTRADAY", "Product", options=["INTRADAY","NRML"], group=group_algo_syntax)-DL_Time = input(3000, "Delay Time", group=group_algo_syntax)+DL_Time = input.int(3000, "Delay Time", group=group_algo_syntax)functions_algo_syntax(qty_ALGOX, result)=>⋯Periods_spt = input.int(title="ATR Period",               defval=10,     group=group_indicator_1)-src_spt = input(title="Source",                                           defval=hl2,    group=group_indicator_1)+src_spt = input.source(title="Source",                                           defval=hl2,    group=group_indicator_1)Multiplier_spt = input.float(title="ATR Multiplier", step=0.1,       defval=3.0,    group=group_indicator_1)⋯highlighting_spt = input.bool(title="Highlighter On/Off ?", defval=true,   group=group_indicator_1)-candle_type_ssl = input(defval="HeikenAshi", title="Candle_Type_Filter", options = ["HeikenAshi", "CandleStick", "Same as Chart"],    group=group_indicator_1)+candle_type_ssl = input.string(defval="HeikenAshi", title="Candle_Type_Filter", options = ["HeikenAshi", "CandleStick", "Same as Chart"],    group=group_indicator_1)f_spt()=>    ⋯group_date = "🟥 🟥 🟥 🟥 Date- Filter 🟥 🟥 🟥 🟥 "-fromDay = input(defval = 1,    inline="xx_x", title = "From Day",     minval = 1, maxval = 31, group=group_date)+fromDay = input.int(defval = 1,    inline="xx_x", title = "From Day",     minval = 1, maxval = 31, group=group_date)-fromMonth = input(defval = 1,    inline="xx_x", title = "     Month",   minval = 1, maxval = 12, group=group_date)+fromMonth = input.int(defval = 1,    inline="xx_x", title = "     Month",   minval = 1, maxval = 12, group=group_date)-fromYear = input(defval = 2015, inline="xx_x", title = "     Year",    minval = 1970,           group=group_date)+fromYear = input.int(defval = 2015, inline="xx_x", title = "     Year",    minval = 1970,           group=group_date) -toDay = input(defval = 1,     inline="xx_y", title = "To Day",   minval = 1, maxval = 31, group=group_date)+toDay = input.int(defval = 1,     inline="xx_y", title = "To Day",   minval = 1, maxval = 31, group=group_date)-toMonth = input(defval = 1,     inline="xx_y", title = "   Month", minval = 1, maxval = 12, group=group_date)+toMonth = input.int(defval = 1,     inline="xx_y", title = "   Month", minval = 1, maxval = 12, group=group_date)-toYear = input(defval = 2023,  inline="xx_y", title = "   Year",  minval = 1970          , group=group_date)+toYear = input.int(defval = 2023,  inline="xx_y", title = "   Year",  minval = 1970          , group=group_date) ⋯group_strategy_qty_1 = "======== Quantity-Settings ↓========"-want_qty_feature = input(defval=true,   title="Want_Quantity Feature",      group=group_strategy_qty_1)+want_qty_feature = input.bool(defval=true,   title="Want_Quantity Feature",      group=group_strategy_qty_1)-want_qty_feature_refresh = input(defval=true,   title="Want_Quantity Feature Refresh Daily",      group=group_strategy_qty_1)+want_qty_feature_refresh = input.bool(defval=true,   title="Want_Quantity Feature Refresh Daily",      group=group_strategy_qty_1)-qty_1_x_max = input(defval=100.0,  title="Max_Qty",                    group=group_strategy_qty_1)+qty_1_x_max = input.float(defval=100.0,  title="Max_Qty",                    group=group_strategy_qty_1)-qty_1_x = input(defval=25.0,   title="Entry Quanity",              group=group_strategy_qty_1)+qty_1_x = input.float(defval=25.0,   title="Entry Quanity",              group=group_strategy_qty_1)f_martangle_qty_1()=>⋯if strategy.position_size > 0 -    strategy.close( 'Buy',  when=time_exit() and want_intraday, alert_message=exit_alert_msg_1,    comment="EoD_Exit")+    if time_exit() and want_intraday+        strategy.close( 'Buy', alert_message=exit_alert_msg_1,    comment="EoD_Exit")if strategy.position_size < 0 -    strategy.close( 'Sell', when=time_exit() and want_intraday, alert_message=exit_alert_msg_2,    comment="EoD_Exit")+    if time_exit() and want_intraday+        strategy.close( 'Sell', alert_message=exit_alert_msg_2,    comment="EoD_Exit")-strategy.close("Buy",  when= sell_time,    comment="Buy_Exit",  alert_message=functions_algo_syntax(f_martangle_qty_1(), 3 ))+if sell_time+    strategy.close("Buy",    comment="Buy_Exit",  alert_message=functions_algo_syntax(f_martangle_qty_1(), 3 ))-strategy.close("Sell", when= buy_time,     comment="Sell_Exit", alert_message=functions_algo_syntax(f_martangle_qty_1(), 4 ))+if buy_time+    strategy.close("Sell",     comment="Sell_Exit", alert_message=functions_algo_syntax(f_martangle_qty_1(), 4 ))group_strategy_tp_sl_1 = "======== TP-SL-Main & Reverse ↓========"-tp_sl_type = input(defval="Percent",title="TP-SL Type",             options=["Points","Percent"],  group=group_strategy_tp_sl_1)+tp_sl_type = input.string(defval="Percent",title="TP-SL Type",             options=["Points","Percent"],  group=group_strategy_tp_sl_1)target_points_1_00 = input.float(defval=20,       title="Target     ", minval=0 ,   group=group_strategy_tp_sl_1)⋯want_sell = input.bool(title="Want_Sell_Side",    defval=true, group=group_strategy_1)-strategy.entry("Buy",  strategy.long,  when= buy_time    and  want_buy ,     qty = f_martangle_qty_1() , alert_message=functions_algo_syntax(f_martangle_qty_1(), 1 ))+if buy_time    and  want_buy+    strategy.entry("Buy",  strategy.long ,     qty = f_martangle_qty_1() , alert_message=functions_algo_syntax(f_martangle_qty_1(), 1 ))-strategy.entry("Sell", strategy.short, when= sell_time   and  want_sell,     qty = f_martangle_qty_1() , alert_message=functions_algo_syntax(f_martangle_qty_1(), 2 ))+if sell_time   and  want_sell+    strategy.entry("Sell", strategy.short,     qty = f_martangle_qty_1() , alert_message=functions_algo_syntax(f_martangle_qty_1(), 2 ))strategy.exit('Buy_Exit' ,  'Buy',   loss=sl_points_1,  profit=target_points_1 , alert_message=functions_algo_syntax(f_martangle_qty_1(), 3 ) )⋯

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L111:C60: 'linewidth' must be at least 1 in Pine Script v6. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// AAKASHPARIKH787-//@version=5+//@version=6////////⋯

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
OutPut_Syntax{{strategy.order.alert_message}}stringunused
BrokerFyersstring · options ["Fyers", "Zerodha"]Buy_Call Buy_Put Sell_Call Sell_Put Exit_Call Exit_Put
🟩🟩🟩🟩 Algo-Syntax-2 🟩🟩🟩🟩
Want Custom SyntaxIn Algo Syntax Type '{0}' in place of Quantity\n&& remove '{' & '}' the Bracket from the SyntaxtrueboolExit_Call Exit_Put Buy_Entry_msg Sell_Entry_msg
Buy Entry SyntaxIn Algo Syntax Type '{0}' in place of Quantity\n&& remove '{' & '}' the Bracket from the Syntaxstringbuy_s_entry_msg_i
Sell Entry SyntaxIn Algo Syntax Type '{0}' in place of Quantity\n&& remove '{' & '}' the Bracket from the Syntaxstringsell_s_entry_msg_i
Buy Exit SyntaxIn Algo Syntax Type '{0}' in place of Quantity\n&& remove '{' & '}' the Bracket from the Syntaxstringbuy_s_exit_msg
Sell Exit SyntaxIn Algo Syntax Type '{0}' in place of Quantity\n&& remove '{' & '}' the Bracket from the Syntaxstringsell_s_exit_msg
🟥 🟥 🟥Options Algo-Syntax 🟥 🟥 🟥
CALL & PUTBUYstring · options ["BUY", "SELL"]Buy_Entry_msg Sell_Entry_msg
CALL SymbolBANKNIFTY21MAYstringBuy_Call_f Buy_Call_z Sell_Call_f Sell_Call_z Exit_Call_f Exit_Call_z
PUT SymbolBANKNIFTY21MAYstringBuy_Put_f Buy_Put_z Sell_Put_f Sell_Put_z Exit_Put_f Exit_Put_z
Both side Nearby100stringBuy_Call_f Buy_Call_z Buy_Put_f Buy_Put_z Sell_Call_f Sell_Call_z Sell_Put_f Sell_Put_z
CALL Side Calculation+0stringBuy_Call_f Buy_Call_z Sell_Call_f Sell_Call_z
PUT Side Calculation+0stringBuy_Put_f Buy_Put_z Sell_Put_f Sell_Put_z
ProductINTRADAYstring · options ["INTRADAY","NRML"]Buy_Call_f Buy_Call_z Buy_Put_f Buy_Put_z Sell_Call_f Sell_Call_z Sell_Put_f Sell_Put_z Exit_Call_f Exit_Call_z Exit_Put_f Exit_Put_z
Delay Time3000intBuy_Call_f Buy_Call_z Buy_Put_f Buy_Put_z Sell_Call_f Sell_Call_z Sell_Put_f Sell_Put_z
🟥 🟥 🟥 🟥 Indicator Settings 🟥 🟥 🟥 🟥
ATR Period10int (written input.integer)atr2_spt atr_spt
Sourcehl2sourceup_spt dn_spt
ATR Multiplier3.0float · step 0.1up_spt dn_spt
Change ATR Calculation Method ?trueboolatr_spt
Show Buy/Sell Signals ?trueboolBuy Sell
Highlighter On/Off ?trueboollongFillColor_spt shortFillColor_spt
Candle_Type_FilterHeikenAshistring · options ["HeikenAshi", "CandleStick", "Same as Chart"]up_spt dn_spt trend_spt
╣ Entry Time ↓╠
Want_Intradayfalseboolline 120 line 125 close Buy close Sell
Hours9int (written input.integer) · min 0 · max 23line 120
Minutes0int (written input.integer) · min 0 · max 59line 120
HighlightfalseboolEntry_Time Area
╣ Exit Time ↓╠
Hours14int (written input.integer) · min 0 · max 23line 125
Minutes55int (written input.integer) · min 0 · max 59line 125
HighlightfalseboolExit_Time Area
🟥 🟥 🟥 🟥 Date- Filter 🟥 🟥 🟥 🟥
From Day1int · min 1 · max 31startDate
Month1int · min 1 · max 12startDate
Year2015int · min 1970startDate
To Day1int · min 1 · max 31finishDate
Month1int · min 1 · max 12finishDate
Year2023int · min 1970finishDate
Quantity-Settings ↓
Want_Quantity Featuretrueboolline 171
Want_Quantity Feature Refresh Dailytrueboolline 148
Max_Qty100.0floatline 161
Entry Quanity25.0floatqty_1
TP-SL-Main & Reverse ↓
TP-SL TypePercentstring · options ["Points","Percent"]target_points_1 sl_points_1
Target 20float · min 0target_points_1_01 target_points_1_02
Stop-Loss 30float · min 0sl_points_1_01 sl_points_1_02
Want Supertrend TP truebooltarget_points_1
X-times 1floatspt_sl_x
🟧 🟧 🟧 Strategy - Settings 🟧 🟧 🟧
Want_Buy_Sidetrueboolentry Buy
Want_Sell_Sidetrueboolentry Sell

What it calculates

  • SMA (sma, ta.sma in v5)tr, ATR Period (10)atr2_spt · line 84
  • ATR (atr, ta.atr in v5)ATR Period (10)atr_spt · line 85

Signal flow

How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

The script has 73 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Close Buytime_exit() and want_intradayOn183
Close Selltime_exit() and want_intradayOn185
Close Buysell_timesellSignal_spt and strategy.position_size>=0 and time_cond() and time_entry() and time_exit()==falseOn186
Close Sellbuy_timebuySignal_spt and strategy.position_size<=0 and time_cond() and time_entry() and time_exit()==falseOn187
Open Buy longbuy_time and want_buyOn209
Open Sell shortsell_time and want_sellOn210
Exit Buy_Exit stop and limitevery barOn211
Exit Sell_Exit stop and limitevery barOn212

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

No

No repainting patterns in the source.

The live replay needs a run, and this script does not run in Zeal Terminal yet; the answer comes from the checks on the source alone.

  • ClearHigher-timeframe data2 security call(s), none with lookahead on.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Similar scripts

Indicators and strategies built from the same calculations.

ScriptSharesTypeNetTradesMax drawdown
I11L - Better Buy Low Volatility or High Volatility- by I11Latr smav5 strategy+19.2%8337.4%
Vortex Cross w-MA Confirmation by DraftVentureatr smav5 strategy+2.4%524.7%
Configurable Multi MA Crossover Voting System by levieuxsma atrv5 strategy+28.5%539.4%
Swing Trend Strategy by Inkedlausma atrv5 strategy+11.2%516.2%
SSL Backtester With ATR SL TP and Money Management by JBTrippinsma atrv4 strategy+8.5%553.9%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2No Pine Script v4 Error at @L59:C24: 'str.format' is not available in Pine Script v4. It was added in a later version.Not measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as true, false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 209, 210) so the engine trades the way the script says.

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report. PineTS runs Pine Script v5 and v6 only.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// AAKASHPARIKH787//@version=4////////strategy("supertrend advance", "supertrend Advance", overlay=true, max_labels_count=51, max_lines_count=50)   SYNTAX_Output = input("{{strategy.order.alert_message}}",   title= "OutPut_Syntax")syntax_broker = input("Fyers", title=   "Broker", options=["Fyers", "Zerodha"])tooltip_1_algo = "In Algo Syntax Type  '{0}'  in place of Quantity\n&& remove '{' & '}' the Bracket from the Syntax"group_buy_syntax_2= "🟩🟩🟩🟩 Algo-Syntax-2 🟩🟩🟩🟩"Want_PaperTrading = input(true,    title=   "Want Custom Syntax",         group=group_buy_syntax_2, tooltip=tooltip_1_algo       )ZX_buy_s_entry_msg_i = input("",    title=   "Buy Entry Syntax",  group=group_buy_syntax_2, tooltip=tooltip_1_algo)ZX_sell_s_entry_msg_i = input("",    title=   "Sell Entry Syntax", group=group_buy_syntax_2, tooltip=tooltip_1_algo)ZX_buy_s_exit_msg = input("",    title=   "Buy Exit Syntax",   group=group_buy_syntax_2, tooltip=tooltip_1_algo)ZX_sell_s_exit_msg = input("",    title=   "Sell Exit Syntax",  group=group_buy_syntax_2, tooltip=tooltip_1_algo)group_algo_syntax = "🟥 🟥 🟥Options Algo-Syntax 🟥 🟥 🟥"tt = input("BUY", "CALL & PUT", options=["BUY", "SELL"], group=group_algo_syntax)ts = input("BANKNIFTY21MAY", "CALL Symbol", input.string, group=group_algo_syntax)ts_1 = input("BANKNIFTY21MAY", "PUT Symbol", input.string, group=group_algo_syntax)nearby = input("100", "Both side Nearby", input.string, group=group_algo_syntax)cal = input("+0", "CALL Side Calculation", input.string, group=group_algo_syntax)cal_1 = input("+0", "PUT Side Calculation", input.string, group=group_algo_syntax)product = input("INTRADAY", "Product", options=["INTRADAY","NRML"], group=group_algo_syntax)DL_Time = input(3000, "Delay Time", group=group_algo_syntax)functions_algo_syntax(qty_ALGOX, result)=>    qty = tostring(qty_ALGOX)    Buy_Call_f = '[{"AS":"' + ts + '","P":"' + product           +'","AT":"FYERSV2"},{"TT":"'      + "BUY"            + '","TS":"' + ts   +'{' +tostring(close) +'}CE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal   +'","AT":"FYERSV2"' + ',"DL":"'+ tostring(DL_Time) +'"}]'    Buy_Call_z = '[{"AS":"' + ts + '","P":"' + product +'","E":"NFO","AT":"ZERODHA"},' + '{"TT":"' + "BUY"  + '","E":"NFO","TS":"' + ts   +'{' +tostring(close) +'}CE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal   +'","AT":"ZERODHA"' + ',"DL":"'+ tostring(DL_Time) +'"}]'    Buy_Call = syntax_broker== "Fyers" ? Buy_Call_f   : Buy_Call_z        Buy_Put_f = '[{"AS":"' + ts_1+'","P":"' + product           +'","AT":"FYERSV2"},{"TT":"'      + "BUY"            + '","TS":"' + ts_1 +'{' +tostring(close) +'}PE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal_1 +'","AT":"FYERSV2"'  + ',"DL":"'+ tostring(DL_Time) +'"}]'    Buy_Put_z = '[{"AS":"' + ts_1+'","P":"' + product +'","E":"NFO","AT":"ZERODHA"},' + '{"TT":"' + "BUY"  + '","E":"NFO","TS":"' + ts_1 +'{' +tostring(close) +'}PE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal_1 +'","AT":"ZERODHA"'  + ',"DL":"'+ tostring(DL_Time) +'"}]'    Buy_Put = syntax_broker== "Fyers" ? Buy_Put_f   : Buy_Put_z            Sell_Call_f = '[{"AS":"' + ts + '","P":"' + product                +'","AT":"FYERSV2"},{"TT":"' + "SELL" +           '","TS":"' + ts   +'{' +tostring(close) +'}PE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal   +'","AT":"FYERSV2"' + ',"DL":"'+ tostring(DL_Time) +'"}]'    Sell_Call_z = '[{"AS":"' + ts + '","P":"' + product +'","E":"NFO","AT":"ZERODHA"},' + '{"TT":"' + "SELL" + '","E":"NFO","TS":"' + ts   +'{' +tostring(close) +'}PE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal   +'","AT":"ZERODHA"' + ',"DL":"'+ tostring(DL_Time) +'"}]'    Sell_Call = syntax_broker== "Fyers" ? Sell_Call_f   : Sell_Call_z        Sell_Put_f = '[{"AS":"' + ts_1+'","P":"' + product +'","E":"NFO","AT":"ZERODHA"},' + '{"TT":"' + "SELL" + '","E":"NFO","TS":"' + ts_1 +'{' +tostring(close) +'}CE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal_1 +'","AT":"ZERODHA"'  + ',"DL":"'+ tostring(DL_Time) +'"}]'    Sell_Put_z = '[{"AS":"' + ts_1+'","P":"' + product +'","E":"NFO","AT":"ZERODHA"},' + '{"TT":"' + "SELL" + '","E":"NFO","TS":"' + ts_1 +'{' +tostring(close) +'}CE","Q":"'+ qty +'","OT":"MARKET","P":"'+ product +'","VL":"DAY","NEAR":"'+ nearby +'","CAL":"'+ cal_1 +'","AT":"ZERODHA"' + ',"DL":"'+ tostring(DL_Time) +'"}]'    Sell_Put = syntax_broker== "Fyers" ? Sell_Put_f   : Sell_Put_z            Exit_Call_f = '[{"AS":"' + ts  +'","P":"' + product +          '","AT":"FYERSV2"}]'    Exit_Call_z = '[{"AS":"' + ts + '","P":"' + product +'","E":"NFO","AT":"ZERODHA"}]'    Exit_Call = syntax_broker== "Fyers" ? Exit_Call_f   : Exit_Call_z        Exit_Put_f = '[{"AS":"' + ts_1+'","P":"' + product +          '","AT":"FYERSV2"}]'    Exit_Put_z = '[{"AS":"' + ts_1+'","P":"' + product +'","E":"NFO","AT":"ZERODHA"}]'    Exit_Put = syntax_broker== "Fyers" ? Exit_Put_f   : Exit_Put_z        Buy_Entry_msg =  tt=="BUY"  ? Buy_Call  : Sell_Call             Sell_Entry_msg =  tt=="BUY"  ? Buy_Put   : Sell_Put              buy_s_entry_msg_i = str.format(ZX_buy_s_entry_msg_i  ,  qty, tostring(close)  )    sell_s_entry_msg_i = str.format(ZX_sell_s_entry_msg_i ,  qty, tostring(close)  )    buy_s_exit_msg = str.format(ZX_buy_s_exit_msg     ,  qty, tostring(close)  )    sell_s_exit_msg = str.format(ZX_sell_s_exit_msg    ,  qty, tostring(close)  )    Buy_Entry_msg      := Want_PaperTrading   ? buy_s_entry_msg_i   : Buy_Entry_msg        Sell_Entry_msg     := Want_PaperTrading   ? sell_s_entry_msg_i  : Sell_Entry_msg       Exit_Call          := Want_PaperTrading   ? buy_s_exit_msg      : Exit_Call            Exit_Put           := Want_PaperTrading   ? sell_s_exit_msg     : Exit_Put             return_ =     result==1 ? Buy_Entry_msg                          : result==2 ? Sell_Entry_msg                         : result==3 ? Exit_Call                         : result==4 ? Exit_Put : "Error"    return_         group_indicator_1 = "🟥 🟥 🟥 🟥 Indicator Settings 🟥 🟥 🟥 🟥 "Periods_spt = input(title="ATR Period",     type=input.integer,               defval=10,     group=group_indicator_1)src_spt = input(title="Source",                                           defval=hl2,    group=group_indicator_1)Multiplier_spt = input(title="ATR Multiplier", type=input.float, step=0.1,       defval=3.0,    group=group_indicator_1)changeATR_spt = input(title="Change ATR Calculation Method ?", type=input.bool, defval=true,   group=group_indicator_1)showsignals_spt = input(title="Show Buy/Sell Signals ?",         type=input.bool, defval=true,   group=group_indicator_1)highlighting_spt = input(title="Highlighter On/Off ?",            type=input.bool, defval=true,   group=group_indicator_1)candle_type_ssl = input(defval="HeikenAshi", title="Candle_Type_Filter", options = ["HeikenAshi", "CandleStick", "Same as Chart"],    group=group_indicator_1)f_spt()=>        atr2_spt = sma(tr, Periods_spt)    atr_spt = changeATR_spt ? atr(Periods_spt) : atr2_spt    up_spt =    src_spt  -  (Multiplier_spt*atr_spt)    up1_spt =    nz(up_spt[1],up_spt)    up_spt     :=   close[1] > up1_spt ? max(up_spt,up1_spt) : up_spt    dn_spt =    src_spt+(Multiplier_spt*atr_spt)    dn1_spt =    nz(dn_spt[1], dn_spt)    dn_spt     :=   close[1] < dn1_spt ? min(dn_spt, dn1_spt) : dn_spt    trend_spt =    1    trend_spt  :=   nz(trend_spt[1], trend_spt)    trend_spt  :=   trend_spt == -1 and close > dn1_spt ? 1 : trend_spt == 1 and close < up1_spt ? -1 : trend_spt        [trend_spt, up_spt, dn_spt][trend_spt_1, up_spt_1, dn_spt_1] = f_spt()[trend_spt_2, up_spt_2, dn_spt_2] = security(heikinashi(tickerid(syminfo.prefix,syminfo.ticker)), timeframe.period, f_spt())    [trend_spt_3, up_spt_3, dn_spt_3] = security(syminfo.tickerid, timeframe.period, f_spt())    trend_spt =  candle_type_ssl=="HeikenAshi" ?  trend_spt_2    : candle_type_ssl=="CandleStick" ? trend_spt_2   : trend_spt_1  up_spt =  candle_type_ssl=="HeikenAshi" ?  up_spt_2       : candle_type_ssl=="CandleStick" ? up_spt_2      : up_spt_1     dn_spt =  candle_type_ssl=="HeikenAshi" ?  dn_spt_2       : candle_type_ssl=="CandleStick" ? dn_spt_2      : dn_spt_1     buySignal_spt = trend_spt == 1  and trend_spt[1] == -1sellSignal_spt = trend_spt == -1 and trend_spt[1] == 1plotshape(buySignal_spt  ? up_spt : na, title="UpTrend Begins",   location=location.absolute, style=shape.circle, size=size.tiny, color=color.green )plotshape(sellSignal_spt ? dn_spt : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red   )plotshape(buySignal_spt  and showsignals_spt ? up_spt : na, title="Buy",  text="Buy",  location=location.absolute, style=shape.labelup,   size=size.tiny, color=color.green, textcolor=color.white)plotshape(sellSignal_spt and showsignals_spt ? dn_spt : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red,   textcolor=color.white)longFillColor_spt = highlighting_spt ? (trend_spt == 1 ? color.green : color.white) : color.whiteshortFillColor_spt = highlighting_spt ? (trend_spt == -1 ? color.red : color.white) : color.whitemPlot_spt = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)upPlot_spt = plot(trend_spt == 1 ? up_spt : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)dnPlot_spt = plot(trend_spt == 1 ? na : dn_spt, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)fill(mPlot_spt, upPlot_spt, title="UpTrend Highligter", color=longFillColor_spt)fill(mPlot_spt, dnPlot_spt, title="DownTrend Highligter", color=shortFillColor_spt)want_intraday = input(defval=false, type=input.bool,    title="Want_Intraday",                                      group=" ════╣ Entry Time ↓╠════")start_hours = input(defval=9 ,    type=input.integer, title="Hours",   minval=0, maxval=23, inline="Entry_Time",  group=" ════╣ Entry Time ↓╠════")start_minutes = input(defval=0 ,    type=input.integer, title="Minutes", minval=0, maxval=59, inline="Entry_Time",  group=" ════╣ Entry Time ↓╠════")draw_entry_area = input(defval=false, type=input.bool,    title="Highlight",                    inline="Entry_Time",  group=" ════╣ Entry Time ↓╠════")time_entry()   =>  want_intraday ? ((hour > start_hours   ) ? true   :  (hour < start_hours   ) ? false   :  (hour == start_hours   )  ?  minute >= start_minutes   : false) : truebgcolor(time_entry()   and draw_entry_area                               ? color.red  : na, title="Entry_Time Area")end_hours = input(defval=14,    type=input.integer, title="Hours",   minval=0, maxval=23, inline="Exit_Time",  group=" ════╣ Exit Time ↓╠════")end_minutes = input(defval=55,    type=input.integer, title="Minutes", minval=0, maxval=59, inline="Exit_Time",  group=" ════╣ Exit Time ↓╠════")draw_exit_area = input(defval=false, type=input.bool,    title="Highlight",                    inline="Exit_Time",  group=" ════╣ Exit Time ↓╠════")time_exit()  =>  want_intraday ? ((hour > end_hours   ) ? true   :  (hour < end_hours   ) ? false   :  (hour == end_hours   )  ?  minute >= end_minutes   : false) : falsebgcolor(time_exit()   and draw_exit_area                               ? color.red  : na, title="Exit_Time Area")group_date = "🟥 🟥 🟥 🟥 Date- Filter 🟥 🟥 🟥 🟥 "fromDay = input(defval = 1,    inline="xx_x", title = "From Day",     minval = 1, maxval = 31, group=group_date)fromMonth = input(defval = 1,    inline="xx_x", title = "     Month",   minval = 1, maxval = 12, group=group_date)fromYear = input(defval = 2015, inline="xx_x", title = "     Year",    minval = 1970,           group=group_date) toDay = input(defval = 1,     inline="xx_y", title = "To Day",   minval = 1, maxval = 31, group=group_date)toMonth = input(defval = 1,     inline="xx_y", title = "   Month", minval = 1, maxval = 12, group=group_date)toYear = input(defval = 2023,  inline="xx_y", title = "   Year",  minval = 1970          , group=group_date) startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)finishDate = timestamp(toYear,   toMonth,   toDay,   00, 00)time_cond()  => time >= startDate and time <= finishDategroup_strategy_qty_1 = "======== Quantity-Settings ↓========"want_qty_feature = input(defval=true,   title="Want_Quantity Feature",      group=group_strategy_qty_1)want_qty_feature_refresh = input(defval=true,   title="Want_Quantity Feature Refresh Daily",      group=group_strategy_qty_1)qty_1_x_max = input(defval=100.0,  title="Max_Qty",                    group=group_strategy_qty_1)qty_1_x = input(defval=25.0,   title="Entry Quanity",              group=group_strategy_qty_1)f_martangle_qty_1()=>    var qty_1 =     0.0    var loss_trade =     false         if dayofmonth!=dayofmonth[1] and want_qty_feature_refresh        loss_trade    := false        qty_1         := qty_1_x                            if change(strategy.losstrades) and (strategy.losstrades+strategy.wintrades)>1        loss_trade    := true    if change(strategy.wintrades)  and (strategy.losstrades+strategy.wintrades)>1        loss_trade    := false            if  loss_trade  and change(strategy.losstrades) and  qty_1_x_max > qty_1        qty_1         := qty_1 * 2                            if  loss_trade==false //and strategy.position_size==0         qty_1         := qty_1_x                             if want_qty_feature==false        qty_1         := qty_1_x                     qty_1            buy_time = buySignal_spt  and strategy.position_size<=0 and time_cond()  and  time_entry()  and  time_exit()==false sell_time = sellSignal_spt and strategy.position_size>=0 and time_cond()  and  time_entry()  and  time_exit()==false exit_alert_msg_1 = functions_algo_syntax(f_martangle_qty_1(), 3 )exit_alert_msg_2 = functions_algo_syntax(f_martangle_qty_1(), 4 )if strategy.position_size > 0     strategy.close( 'Buy',  when=time_exit() and want_intraday, alert_message=exit_alert_msg_1,    comment="EoD_Exit")if strategy.position_size < 0     strategy.close( 'Sell', when=time_exit() and want_intraday, alert_message=exit_alert_msg_2,    comment="EoD_Exit")strategy.close("Buy",  when= sell_time,    comment="Buy_Exit",  alert_message=functions_algo_syntax(f_martangle_qty_1(), 3 ))strategy.close("Sell", when= buy_time,     comment="Sell_Exit", alert_message=functions_algo_syntax(f_martangle_qty_1(), 4 ))group_strategy_tp_sl_1 = "======== TP-SL-Main & Reverse ↓========"tp_sl_type = input(defval="Percent",title="TP-SL Type",             options=["Points","Percent"],  group=group_strategy_tp_sl_1)target_points_1_00 = input(defval=20,       title="Target     ",            type=input.float, minval=0 ,   group=group_strategy_tp_sl_1)sl_points_1_00 = input(defval=30,       title="Stop-Loss ",             type=input.float, minval=0 ,   group=group_strategy_tp_sl_1 )want_spt_tp = input(defval=true,     title="Want Supertrend TP ",    type=input.bool,   inline="aabjbdkjbsk",  group=group_strategy_tp_sl_1 )spt_tp_factor = input(defval=1,        title="X-times ",               type=input.float,  inline="aabjbdkjbsk",  group=group_strategy_tp_sl_1 )SPT_value = buySignal_spt  ? up_spt : sellSignal_spt ? dn_spt : naspt_sl_x = round(   (  abs(close -  SPT_value) *spt_tp_factor ) /syminfo.mintick  )spt_sl = 0spt_sl              := buy_time or sell_time ? spt_sl_x :    spt_sl[1]target_points_1_01 = round(  ( close* (target_points_1_00*0.01) )/syminfo.mintick)target_points_1_02 = round(target_points_1_00/syminfo.mintick)target_points_1 = tp_sl_type=="Points" ? target_points_1_02 : target_points_1_01target_points_1     := want_spt_tp  ? min(target_points_1, spt_sl ) : target_points_1sl_points_1_01 = round(  ( close* (sl_points_1_00*0.01) )/syminfo.mintick)sl_points_1_02 = round(sl_points_1_00/syminfo.mintick)sl_points_1 = tp_sl_type=="Points" ? sl_points_1_02 : sl_points_1_01group_strategy_1 = "🟧 🟧 🟧  Strategy   - Settings 🟧 🟧 🟧 "group_strategy_2 = "🟧 🟧 🟧  SL-Trailing- Settings 🟧 🟧 🟧 "want_buy = input(title="Want_Buy_Side",     defval=true,     type=input.bool, group=group_strategy_1)want_sell = input(title="Want_Sell_Side",    defval=true,     type=input.bool, group=group_strategy_1)strategy.entry("Buy",  true,  when= buy_time    and  want_buy ,     qty = f_martangle_qty_1() , alert_message=functions_algo_syntax(f_martangle_qty_1(), 1 ))strategy.entry("Sell", false, when= sell_time   and  want_sell,     qty = f_martangle_qty_1() , alert_message=functions_algo_syntax(f_martangle_qty_1(), 2 ))strategy.exit('Buy_Exit' ,  'Buy',   loss=sl_points_1,  profit=target_points_1 , alert_message=functions_algo_syntax(f_martangle_qty_1(), 3 ) )strategy.exit('Sell_Exit',  'Sell',  loss=sl_points_1,  profit=target_points_1 , alert_message=functions_algo_syntax(f_martangle_qty_1(), 4 ) )