//————————————————————————-
// Hauptcode : #KISS RSI5 EurUsd M15
//Spread = 1
//————————————————————————-
DEFPARAM CumulateOrders = false
defparam preloadbars = 2000
Nlong = 1
Nshort = 1
MAXSHARES = abs(COUNTOFPOSITION) <= 1
//EMA-Trend
EMA1 = ExponentialAverage[45](close) //50
//EMA2 = ExponentialAverage[ma*1](close)//H1
EMA3 = ExponentialAverage[45](close) //60
EMAlong = close > EMA3
EMAshort = close < EMA3
steigunglong = EMA1 > EMA1[1]
steigungshort = EMA1 < EMA1[1]
myATR = AverageTrueRange[12](close)
//RSI5-Eingang
myRSI = RSI[5](close)
rsilong = (myRSI[1] > 30) and (myRSI < 30)
rsishort = (myRSI[1] < 70) and (myRSI > 70)
rsilongraus = myRSI > 75
rsishortraus = myRSI < 30
IF Time >= 010000 AND Time <= 230000 THEN
IF rsilong and EMAlong and steigunglong and MAXSHARES THEN //and emalongkurz
BUY Nlong shares at market
//SET STOP %LOSS 0.35 //120
//Set target %profit 0.975 //40
SET STOP LOSS myATR*6 //120
Set target profit myATR*7
ENDIF
IF rsishort and EMAshort and steigungshort and MAXSHARES THEN //and emashortkurz
sellshort Nshort shares at market //BollUp[1]limit
//SET STOP %LOSS 0.975 //130
//Set target %profit 0.9 //40
SET STOP LOSS myATR*10 //120
Set target profit myATR*9.25
ENDIF
endif
if longonmarket and rsilongraus then //c2
sell at market
endif
if shortonmarket and rsishortraus then //c1
exitshort at market
endif
//if time = 230000 then //and dayofweek = 5 then
//sell at market
//EXITSHORT at market
//endif
//************************************************************************
//trailing stop function
trailingstartL = 23 //30 15 trailing will start @trailinstart points profit
trailingstartS = 18 //30 15 trailing will start @trailinstart points profit
trailingstepL = 9 //2 1 trailing step to move the “stoploss”
trailingstepS = 2 //2 1 trailing step to move the “stoploss”
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close–tradeprice(1)>=trailingstartL*pipsize THEN
newSL = tradeprice(1)+trailingstepL*pipsize
ENDIF
//next moves
IF newSL>0 AND close–newSL>=trailingstepL*pipsize THEN
newSL = newSL+trailingstepL*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)–close>=trailingstartS*pipsize THEN
newSL = tradeprice(1)–trailingstepS*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL–close>=trailingstepS*pipsize THEN
newSL = newSL–trailingstepS*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF