This automated trading strategy was posted by Nicolas 1 year ago for long side trade as example, starting from this example I’ve added short side, Trailing stop, and Donchian stop.
Below you will find link of the original version: “Cumulative RSI 2 periods strategy”.
The following variables can be optimized and adapted to volatily and time frame
Trailing Stop : TGL and TGS
Stop loss by Donchian channel: DC
Moving Average: AVG to open position above or below it
Period of cumulative summ of the RSI indicator value “CUMRSI”
Positions are opens at indicator value set, called “CUMRSI” , this could be optimized and adapted to volatily and time frame (Ex:IF Close>AVG AND CUMRSI<35 THEN BUY…)
The concept of the strategy it’s universal, and It could work for equity/indices/currencies.
This strategy could be used with cumulative order for long side. Below the result in the red graphic equity.
https://www.prorealcode.com/prorealtime-trading-strategies/cumulative-rsi-2-periods-strategy/
//CSR strategy cumulative 2 periods
//Author Nicolas 2016 - February
//Optimizator Ale 2017 - May
// cfd DAX 1 Daily
// Spread 5 - 95% of Position open at 010000 am
// Probacktest 10 years Tick by Tick
DEFPARAM CumulateOrders = FALSE // Posizioni cumulate disattivate
//indicator
Period = 2
CUMRSI = SUMMATION[Period](RSI[Period](close))
AVG = average[100](close)
AVGS = average[110](close)
//initial lot
initLOT = 1
//initial lot
initLOT = 1
CUM=COUNTOFLONGSHARES<4
IF Close>AVG AND CUMRSI<35 AND CUM THEN
BUY initLOT CONTRACTS AT MARKET
ENDIF
If LongOnMarket AND CUMRSI>65THEN
SELL AT MARKET
ENDIF
IF NOT SHORTONMARKET AND Close<AVGS AND CUMRSI > 175 THEN
SELLSHORT initLOT CONTRACTS AT MARKET
ENDIF
If SHORTONMARKET AND CUMRSI<120 THEN
EXITSHORT AT MARKET
ENDIF
//TRAILING STOP
TGL=25
TGS=15
if not onmarket then
MAXPRICE = 0
MINPRICE = close
PREZZOUSCITA = 0
ENDIF
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
if MAXPRICE-tradeprice(1)>=TGL*pointsize then
PREZZOUSCITA = MAXPRICE-TGL*pointsize
ENDIF
ENDIF
if shortonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=TGS*pointsize then
PREZZOUSCITA = MINPRICE+TGS*pointsize
ENDIF
ENDIF
if onmarket and PREZZOUSCITA>0 then
EXITSHORT AT PREZZOUSCITA STOP
SELL AT PREZZOUSCITA STOP
ENDIF
// DONCHIAN STOP
once DC =25
IF LONGONMARKET THEN
DC=40
ENDIF
IF SHORTONMARKET THEN
DC=30
ENDIF
e= Highest[DC](high)
f=Lowest[DC](low)
if longonmarket then
laststop = f[1]
endif
if shortonmarket then
laststop = e[1]
endif
if onmarket then
sell at laststop stop
exitshort at laststop stop
endif