Coding required – Trade on specific day only via parameter
Forums › ProRealTime English forum › ProOrder support › Coding required – Trade on specific day only via parameter
- This topic has 24 replies, 4 voices, and was last updated 1 month ago by
OggyFluff77.
-
-
01/31/2025 at 6:52 PM #243292
hi,
that’s great – many thanks for coming back to me. my coding is very basic so i will need time to test this but really appreciate you sending over the code.
regards
02/04/2025 at 6:25 PM #243456HI Roberto,
ok, the array tables have been a game changer for me and work perfectly and I now have all 5 trading days with different parameters all working – so a massive thank you.
in addition, I have managed to get the code working for opening a trade from a specific time for a specific day (using the ‘TimeRef = OpenTime’), so again – thank you, but I can not manage to get a trade to close at a certain time for a specific day.
I do have a ‘DefParam FlatAfter’ that works very well in the main code but that closes trades at that one specific time for every day and I still would like the ability to close trades on different days at different times.
I have tried all the suggestions above but none seem to work – anymore suggestions?
thanks in advance
02/04/2025 at 7:25 PM #243457I only can suggest what I posted at https://www.prorealcode.com/topic/coding-required-trade-on-specific-day-only-via-parameter/#post-242966.
I can’t understand whythe version to open a trade works fine, while the verskion to close a trade doesn’t. What’s different between the two cases?
02/05/2025 at 5:28 AM #243468Hi Roberto, hello Oggy,
The difference will be that no code was provided for the task of closing :
So Oggy, you must copy the snippet as provided by Roberto in that post, change all the TimeRef references in that snippet o TimeRefClose, change all the tdx variables to tdClosex variables, make a tdCondClose variable for it (instead of tdCond) and use that as the condition for closing.
Make the time span for closing small, like a startT of 204500 and endT of 210000 (a 15 minute time span).Does that help ?
Peter02/05/2025 at 8:57 AM #243472many thanks Roberto and Peter for coming back to me,
i will try and resolve using the new suggestions, thank you, and revert but my coding is very basic so i may have to ask for the actual code as i can probably amend to make it work but not overly confident i can write it from scratch.
thanks
02/05/2025 at 10:46 AM #243473ok so the change to close does not work at the moment but i am possibly/probably doing something wrong.
I am no expert but could it be that the opening time of a trade has a reference in PRT which makes it easy to define –
ie. TimeRef = OpenTime ( I assume in PRT code language that OpenTime does exactly what it says on the tin)
so I think the closing of a trade doesn’t work because I can’t find a PRT definable reference for Closing a trade
so I feel like I need specific parameter code for both Open – as previous – and then additional code for closing a trade at a certain time
does that make sense?
or am I barking up the wrong tree?
thanks in advance
02/05/2025 at 12:04 PM #243476This example works like a charm:
123456789101112131415161718192021222324252627282930313233343536373839404142434445////////////////////////////////////////////////////////////////////////////////////////////////////////////ONCE startT = 090000 //from 090000ONCE endT = 180000 //to 180000TimeRef = OpenTimeDayRef = OpenDayOfWeek//td0 = 0 AND DayRef = 0 AND TimeRef >= startT AND TimeRef <= endT //Suntd1 = 1 AND DayRef = 1 AND TimeRef >= startT AND TimeRef <= endT //Montd2 = 1 AND DayRef = 2 AND TimeRef >= 110000 AND TimeRef <= 160000 //Tue EXCEPTIONtd3 = 1 AND DayRef = 3 AND TimeRef >= startT AND TimeRef <= endT //Wedtd4 = 1 AND DayRef = 4 AND TimeRef >= 093000 AND TimeRef <= 130000 //Thu EXCEPTIONtd5 = 1 AND DayRef = 5 AND TimeRef >= startT AND TimeRef <= endT //Fritd6 = 0 AND DayRef = 6 AND TimeRef >= startT AND TimeRef <= endT //SattdCond = td0 OR td1 OR td2 OR td3 OR td4 OR td5 OR td6////////////////////////////////////////////////////////////////////////////////////////////////////////////ONCE ClosingTime = 200000 //200000TimeRef = OpenTimeDayRef = OpenDayOfWeek//tc0 = 0 AND DayRef = 0 AND TimeRef = ClosingTime //Suntc1 = 1 AND DayRef = 1 AND TimeRef = ClosingTime //Montc2 = 1 AND DayRef = 2 AND TimeRef = ClosingTime //Tuetc3 = 1 AND DayRef = 3 AND TimeRef = ClosingTime //Wedtc4 = 1 AND DayRef = 4 AND TimeRef = ClosingTime //Thutc5 = 1 AND DayRef = 5 AND TimeRef = 150000 //Fri EXCEPTIONtc6 = 0 AND DayRef = 6 AND TimeRef = ClosingTime //SattcCond = tc0 OR tc1 OR tc2 OR tc3 OR tc4 OR tc5 OR tc6//////////////////////////////////////////////////////////////////////////////////////////////////////////////Sma20 = average[20,0](close)// EntryIF close CROSSES OVER Sma20 AND Not OnMarket AND tdCond THENBUY AT highest[3](high) STOPELSIF close CROSSES UNDER Sma20 AND Not OnMarket AND tdCond THENSELLSHORT AT lowest[3](low) STOPENDIF//// ExitIF OnMarket AND tcCond THENSELL AT MarketEXITSHORT AT MarketENDIF// TP & SLset stop %loss 0.3set target %profit 0.602/05/2025 at 2:55 PM #243486Hi Roberto,
thanks for that code, appreciated as always, but that doesn’t work for me unfortunately. I tried manipulating it for my code and that didn’t work and then i tried copying the whole code into a blank workspace and that didn’t work either.
taking a step back, i have 2 issues;
- the opening of a trade works using a from time but not within a range such as:
- example “td2 = 1 AND DayRef = 2 AND TimeRef >= 110000 AND TimeRef <= 160000 //Tue EXCEPTION” – it opens a trade using the first TimeRef , ie after 110000, but ignores the second TimeRef – therefore continuing to put trades on all day.
- I would like specific code to close a trade at a certain time per day.
any other advice or suggestions?
Thanks in advance
02/10/2025 at 10:12 PM #243716Post the code you are using, specifying:
- the timeframe used
- the instrument or asset traded
- date and time of a trade enterd or exited incorrectly.
If you are using my code, just tell me, but post your version in case you modified it even slightly.
02/13/2025 at 5:53 PM #243790Hi Roberto,
thank you for all your help – your code worked, I had implemented it incorrectly. I have now fixed it.
thank you so much for all your help, and patience.
regards
1 user thanked author for this post.
- the opening of a trade works using a from time but not within a range such as:
-
AuthorPosts
Find exclusive trading pro-tools on