DEFPARAM CumulateOrders = false
//
timeframe(1 day,updateonclose)
CondL = close > average[200] AND average[10] CROSSES OVER average[20]
CondS = close < average[200] AND average[10] CROSSES UNDER average[20]
//
timeframe(default)
If not OnMarket then
NewStop = 0
Endif
If not OnMarket then //do not change while at market
StopLossL = lowest [5](low) * 0.99 //-1%
StopLossS = highest [5](low) * 1.01 //+1%
Endif
IF LongOnMarket THEN
MyProfit = TradePrice * 1.10 //+10%
Result = TradePrice * (1 + PositionPerf)
ELSIF ShortOnMarket THEN
MyProfit = TradePrice * 0.90 //-10%
Result = TradePrice * (1 - PositionPerf)
ENDIF
If NewStop <> 0 Then
IF LongOnMarket THEN
MyProfit = NewStop * 1.02 //2% trailing stop
If close >= MyProfit Then
NewStop= MyProfit
Endif
ELSIF ShortOnMarket THEN
MyProfit = NewStop * 0.98 //2% trailing stop
If close <= MyProfit Then
NewStop= MyProfit
Endif
ENDIF
Endif
If NewStop = 0 THEN
IF LongOnMarket and Result >= MyProfit Then
NewStop = TradePrice
ELSIF ShortOnMarket and Result <= MyProfit Then
NewStop = TradePrice
ENDIF
Endif
If CondL and Not OnMarket then
Buy 1 contract at Market
Sell at StopLossL STOP
Endif
If CondS and Not OnMarket then
SellShort 1 contract at Market
ExitShort at StopLossS STOP
Endif
If OnMarket then
Sell at max(StopLossL,NewStop) STOP
ExitShort at min(StopLossS,NewStop) STOP
Endif
SET TARGET pPROFIT 50