BelParticipant
New
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// ---parameters
MaxDailyProfit=20 //Max daily profit allowed (in money)
once tradeon=1
// reset the current state of the strateygprofit each new day
If intradaybarindex=0 then
MyProfit=STRATEGYPROFIT
tradeon = 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 then
tradeon = 0
endif
IF tradeon=1 and c1 AND c2 THEN
BUY 1 contract AT MARKET
ENDIF
IF tradeon=1 and c3 AND c4 THEN
SELLSHORT 1 contract AT MARKET
ENDIF
BelParticipant
New
Good evening.
Been studying how to get my intraday system to stop trading after MAX PROFIT/GAIN reached of lets say 20 euros. https://www.prorealcode.com/blog/learning/max-profit-loss-day-trading-strategy/ has it all outlined but somehow I can’t get it to work. Any help would be appreciated.
p.s. sorry for the double post as couldnt type my msg after adding PRT code somehow, live and learn)
Thank you.
Best regards,
Bel.
This version works ok:
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// ---parameters
MaxDailyProfit=100 //Max daily profit allowed (in money)
once tradeon=1
// reset the current state of the strateygprofit each new day
If intradaybarindex=0 then
MyProfit=STRATEGYPROFIT
tradeon = 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 then
tradeon = 0
endif
IF tradeon=1 and rsi[14]crosses over 50 THEN
BUY 1 contract AT MARKET
ENDIF
IF tradeon=1 and rsi[14]crosses under 50 THEN
SELLSHORT 1 contract AT MARKET
ENDIF
//graph strategyprofit
//graph MyProfit+MaxDailyProfit coloured("orange")
//graph tradeon