How can I freeze running strategies?
Forums › ProRealTime English forum › ProOrder support › How can I freeze running strategies?
- This topic has 10 replies, 4 voices, and was last updated 8 years ago by robertogozzi.
-
-
06/09/2016 at 2:47 PM #9119
A few minutes (or hours, according to the timeframe involved) before certain news I would like to freeze a running strategy without interrupting it and without closing open trades.
I haven’t found instructions on how to manage that issue, so I decided to wrote a simple strategy than opens a trade each 1-minute-bar, continuosly (of course it is just for demo accounts so I don’t care whether it loses or gains) and, each bar, it CALLs a custom indicator (named FreezeStrategy) that simply returns 0 or 1.
If it returns 0 my strategy just operates normally and continuosly opens and closes trades. If it returns 1 it STOPs opening new trades.
My idea was to modify the Indicator a few minutes before the news (say 14:20 UTC+2 for NFP) so that it returns 1 and my strategy freezes. When I want my strategy to resume operating I should just modify it (and validate the code each time) so that it returns 0 again.
It seems fine, but it DOES NOT work!!! I guess ProOrder doesn’t actually CALL the indicator at each bar, but it CALLs it only when the strategy is started, so any change I may make to the code, the strategy is not affected.
Is there any way to FORCE the strategy to CALL the indicator at each bar?
Thank you for your help.
————————————————————————————————————————–
Indicator (FreezeStrategy):
RETURN 0 // 1 to freeze my strategy
<hr />
My strategy:
DEFPARAM CumulateOrders = False
IF LONGONMARKET THEN
SELL AT MARKET // close any open trade, no matter if shows a profit or loss
ENDIF
Inactive = CALL FreezeStrategy
IF( close <= close[1]) OR (close > close[1]) THEN // open a trade no matter what
IF Inactive = 0 THEN
BUY 1 CONTRACT AT MARKET // LONG trades just as an example
ENDIF
ENDIF
SET STOP PLOSS 2
SET TARGET PPROFIT 206/09/2016 at 4:44 PM #912006/09/2016 at 5:31 PM #9121The code is above, just 1 line:
RETURN 0 // 1 to freeze my strategy
I don’t know if there is a minum requirement as to lines, do they require more than 1 line?
As to your code, if you embed dates in your code you have to adjust them everyday or even more than once a day, thus interrupting the strategy.
Maybe there is a way I haven’t read of so far!
06/09/2016 at 5:58 PM #912406/09/2016 at 6:34 PM #912506/09/2016 at 9:31 PM #914406/09/2016 at 11:04 PM #9153The options just let me keep trades open, not pause and then resume my strategy.
Setting as many dates and times in a strategy for, say, 2-3 months would imply several pages of code to evaluate each of them at each bar!
I could temporarily solve the problem stopping the Auto Trade, but this will clear all statistics. Till I find a better solution I’ll use this one. Thanks.
06/10/2016 at 12:23 AM #915606/10/2016 at 12:59 AM #9157That would be fine once for specific news. At each crucial news I should recode it and replace the running one, which could be required once in a week or maybe twice in a day, depending on how many news are scheduled and when…
I am looking for a piece of code to pause and resume a strategy without having to change the code and stop it, so that I could pause it at 10:25, resume it at 10:40. then pause it again at 14:20, then resume it again at 15:00 today and maybe at 11:00 or 16:30 Tomorrow or next monday.
There are tens of important news each month and I would like a strategy to be fully operating without having to change the code each time.
In my opinion just having to set 0 or 1 in an indicator would be great. I would have to change just one line of code as many times a day as I want without stopping the strategy and clearing statistics.
A better solution would be if Auto Trade had another button “Pause/Resume”, you click it and the strategy would pause without starting new trades, just keeping an eye on pending orders and running trades in case a previously programmed action is required.
Thank you Adolfo.
06/10/2016 at 9:23 AM #918506/10/2016 at 1:26 PM #9200I hope so as well. Thanks Adolfo.
-
AuthorPosts
Find exclusive trading pro-tools on