DEFPARAM CUMULATEORDERS=false //Parameters m=:) P=:) ClotureST=0 (0 or 1) Trail=:) OffsetSL=:) OffsetTP=:) Ratio=:) GainMIN=:) SLmin=:) cotationEURxxx=1.10 Capital = 100000 Risk = 0.003 JPY=0 //If JPY = 1, Fact =100 Fact=1 If Yen =1 then Fact=100 endif // Money Management equity = Capital + StrategyProfit/cotationEURxxx maxrisk = round(equity*Risk) //Supertrend in different Timeframes timeframe (1h,UPDATEONCLOSE) SThour=Supertrend[m,p] timeframe (4h,UPDATEONCLOSE) ST4h=Supertrend[m,p] timeframe (daily,UPDATEONCLOSE) STday=Supertrend[m,p] timeframe (weekly,UPDATEONCLOSE) STweek=Supertrend[m,p] TIMEFRAME(DEFAULT) st = Supertrend[m,p] i=0 j=0 k=0 l=0 x=0 y=0 // ****************BUY********************* If close CROSSES over ST then if ClotureST =1 then EXITSHORT at market Endif WHILE (close[i+1] < st[i+1]) DO i = i+1 j=j+1 WEND WHILE (close[j+1] > st[j+1]) DO j = j+1 WEND SLSTha = lowest[i](low) - OffsetSL*fact TPSTha= close + abs (close-lowest[i](open)) - OffsetTP*fact if (close < sthour and TPSTha > sthour) then TPSTha= sthour - OffsetTP *fact endif if (close < st4h and TPSTha > st4h) then TPSTha= st4h - OffsetTP *fact endif if (close < stday and TPSTha > stday) then TPSTha= stday - OffsetTP *Fact endif if (close < stweek and TPSTha > stweek) then TPSTha= stweek - OffsetTP *fact endif TPSThapips=abs(close-TPSTha)*10000/fact SLSThapips= abs(close-SLSTha)*10000/fact Endif if close > st then WHILE (close[X+1] > st[x+1]) DO X = X+1 WEND SLPBha = SLSTha TPPBha= highest[x](high) TPPBhapips=abs(st-TPPBha)*10000/fact lotEURha=equity*Risk/SLPBhapips PositionSizeHA=lotEURha*CotationEURxxx/fact ratioPBha = TPPBhapips/SLPBhapips > Ratio GainPBha = TPPBhapips>GainMIN If GainPBha and ratioPBha and ObjSTKOha and SLPBhapips > SLmin then BUY PositionSizeHA LOT AT st LIMIT SET STOP pLOSS SLPBhapips SET TARGET pPROFIT TPPBhapips*trail endif ENDIF // ****************SELL********************* If close CROSSES UNDER ST then if ClotureST =1 then Sell at market endif WHILE (close[i+1] > st[i+1]) DO i = i+1 j=j+1 WEND WHILE (close[j+1] < st[j+1]) DO j = j+1 WEND SLSTve = highest[i](high) + OffsetSL*fact TPSTve= close - abs (close-highest[i](close)) + OffsetTP*fact if (close > sthour and TPSTve < sthour) then TPSTve = sthour +OffsetTP *fact endif if (close > st4h and TPSTve < st4h) then TPSTve = st4h +OffsetTP *fact endif if (close > stday and TPSTve < stday) then TPSTve = stday +OffsetTP *fact endif if (close > stweek and TPSTve < stweek) then TPSTve = stweek +OffsetTP *fact endif TPSTvepips=abs(close-TPSTve)*10000/fact SLSTvepips= abs(close-SLSTve)*10000/fact IF CLOSE < st then WHILE (close[y+1] < st[y+1]) DO y=y+1 WEND SLPBve = SLSTve TPPBve= lowest[y](low) TPPBvepips=abs(st-TPPBve)*10000/fact lotEURve=equity*Risk/SLPBvepips PositionSizeVE=lotEURve*CotationEURxxx/fact ratioPBve = TPPBvepips/SLPBvepips > Ratio GainPBve = TPPBvepips>GainMIN If GainPBve and ratioPBve and ObjSTKOve and SLPBvepips > SLmin then SELLSHORT PositionSizeVE LOT AT st LIMIT SET STOP pLOSS SLPBvepips SET TARGET pPROFIT TPPBvepips*Trail Endif Endif