X Max trade per day
Forums › ProRealTime English forum › ProOrder support › X Max trade per day
- This topic has 4 replies, 3 voices, and was last updated 1 year ago by Inertia.
-
-
10/13/2023 at 8:52 AM #222386
Hello All !
Hope you are doing well 😉
1 – May I kindly ask for a snippet of code that would allow an auto strategy being triggered X MAX num of time per Day ?
2 – Is there another snippet of code that will let the strategy keeping on being triggered until X Pts per day are achieved?
Example > I am looking for a gain of 10 pts per day. First trigger, loss of -30 pts. I need 40 pips to achieve my daily goal (forget about the fees). Best scenario, 4 wins in a row THEN the strategy will stop for the day.
BIG THANKS
10/13/2023 at 9:30 AM #2223901/ numerous topics for that:
Max profit and loss each day in a trading strategy
https://www.prorealcode.com/topic/1-gain-par-jour/#post-74368
https://www.prorealcode.com/topic/1-position-par-jour/#post-46788
https://www.prorealcode.com/topic/how-to-operate-just-once-in-a-day/
https://www.prorealcode.com/topic/quick-question-one-order-per-day/
https://www.prorealcode.com/topic/limiting-accumulating-orders-fuse/#post-25833
https://www.prorealcode.com/topic/limite-le-trading-automatique-a-un-ordre-journalier/
https://www.prorealcode.com/topic/max-number-of-trades-in-a-period/#post-176779
…
2/ code for Daily max loss/profit in points/pips:
123456789101112131415161718MaxProfit = 50 //max daily profit objective in pipsMaxLoss = 40 //max daily loss in pips//max profit/loss achievedif day<>day[1] thenstrategyprofitpoint=0 //daily resetendifif(strategyprofit<>strategyprofit[1]) thenpnl = strategyprofit-strategyprofit[1]size = max(startContract,abs(countofposition[1]))onepos = pnl/sizepointprofit = onepos/pointvaluestrategyprofitpoint = strategyprofitpoint+pointprofitendifallowtrading=1if (strategyprofitpoint>=MaxProfit or strategyprofitpoint<=-MaxLoss) thenallowtrading=0endif1 user thanked author for this post.
10/13/2023 at 7:10 PM #222402X max trade per day (Max 2)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748//-------------------------------------------------------------------------// Main code : NSDQ Clo W Pré OCTOBRE 13//-------------------------------------------------------------------------// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedDEFPARAM FLATBEFORE = 070000DEFPARAM FLATAFTER = 213000maxorders = 2 //max orders per day//reset the count of orders each dayif intradaybarindex=0 thencount = 0endif//counting ordersif onmarket and lastindex<>tradeindex thencount=count+1lastindex=tradeindexendiftrailingstop = 6// Previous 25if not onmarket thenMAXPRICE = 0priceexit = 0endifif longonmarket thenMAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current tradeif MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price levelendifendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenSELL AT priceexit STOPendif// Conditions to enter long positionsc1 = (low CROSSES UNDER 15112)IF NOT LONGONMARKET AND c1 THENbuy 1 SHARES AT MARKETENDIFSET STOP %LOSS 0.2SET TARGET %PROFIT 0.07Hello !
This strategy keep buying indefinitely … I thought the code would have stopped after the second trade…
Where is my mistakeplease??
THANK YOU 😉
10/14/2023 at 4:37 PM #222456You added variable maxorders, but you never used it to enter trades, so it is useless. In addition count wasn’t correctly updated and wasn’t used either.
I added maxpips to set a daily target, after which trading is disabled:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950DEFPARAM CumulateOrders = False // Cumulating positions deactivatedDEFPARAM FLATBEFORE = 070000DEFPARAM FLATAFTER = 213000ONCE maxorders = 2 //max orders per dayONCE maxpips = 10 //max daily gain (in pips)ONCE count = 0ONCE pips = 0ONCE myProfit = 0//reset the count of orders each dayif intradaybarindex=0 thencount = 0pips = 0myProfit = StrategyProfitendif//counting orders//if onmarket and lastindex<>tradeindex then//count=count+1//lastindex=tradeindex//endifIF StrategyProfit <> StrategyProfit[1] THENpips = pips + ((StrategyProfit - myProfit) / Pipvalue)IF pips >= maxpips THENcount = maxorders + 1 //disable trtading after reaching maxpips gainENDIFENDIFtrailingstop = 6// Previous 25if not onmarket thenMAXPRICE = 0priceexit = 0endifif longonmarket thenMAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current tradeif MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price levelendifendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenSELL AT priceexit STOPendif// Conditions to enter long positionsc1 = (low CROSSES UNDER 15112)IF NOT LONGONMARKET AND c1 AND count < maxorders THENbuy 1 SHARES AT MARKETcount=count+1ENDIFSET STOP %LOSS 0.2SET TARGET %PROFIT 0.071 user thanked author for this post.
10/14/2023 at 4:48 PM #222459THANK YOU very much Roberto ! I keep this one safe.
Have a nice week-end.
Damien
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on