Hi all,
I am working on a code that work from Monday to Friday. I will open on Monday and will close on Friday unless the code reach x profit or y losses.
To modify the strategyprofit for just one day, Roberto showed a nice piece of code that I have just changed to a weekly strategy profit. I just wanted to have confirmation that it is correct.
// STRATEGYPROFIT per WEEK. It resets the variable each new week
IF dayofweek=1 AND INTRADAYBARINDEX = 0 THEN
stratprofit = STRATEGYPROFIT //saves the previous week Profit
nomoretrading = 0
ENDIF
//Finishing WEEKLY operations when reaching target profit/loss
IF (STRATEGYPROFIT-stratprofit)>=100 THEN //current week's profit
SELL AT MARKET
EXITSHORT AT MARKET
nomoretrading=1
ENDIF
IF (STRATEGYPROFIT-stratprofit)<=-100 THEN //current week's loss
SELL AT MARKET
EXITSHORT AT MARKET
nomoretrading=1
ENDIF
Thanks,
Juan
The logic is fine, in case line 2 doesn’t work as expected try
IF Opendayofweek=1 AND INTRADAYBARINDEX = 0 THEN
You only have to demo it!
Hi Roberto,
Thanks again. I will try your option in case does not work.
Regards,
Juan