Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------*(35 Lezione Personale Attivare Un Trigger Orer Touched)*-------------------------------------------------
- QUESTO PEZZO DI CODICE SERVE A IMPOSTARE DEI LIVELLI DA INPUT E VERIFICARE SE L'HIGHEST O IL LOWEST PER TUTTA LA NOSTRA POSIZIONE HA OLTREPASSATO QUEL LIVELLO.
- E' MOLTO UTILE NEL CASO AVESSIMO ORDINI PENDENTI PER VERIFICARE SE POI SUCCESSIVAMENTE CANCELLARE UN ORDINE O PER QUALSIASI ALTRA AZIONE.
- ES: SICCOME NON SAPPIAMO MAI SE VERREMO ESEGUITI SUL NOSTRO EXCHANGE DOPO AVER IMMESSO UN INGRESSO LIMIT, CON QUESTO CODICE POSSIAMO ALMENO
- SAPERE SE "DATO UN MARGINE DI SPREAD DA INPUT" QUEL MARGINE E' STATO RAGGIUNTO E ANCHE SE NON ABBIAMO MAI LA CERTEZZA E' COMUNQUE UN UTILE AIUTO
- ES: INGRESSO LIMIT LONG 5,46 / LIVELLI IMPOSTATO A 5.40 / SE IL LOWEST LOW NELLE CANDELE CHE COMPRENDE TUTTO IL MIO TRADE E' PIU' BASSO
- O UGUALE AL MIO LIVELLO, SARA' PIU' PROBABILE CHE IL MIO ORDINE SIA STATO FILLATO E POTREI PRENDERE DELLE DECISIONI AD ESEMPIO DI NON CANCELLARE
- PIU' GLI ORDINI PENDENTI.
- ALTRO MODO DI UTILIZZO PER VERIFICARE SE IL TAKE PROFIT O STOP LOSS E' STATO TOCCATO FACENDO POI CANCELLARE GLI ORDINI PENDENTI
- //------------------------------------ Inizio Codice se voglio attivare un trigger ored touched ------------------------------------//
- //@version=5
- strategy(title="Study Test Alert/Ingre Limit/Canc Ord Pend", overlay=true, precision = 4, ETC...
- // Variabili Trigger Fill Or Cancel Long
- 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')
- 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')
- trigger_fill_or_cancel_long = (strategy.opentrades.entry_price(0) - (strategy.opentrades.entry_price(0) * input_trigger_fill_or_cancel_long) / 100)
- //plot(trigger_fill_or_cancel_long, title="fill_or_canc_l", color=color.yellow)
- // take_profit_long_price = (strategy.opentrades.entry_price(0) + ((strategy.opentrades.entry_price(0) * input_take_profit_long) / 100))
- // Variabili Trigger Fill Or Cancel Long
- trigger_fill_or_cancel_short = (strategy.opentrades.entry_price(0) + (strategy.opentrades.entry_price(0) * input_trigger_fill_or_cancel_short) / 100)
- plot(trigger_fill_or_cancel_short, title="fill_or_canc_s", color=color.yellow)
- // take_profit_short_price = (strategy.opentrades.entry_price(0) - ((strategy.opentrades.entry_price(0) * input_take_profit_short) / 100))
- range_barre_trailing = bar_index - strategy.opentrades.entry_bar_index(0) +1
- plot(range_barre_trailing, title = 'lunghezza')
- highesthigh = strategy.opentrades ==1 ? ta.highest(high, range_barre_trailing): na
- plot(highesthigh, title="hh", color=color.rgb(238, 68, 187))
- lowestlow = strategy.opentrades ==1 ? ta.lowest(low, range_barre_trailing): na
- //plot(lowestlow, title="ll", color=color.rgb(68, 238, 68))
- pending_cancelled_l = 0
- if trigger_fill_or_cancel_long <= lowestlow
- pending_cancelled_l := 1
- else
- pending_cancelled_l := 0
- plot(pending_cancelled_l, title="pen_canc_l")
- pending_cancelled_s = 0
- if trigger_fill_or_cancel_short >= highesthigh
- pending_cancelled_s := 1
- else
- pending_cancelled_s := 0
- plot(pending_cancelled_s, title="pen_canc_s")
- // // Cancel the pending take profit and stop loss orders left once they are hit QUESTO FUNZIONA MA VA TESTATO
- // // var int hit_tk = 0
- // var int hit_tk_sl = 0
- // if high >= take_profit_long or low <= stop_loss_long or low <= take_profit_short or high >= stop_loss_short
- // hit_tk_sl := 0
- // else
- // hit_tk_sl := 1
- // //plot(hit_tk_sl)
- ... IF pending_cancelled_l == 1
- // strategy.cancel("operazioneLong") // when = CancelLong
- // 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)
- // plotshape(... == ..., title="pending_tk_stop_l")
- //------------------------------------ Fine Codice se voglio attivare un trigger ored touched ------------------------------------//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement