ONCE CandleNum = 3
Bullish = summation[CandleNum](close > open) = CandleNum
Bearish = summation[CandleNum](close < open) = CandleNum
HigherHIGHs = (summation[CandleNum - 1](high > high[1]) = (CandleNum - 1))
LowerLOWs = (summation[CandleNum - 1](low < low[1]) = (CandleNum - 1))
MyRsi = Rsi[14](close)
IF Bearish AND LowerLOWs AND Not OnMarket AND MyRsi > 30 THEN
BUY 1 CONTRACT AT MARKET
Sl = max(50,(close - low) / pipsize)
// dax 55 minuti 10000 unità 84.14% max perdita 250€ max guadagno 750 (46 win a0 loss)
Tp = Sl * 3
ENDIF
IF Bullish AND HigherHIGHs AND Not OnMarket AND MyRsi < 70 THEN
SELLSHORT 1 CONTRACT AT MARKET
Sl = max(50,(high - close) / pipsize)
Tp = Sl * 3
ENDIF
SET STOP pLOSS Sl
SET TARGET pPROFIT Tp
//trailing stop
trailingstop = 24
//resetting variables when no trades are on market
if not onmarket then
MAXPRICE = 0
MINPRICE = close
priceexit = 0
endif
//case SHORT order
if shortonmarket then
MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
endif
endif
//case LONG order
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
endif
endif
//exit on trailing stop price levels
if onmarket and priceexit>0 then
EXITSHORT AT priceexit STOP
SELL AT priceexit STOP
endif