Advertisement
Maurizio-Ciullo

Study Test Alert-Ingre-Limit Canc-Ord-Pend

Oct 27th, 2022
1,454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //  QUESTO TEST SERVE A VERIFICARE CON UNA STRATEGIA FITTIZIA INGRESSI E USCITE LIMIT CANCELLANDO GLI ORDINI PENDENTI PRIMA DELL'ESECUZIONE
  2. // DI UN NUOVO ORDINE O UNA NUOVA CONDIZIONE
  3.  
  4.                                                 //TEST CANCEL PENDING ALERT BTC/PERP 1 MINUTO
  5.  
  6. //@version=5
  7. strategy(title="Study Test Alert/Ingre Limit/Canc Ord Pend", overlay=true, precision = 4,
  8.      //max_bars_back=5000, // Serve Per Caricare PiΓΉ Storico Per Il Trailing Stop
  9.      pyramiding=0,
  10.      initial_capital=150,
  11.      commission_type=strategy.commission.percent,
  12.      commission_value=0.1,
  13.      slippage=3,
  14.      default_qty_type=strategy.percent_of_equity,
  15.      default_qty_value=15)
  16.      
  17.  
  18. // Input
  19.  
  20. input_stop_loss_long = input.float(title='stop_loss_long', defval=0.1, minval=0, maxval=100, step=0.1, group='Stop&Target')
  21. input_take_profit_long = input.float(title='take_profit_long', defval=0.1, minval=0, maxval=100, step=0.1, group='Take Profit')
  22. input_stop_loss_short = input.float(title='stop_loss_short', defval=0.1, minval=0, maxval=100, step=0.1, group='Stop&Target')
  23. input_take_profit_short = input.float(title='take_profit_short', defval=0.1, minval=0, maxval=100, step=0.1, group='Take Profit')
  24. input_cancel_pending_limit_long = input.int(title='cancel_limit_pending_long', defval=10, minval=0, maxval=500, group='Cancel Pending Orders')
  25. input_cancel_pending_limit_short = input.int(title='cancel_limit_pending_short', defval=10, minval=0, maxval=500, group='Cancel Pending Orders')
  26. input_MyExitCountBarL = input.int(title='MyExitCountBarL', defval=2, minval=0, maxval=500, group='Exit Bars Counter')
  27. input_MyExitCountBarS = input.int(title='MyExitCountBarS', defval=2, minval=0, maxval=500, group='Exit Bars Counter')
  28. // only_Long = input.bool(title='Solo long trade', defval=false, inline='1', group='Direzione')
  29. // only_Short = input.bool(title='Solo short trade', defval=false, inline='1', group='Direzione')
  30.  
  31.  
  32. // Calculate MyEntryCountBar
  33. MyEntryCountBar = bar_index - strategy.opentrades.entry_bar_index(0)
  34. MyEntryCountBar := MyEntryCountBar + 1
  35. //plot(MyEntryCountBar, title="MyEntryCountBar")
  36. // plot(bar_index, title="bar_index")
  37. // plot(strategy.opentrades.entry_bar_index(0), title="strategy.open")
  38. plotshape(MyEntryCountBar >  input_MyExitCountBarL and strategy.position_size > 0, text="MyExitCountBarL")
  39. plotshape(MyEntryCountBar > input_MyExitCountBarS and strategy.position_size < 0, text="MyExitCountBarS")
  40.  
  41.  
  42. // Variabili Stop E Take Profit Long
  43. stop_loss_long_price = (strategy.opentrades.entry_price(0) - (strategy.opentrades.entry_price(0) * input_stop_loss_long) / 100)
  44. stop_loss_long = (strategy.opentrades.entry_price(0) - stop_loss_long_price) / syminfo.mintick
  45. take_profit_long_price = (strategy.opentrades.entry_price(0) + ((strategy.opentrades.entry_price(0) * input_take_profit_long) / 100))
  46. take_profit_long = (take_profit_long_price - strategy.opentrades.entry_price(0)) / syminfo.mintick
  47.  
  48. // Variabili Stop E Take Profit Short
  49. stop_loss_short_price = (strategy.opentrades.entry_price(0) + (strategy.opentrades.entry_price(0) * input_stop_loss_short) / 100)
  50. stop_loss_short = (stop_loss_short_price - strategy.opentrades.entry_price(0)) / syminfo.mintick
  51. take_profit_short_price = (strategy.opentrades.entry_price(0) - ((strategy.opentrades.entry_price(0) * input_take_profit_short) / 100))
  52. take_profit_short =(strategy.opentrades.entry_price(0) - take_profit_short_price) / syminfo.mintick
  53.  
  54. plot(strategy.position_size != 0 ? strategy.opentrades.entry_price(0) : na , color=strategy.position_size > 0 ? color.blue : strategy.position_size < 0 ? color.red : na, style=plot.style_linebr, title="entry_price") // stampa l'entry price in rosso se short in blu se long
  55. plot(strategy.position_size > 0 ?  take_profit_long_price : strategy.position_size < 0 ? take_profit_short_price: na, color=color.green, style=plot.style_cross, linewidth=2, title="tk_limit")
  56. plot(strategy.position_size > 0 ?  stop_loss_long_price : strategy.position_size < 0 ? stop_loss_short_price: na, color=color.red, style=plot.style_cross, linewidth=2, title="sl_limit")
  57.  
  58. bgcolor(strategy.position_size > 0 ? color.green : strategy.position_size < 0 ? color.red : na, transp=90)// sfondo verde quando siamo long, sfondo rosso quando siamo short, no sfondo quando non siamo in posizione //color.new(color.red, 99): na)
  59.  
  60.  
  61. //------------------------------------ Inizio Codice se voglio attivare un trigger ored touched ------------------------------------//
  62.  
  63.  
  64. // Variabili Trigger Fill Or Cancel Long
  65. input_trigger_fill_or_cancel_long = input.float(title='trigger_fill_or_cancel_long', defval=0.02, minval=0, maxval=100, step=0.01, group='Trigger Fill Or Cancel')
  66. input_trigger_fill_or_cancel_short = input.float(title='trigger_fill_or_cancel_short', defval=0.02, minval=0, maxval=100, step=0.01, group='Trigger Fill Or Cancel')
  67.  
  68. trigger_fill_or_cancel_long = (strategy.opentrades.entry_price(0) - (strategy.opentrades.entry_price(0) * input_trigger_fill_or_cancel_long) / 100)
  69. //plot(trigger_fill_or_cancel_long, title="fill_or_canc_l", color=color.yellow)
  70.  
  71. // take_profit_long_price = (strategy.opentrades.entry_price(0) + ((strategy.opentrades.entry_price(0) * input_take_profit_long) / 100))
  72.  
  73. // Variabili Trigger Fill Or Cancel Long
  74. trigger_fill_or_cancel_short = (strategy.opentrades.entry_price(0) + (strategy.opentrades.entry_price(0) * input_trigger_fill_or_cancel_short) / 100)
  75. plot(trigger_fill_or_cancel_short, title="fill_or_canc_s", color=color.yellow)
  76.  
  77. // take_profit_short_price = (strategy.opentrades.entry_price(0) - ((strategy.opentrades.entry_price(0) * input_take_profit_short) / 100))
  78.  
  79.  
  80.  
  81.  
  82. range_barre_trailing = bar_index - strategy.opentrades.entry_bar_index(0) +1
  83. plot(range_barre_trailing, title = 'lunghezza')
  84.  
  85. highesthigh = strategy.opentrades ==1 ? ta.highest(high, range_barre_trailing): na
  86. plot(highesthigh, title="hh",  color=color.rgb(238, 68, 187))
  87.  
  88. lowestlow = strategy.opentrades ==1 ? ta.lowest(low, range_barre_trailing): na
  89. //plot(lowestlow, title="ll", color=color.rgb(68, 238, 68))
  90.  
  91.  
  92.  
  93.  
  94. pending_cancelled_l = 0
  95. if trigger_fill_or_cancel_long <= lowestlow
  96.     pending_cancelled_l := 1
  97. else
  98.     pending_cancelled_l := 0
  99. plot(pending_cancelled_l, title="pen_canc_l")
  100.  
  101. pending_cancelled_s = 0
  102. if trigger_fill_or_cancel_short >= highesthigh
  103.     pending_cancelled_s := 1
  104. else
  105.     pending_cancelled_s := 0
  106. plot(pending_cancelled_s, title="pen_canc_s")
  107.  
  108.  
  109.  
  110.  
  111. // // Cancel the pending take profit and stop loss orders left once they are hit QUESTO FUNZIONA MA VA TESTATO
  112. // // var int hit_tk = 0
  113. // var int hit_tk_sl = 0
  114.  
  115. // if high >= take_profit_long or low <= stop_loss_long or low <= take_profit_short or high >=  stop_loss_short
  116. //     hit_tk_sl := 0
  117. // else
  118. //     hit_tk_sl := 1
  119. // //plot(hit_tk_sl)
  120.  
  121.  
  122.  
  123.  
  124. //------------------------------------ Fine Codice se voglio attivare un trigger ored touched ------------------------------------//
  125.  
  126.  
  127. /////////////////////////  INIZIO LAVORO DA QUI IN POI ///////////////////////// ,"delay":"15"}'
  128.  
  129.  
  130. // Qui abbiamo in delay buy, sell, close command: ,"delay":"15" per dare il tempo di cancellare prima eventuali ordini pendenti e poi entrare in posizione
  131. // Il cancel command non deve avere il delay.
  132. buy_command = '{"pair":"BTC-PERP","unitsPercent":10,"unitsType":"percentBalance","exchange":"Ftx","apiKey":"FTX","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","isBuy":true,"isLimit":true,"price":19139,"limitPriceType":"bestPrice","stopLossPercent":"-0.1","stopLossType":"percent","leverage":1,"marginType":"ISOLATED","targets":[{"idx":1,"amount":"100","takeProfitPercent":"0.1"}],"targetType":"percent","targetAmountInPercent":true,"closeCurrentPosition":true,"preventPyramiding":true,"delay":"15"}'
  133. sell_command = '{"pair":"BTC-PERP","unitsPercent":10,"unitsType":"percentBalance","exchange":"Ftx","apiKey":"FTX","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","isSell":true,"isLimit":true,"price":19141,"limitPriceType":"bestPrice","stopLossPercent":"-0.1","stopLossType":"percent","leverage":1,"marginType":"ISOLATED","targets":[{"idx":1,"amount":"100","takeProfitPercent":"0.1"}],"targetType":"percent","targetAmountInPercent":true,"closeCurrentPosition":true,"preventPyramiding":true,"delay":"15"}'
  134. close_command = '{"pair":"BTC-PERP","unitsPercent":10,"exchange":"Ftx","apiKey":"FTX","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","isLimit":true,"price":19143,"limitPriceType":"bestPrice","isClose":true}'
  135. //cancel_command = '{"pair":"BTC-PERP","unitsPercent":10,"exchange":"Ftx","apiKey":"FTX","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","isLimit":true,"price":19144,"limitPriceType":"bestPrice","stopLossPercent":"-0.1","stopLossType":"percent","leverage":1,"marginType":"ISOLATED","targets":[{"idx":1,"amount":"100","takeProfitPercent":"0.1"}],"targetType":"percent","targetAmountInPercent":true,"closeCurrentPosition":true,"preventPyramiding":true,"cancelAll":true}'
  136.  
  137. // Condizione Entrata Long
  138. condEntryLong = close > open and close[1] > open[1]
  139. //Condizione Entrata Short
  140. condEntryShort = open > close and  open[1] >close[1]
  141.  
  142.  
  143. // Cancel the pending long entry order if not filled in the number bar since 1      
  144. if condEntryLong and strategy.position_size <0 or condEntryLong and strategy.position_size ==0 //or strategy.position_size >0 and MyEntryCountBar > input_MyExitCountBarL
  145.     //strategy.cancel("operazioneShort") // when = CancelLong // //strategy.cancel("operazioneLong")
  146.     strategy.cancel_all()
  147.     alert(message='{"pair":"BTC-PERP","unitsPercent":10,"exchange":"Ftx","apiKey":"FTX","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","isLimit":true,"price":19144,"limitPriceType":"bestPrice","stopLossPercent":"-0.1","stopLossType":"percent","leverage":1,"marginType":"ISOLATED","targets":[{"idx":1,"amount":"100","takeProfitPercent":"0.1"}],"targetType":"percent","targetAmountInPercent":true,"closeCurrentPosition":true,"preventPyramiding":true,"cancelAll":true}', freq=alert.freq_once_per_bar_close)
  148. // plotshape(MyEntryCountBar == input_cancel_pending_limit_long, title="cancel_pending_limit_long")
  149.  
  150. // Entrata Long PROBABILMENTE RITARDATA DALLA STRINGA BUY COMMAND PER DARE PRIMA IL TEMPO DI CANCELLARE EVENTUALI ORDINI APERTI
  151. if condEntryLong //and strategy.opentrades == 0 FORSE AGGIUNGERE RITARDI INGRESSO PER VIA DELL'ANNULLAMENTO ORDINITK E SL
  152.     strategy.entry('operazioneLong', strategy.long, limit = close, alert_message = "Open Long Position", comment = buy_command)
  153.  
  154. if strategy.opentrades == 1
  155.     strategy.exit('SL e TP', from_entry='operazioneLong', loss=stop_loss_long, profit=take_profit_long, alert_message = "Your Long SL-TP Has Been Triggered.", comment = close_command) //limit=take_profit_short_price    
  156. // Cancel the pending long entry order if not filled in the number bar since 1
  157. // if MyEntryCountBar == input_cancel_pending_limit_long
  158. //  strategy.cancel("operazioneLong") // when = CancelLong
  159. //     alert(message='{"pair":"BTC-PERP","unitsPercent":"6","exchange":"Ftx","apiKey":"FTX","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","isLimit":true,"price":19180,"limitPriceType":"bestPrice","stopLossPercent":"-0.1","stopLossType":"percent","leverage":1,"marginType":"ISOLATED","targets":[{"idx":1,"amount":"100","takeProfitPercent":"0.1"}],"targetType":"percent","targetAmountInPercent":true,"closeCurrentPosition":true,"preventPyramiding":true,"cancelAll":true}', freq=alert.freq_once_per_bar_close)
  160. // plotshape(MyEntryCountBar == input_cancel_pending_limit_long, title="cancel_pending_limit_long")
  161.  
  162. // Cancel the pending long entry order if not filled in the number bar since 2
  163. // if pending_cancelled_l == 1 and condEntryShort
  164. //  strategy.cancel("operazioneLong") // when = CancelLong
  165. //     alert(message='{"pair":"BTC-PERP","unitsPercent":10,"exchange":"Ftx","apiKey":"FTX","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","isLimit":true,"price":19159,"limitPriceType":"bestPrice","stopLossPercent":"-0.1","stopLossType":"percent","leverage":1,"marginType":"ISOLATED","targets":[{"idx":1,"amount":"100","takeProfitPercent":"0.1"}],"targetType":"percent","targetAmountInPercent":true,"closeCurrentPosition":true,"preventPyramiding":true,"delay":"10","cancelAll":true}', freq=alert.freq_once_per_bar_close)
  166. // plotshape(pending_cancelled_l == 1 and condEntryShort, title="cancel_pending_limit_long")
  167.  
  168. // Uscita Long (stop/limit x prezzo) (loss/profit x ticks)
  169. // if strategy.opentrades ==1 and high <= stop_loss_long or strategy.opentrades ==1 and high >= stop_loss_long
  170. //     strategy.exit('SL e TP LONG', from_entry='operazioneLong', loss=stop_loss_long, profit=take_profit_long, alert_message = "Your Long SL-TP Has Been Triggered.")//, comment = close_command) //limit=take_profit_long_price
  171.  
  172. //Uscita Long Exit Count Bar
  173. if strategy.opentrades ==1 and MyEntryCountBar > input_MyExitCountBarL
  174.     strategy.close(id='operazioneLong', alert_message = "Close Long Position", comment = close_command)
  175.  
  176.  
  177. //plot(strategy.opentrades, title = "open")
  178.  
  179.  
  180.  
  181.  
  182. //Cancel the pending short entry order if not filled in the number bar since 1
  183. //LA CANCELLAZZIONE PENDING DOPO EXIT BARS: or strategy.position_size >0 and MyEntryCountBar > input_MyExitCountBarL
  184. //POTREBBE SEERE RIDONDANTE E FORSE INCASINATA PERCHE' GLI ORDINI CLOSE E CANCEL ARRIVANO ISSIEME E QUINDI DIVREI AGGIUNGERE
  185. //UN RITARDO SULLA STRINGA CANCEL E AUMENTARE DI CONSEGUENZA ANCHE IL RITARDO ATTUALE DEGLI INGRESSI PER TENERLI SEMPRE DISTANTI              
  186. if condEntryShort and strategy.position_size >0 or condEntryShort and strategy.position_size ==0 //or strategy.position_size <0 and MyEntryCountBar > input_MyExitCountBarS
  187.     //strategy.cancel("operazioneLong") // when = CancelShort // //strategy.cancel("operazioneShort")
  188.     strategy.cancel_all()
  189.     alert(message='{"pair":"BTC-PERP","unitsPercent":10,"exchange":"Ftx","apiKey":"FTX","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","isLimit":true,"price":19144,"limitPriceType":"bestPrice","stopLossPercent":"-0.1","stopLossType":"percent","leverage":1,"marginType":"ISOLATED","targets":[{"idx":1,"amount":"100","takeProfitPercent":"0.1"}],"targetType":"percent","targetAmountInPercent":true,"closeCurrentPosition":true,"preventPyramiding":true,"cancelAll":true}', freq=alert.freq_once_per_bar_close)
  190. // plotshape(MyEntryCountBar == input_cancel_pending_limit_short, title="cancel_pending_limit_short")
  191.  
  192. // Entrata Short PROBABILMENTE RITARDATA DALLA STRINGA BUY COMMAND PER DARE PRIMA IL TEMPO DI CANCELLARE EVENTUALI ORDINI APERTI
  193. if condEntryShort //and strategy.opentrades == 0 // FORSE AGGIUNGERE RITARDI INGRESSO PER VIA DELL'ANNULLAMENTO ORDINITK E SL
  194.     strategy.entry('operazioneShort', strategy.short, limit = close, alert_message = "Open Short Position", comment = sell_command)
  195.  
  196. // Uscita Short (stop/limit x prezzo) (loss/profit x ticks)
  197. if strategy.opentrades == 1
  198.     strategy.exit('SL e TP', from_entry='operazioneShort', loss=stop_loss_short, profit=take_profit_short, alert_message = "Your Short SL-TP Has Been Triggered.", comment = close_command) //limit=take_profit_short_price    
  199.  
  200. //Cancel the pending short entry order if not filled in the number bar since 1
  201. // if MyEntryCountBar == input_cancel_pending_limit_short
  202. //     strategy.cancel("operazioneShort") // when = CancelShort
  203. //     alert(message='{"pair":"BTC-PERP","unitsPercent":"6","exchange":"Ftx","apiKey":"FTX","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","isLimit":true,"price":19180,"limitPriceType":"bestPrice","stopLossPercent":"-0.1","stopLossType":"percent","leverage":1,"marginType":"ISOLATED","targets":[{"idx":1,"amount":"100","takeProfitPercent":"0.1"}],"targetType":"percent","targetAmountInPercent":true,"closeCurrentPosition":true,"preventPyramiding":true,"cancelAll":true}', freq=alert.freq_once_per_bar_close)
  204. // plotshape(MyEntryCountBar == input_cancel_pending_limit_short, title="cancel_pending_limit_short")
  205.  
  206. //Cancel the pending short entry order if not filled in the number bar since 2
  207. // if pending_cancelled_s == 1 and condEntryLong
  208. //     strategy.cancel("operazioneShort") // when = CancelShort
  209. //     alert(message='{"pair":"BTC-PERP","unitsPercent":10,"exchange":"Ftx","apiKey":"FTX","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","isLimit":true,"price":19159,"limitPriceType":"bestPrice","stopLossPercent":"-0.1","stopLossType":"percent","leverage":1,"marginType":"ISOLATED","targets":[{"idx":1,"amount":"100","takeProfitPercent":"0.1"}],"targetType":"percent","targetAmountInPercent":true,"closeCurrentPosition":true,"preventPyramiding":true,"delay":"10","cancelAll":true}', freq=alert.freq_once_per_bar_close)
  210. // plotshape(pending_cancelled_s == 1 and condEntryLong, title="cancel_pending_limit_short")
  211.  
  212.  
  213.  
  214. // Uscita Long Exit Count Bar
  215. if strategy.opentrades ==1 and MyEntryCountBar > input_MyExitCountBarS
  216.     strategy.close(id='operazioneShort', alert_message = "Close Short Position", comment = close_command)
  217.  
  218. // // Cancel the pending take profit and stop loss orders left once they are hit //on both side long and short
  219. // // FORSE METTERE CANCEL ALL
  220. // if strategy.position_size > 0 and hit_tk_sl == 1
  221. //     strategy.cancel("SL e TP LONG") // when = hit_tk_sl
  222. // if strategy.position_size < 0 and hit_tk_sl == 1
  223. //     strategy.cancel("SL e TP SHORT") // when = hit_tk_sl
  224. //     alert(message='{"pair":"LEO-PERP","unitsPercent":"6","exchange":"Ftx","apiKey":"FTX","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","isLimit":true,"price":4.2992,"limitPriceType":"bestPrice","stopLossPercent":"-12","stopLossType":"percent","leverage":1,"marginType":"ISOLATED","targets":[{"idx":1,"amount":"100","takeProfitPercent":"9"}],"targetType":"percent","targetAmountInPercent":true,"closeCurrentPosition":true,"preventPyramiding":true,"cancelAll":true}', freq=alert.freq_once_per_bar_close)
  225. // plotshape(hit_tk_sl, title="hit_tk_sl")
  226.  
  227. plot(strategy.position_size, title="posit_size")
  228. plotshape(condEntryLong and strategy.position_size <0 or condEntryLong and strategy.position_size ==0)
  229. plotshape(condEntryShort and strategy.position_size >0 or condEntryShort and strategy.position_size ==0)
  230.  
  231.  
  232. // Nome Alert: Test 4 Cancellare Alert
  233. // Commento Alert: {{strategy.order.comment}}
  234.  
  235.  
  236. /////////////////////////  FINE LAVORO DA QUI  /////////////////////////
  237.  
  238.  
  239.  
  240.  
  241.  
  242. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  243.  
  244.  
  245. // ELABORAZIONE CANCELLAZZIONE ORDINE PENDENTE DOPO OPPOSTO SE PRESO UN TK O STOP //
  246. //PER METTERE INGRESSI LIMIT SU TV-HUB NON ABBIAMO MESSO CANCEL PENDING ORDERS, PER QUESTO MOTIVO LI DEVO FARE A MANO //
  247.  
  248. // // QUESTO FUNZIONA MA VA TESTATO
  249. // // var int hit_tk = 0
  250. // var int hit_tk_sl = 0
  251.  
  252. // if high >= take_profit_long or low <= stop_loss_long or low <= take_profit_short or high >=  stop_loss_short
  253. //     hit_tk_sl := 0
  254. // else
  255. //     hit_tk_sl := 1
  256. // plot(hit_tk_sl)
  257.  
  258.  
  259.  
  260. //plot(strategy.opentrades, title="open_trades")
  261. //plot(strategy.position_size, title="position_size")
  262.  
  263.  
  264.  
  265.  
  266. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  267.  
  268.  
  269. // PROVA ANCHE CON ALTRI METODI DI POSIZIONE
  270.  
  271. // bought = strategy.position_size[0]> strategy.position_size[1]
  272. // Close_TP = false    
  273. // Close_TP := strategy.position_size[1] - strategy.position_size[0] and strategy.position_size[1] != 0 and strategy.position_size[0] != 0
  274.  
  275.  
  276. // plotshape(Close_TP,title="Close_TP", style=shape.xcross, color=color.blue, size =size.small, editable = true)
  277. // plot(strategy.position_size[1],"Position Old")
  278. // plot(strategy.position_size,"Position")
  279.  
  280.  
  281. //plot(strategy.opentrades.entry_time(0)[1], title="bar_in")
  282.  
  283.  
  284. //     strategy.cancel("operazioneLong") // when = CancelLong
  285. //     alert(message='{"pair":"LEO-PERP","unitsPercent":"6","exchange":"Ftx","apiKey":"FTX","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","isLimit":true,"price":4.2992,"limitPriceType":"bestPrice","stopLossPercent":"-12","stopLossType":"percent","leverage":1,"marginType":"ISOLATED","targets":[{"idx":1,"amount":"100","takeProfitPercent":"9"}],"targetType":"percent","targetAmountInPercent":true,"closeCurrentPosition":true,"preventPyramiding":true,"cancelAll":true}', freq=alert.freq_once_per_bar_close)
  286. // plotshape(high == take_profit_long, title="pending_tk_stop_l")
  287.  
  288.  
  289. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  290.  
  291.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement