DEFPARAM CumulateOrders = FALSE
Capital = 5000 //initial Capital
Equity = Capital + StrategyProfit //current Equity
PerCent = 2 //1% risk
RiskSize = (Equity * PerCent / 100) //max. Money at risk
MinSize = 0.5 //0.5 lots minimum
//
IF Not OnMarket THEN
SL = 0
ENDIF
//
indicator1 = ExponentialAverage[17](close)
c1 = (close > indicator1)
indicator2 = MACDline[12,26,9](close)
c2 = (indicator2 < 0.1)
indicator3 = MACDline[12,26,9](close)
indicator4 = MACDSignal[12,26,9](close)
c3 = (indicator3 CROSSES OVER indicator4)
//
IF not longonmarket and c1 AND c2 AND c3 THEN
X = (AverageTrueRange[10](close))*3 //X = SL
PositionSize = max(MinSize,RiskSize / X) //Compute PositionSize, no less than MinSize
BUY PositionSize SHARES AT MARKET
ENDIF
//
SET STOP LOSS x
SET TARGET PROFIT x * 3
//
IF LongOnMarket AND (close - PositionPrice) >= (x * 2) AND SL = 0 Then
SL = PositionPrice
Endif
IF SL > 0 THEN
Sell at PositionPrice STOP
ENDIF
graphonprice PositionPrice
graphonprice PositionPrice - X coloured(255,0,0,255) AS "SL"
graphonprice PositionPrice + (X*3) coloured(0,128,0,200) AS "TP"
graphonprice PositionPrice + (X*2) coloured(0,0,255,255) AS "BreakEven Trigger"