Buonasera a tutti,
avrei bisogno di un aiuto. Mi piacerebbe realizzare una strategia di questo tipo :
Entry Long : in caso di pinbar long, entro entro le 5 candele successiva solo se il prezzo arriva a metà candela pinbar. SL = minimo della Pinbar TP = 2xSL
Entry Short : in caso di pinbar short, entro entro le 5 candele successiva solo se il prezzo arriva a metà candela pinbar. SL = minimo della Pinbar TP = 2xSL
Allego immagini per comprendere meglio le entrare e le uscite.
Grazie in anticipo.
Simone
Ecco il codice per quella strategia. Aprirà gli ordini solo durante 5 barre dopo un rilevamento pinbar.
defparam cumulateorders=false
body = ABS(open-close)
bearishwick = ABS(high-close)
bearishnose = ABS(close-low)
bullishwick = ABS(close-low)
bullishnose = ABS(high-close)
//bearish pinbar
bearish= (body/bearishwick)<20/100 AND (body/bearishnose)>100/100
//bullish pinbar
bullish= (body/bullishwick)<20/100 and (body/bullishnose)>100/100
if not longonmarket and bullish then
buylevel = medianprice
buysl = low
buytp = close+(close-low)*2
buystart = barindex
buy at buylevel stop
sell at buysl stop
sell at buytp limit
endif
if longonmarket then
if close<buylevel and barindex-buystart<=5 then
buy at buylevel stop
endif
sell at buysl stop
sell at buytp limit
endif
if not shortonmarket and bearish then
selllevel = medianprice
sellsl = high
selltp = close-(high-close)*2
sellstart = barindex
sellshort at selllevel stop
exitshort at sellsl stop
exitshort at selltp limit
endif
if shortonmarket then
if close>selllevel and barindex-sellstart<=5 then
sellshort at selllevel stop
endif
exitshort at sellsl stop
exitshort at selltp limit
endif
//graphonprice buytp
Nicolas, grazie molte !!!
Sei stato gentilissimo.
Lo provo subito.
Grazie ancora