How to Pause strategy when win X% or loss X% on weekly and monthly.
Pause to Next week the weekly strategy.
AndPause to Next month the montly strategy.
Much thanks!!!
// Monthly strategy
//
DEFPARAM CumulateOrders = false
ONCE TradeON = 1
ONCE WinLoss = 10
ONCE Capital = 10000
ONCE PrevEquity = Capital
CurrEquity = Capital + StrategyProfit
IF Month <> Month[1] THEN
TradeON = 1
PrevEquity = CurrEquity
ENDIF
TempProfit = (CurrEquity - PrevEquity) * 100 / PrevEquity
IF abs(TempProfit) >= WinLoss THEN
TradeON = 0
ENDIF
IF close crosses over average[100] and TradeON then
buy at market
set target pprofit 200
set stop ploss 200
endif
if close crosses under average[100] and longonmarket then
sell at market
endif
// Weekly strategy
//
DEFPARAM CumulateOrders = false
ONCE TradeON = 1
ONCE WinLoss = 10
ONCE Capital = 10000
ONCE PrevEquity = Capital
CurrEquity = Capital + StrategyProfit
IF DayOfWeek < DayOfWeek[1] THEN
TradeON = 1
PrevEquity = CurrEquity
ENDIF
TempProfit = (CurrEquity - PrevEquity) * 100 / PrevEquity
IF abs(TempProfit) >= WinLoss THEN
TradeON = 0
ENDIF
IF close crosses over average[100] and TradeON then
buy at market
set target pprofit 200
set stop ploss 200
endif
if close crosses under average[100] and longonmarket then
sell at market
endif
You can change the % (WinLoss) and the starting Capital as suits you best.
Ok Roberto, i see.
But, win X% and loss X% are independents.
For example:
win 5% or loss 2%
You wrote win X% or loss X%.
I’ll change it soon.
There you go:
// Monthly strategy
//
DEFPARAM CumulateOrders = false
ONCE TradeON = 1
ONCE PerCentLoss = 3
ONCE PerCentWin = 5
ONCE Capital = 10000
ONCE PrevEquity = Capital
CurrEquity = Capital + StrategyProfit
IF Month <> Month[1] THEN
TradeON = 1
PrevEquity = CurrEquity
ENDIF
TempProfit = (CurrEquity - PrevEquity) * 100 / PrevEquity
IF (TempProfit <> 0) AND ((TempProfit >= PerCentWin) OR (TempProfit <= PerCentLoss)) THEN
TradeON = 0
ENDIF
IF close crosses over average[100] and TradeON = 1 then
buy 1 contract at market
set target pprofit 200
set stop ploss 200
endif
if close crosses under average[100] and longonmarket then
sell at market
endif
// Weekly strategy
//
DEFPARAM CumulateOrders = false
ONCE TradeON = 1
ONCE PerCentLoss = 2
ONCE PerCentWin = 6
ONCE Capital = 10000
ONCE PrevEquity = Capital
CurrEquity = Capital + StrategyProfit
IF DayOfWeek < DayOfWeek[1] THEN
TradeON = 1
PrevEquity = CurrEquity
ENDIF
TempProfit = (CurrEquity - PrevEquity) * 100 / PrevEquity
IF (TempProfit <> 0) AND ((TempProfit >= PerCentWin) OR (TempProfit <= PerCentLoss)) THEN
TradeON = 0
ENDIF
IF close crosses over average[100] and TradeON = 1 then
buy at market
set target pprofit 200
set stop ploss 200
endif
if close crosses under average[100] and longonmarket then
sell at market
endif
At line 5 use a negative PerCentage, -2 or -5, or anything else.