DEFPARAM CumulateOrders = false // Cumulating positions deactivated
//dynamic position sizing
INITIALCAPITAL = 10000
c = (INITIALCAPITAL/close)
if c < 0.2 then
c = 0.2
endif
// Conditions to enter long positions
IF NOT onmarket then
StrategyID = 0
ENDIF
//trend following strategy
IF (StrategyID = 0) OR (StrategyID = 1) THEN
indicator1 = SAR[0.14,0.01,0.3]
c1 = (close > indicator1)
indicator2 = RSI[14](close)
c2 = (indicator2 < 80)
c3 = (close >= open)
indicator3 = AroonUp[10]
c4 = (indicator3 > 15)
indicator4 = CALL "ATR"[14,2]
c5 = (close > indicator4)
IF c1 AND c2 AND c3 AND c4 AND c5 AND Not OnMarket THEN
StrategyID = 1
set stop $loss 420
BUY c PERPOINT AT MARKET
ENDIF
indicator5 = SAR[0.14,0.01,0.3]
c6 = (indicator5 > close)
indicator6 = RSI[14](close)
c7 = (indicator6 > 80)
IF c6 OR c7 THEN
SELL AT MARKET
ENDIF
ENDIF
//mean reversion strategy
IF (StrategyID = 0) OR (StrategyID = 2) THEN
indicator4 = CALL "ATR"[14,2,1]
c8 = (close < indicator4)
indicator7 = RSI[14](close)
c9 = (indicator7 < 30)
IF c8 and c9 AND not onmarket THEN
StrategyID = 2
BUY c PERPOINT AT MARKET
ENDIF
c10= (indicator7 > 50)
IF c10 THEN
SELL AT MARKET
ENDIF
ENDIF
graph StrategyID