Resetting each day the daily target profit and maximum allowed loss.
This code snippet that can be added to any trading strategy.
// ---parameters
MaxDailyProfit=1000 //Max daily profit allowed (in money)
MaxDailyLoss=1000 //Max daily loss allowed (in money)
// first time we launch the code, the trading is allowed
once TradeAllowed=1
// reset the current state of the strateygprofit each new day
If intradaybarindex=0 then
MyProfit=STRATEGYPROFIT
TradeAllowed=1
endif
// test if the strategyprofit of the day is currently above the daily profit allowed of below the daily loss allowed
If StrategyProfit>=MyProfit+MaxDailyProfit or Strategyprofit<=MyProfit-MaxDailyLoss then
TradeAllowed=0
endif
// initiate a new BUY order
if TradeAllowed=1 and buyconditions then
buy 1 lot at market
endif