EXIT ON WEEKEND
Forums › ProRealTime English forum › ProOrder support › EXIT ON WEEKEND
- This topic has 14 replies, 3 voices, and was last updated 2 years ago by robertogozzi.
-
-
03/09/2017 at 6:05 PM #27961
I am trying to add the code necessary to exit all my trades at the end of Friday. I thought it would be easy but I can´t make it work. This is what I tried…
1234IF ONMARKET AND CURRENTDAYOFWEEK = 5 AND CURRENTTIME = 230000 THENSELL AT MARKETEXITSHORT AT MARKETENDIFI´ve been trying to find it in the forum but no way
Some help please.
Thanks in advance03/09/2017 at 8:35 PM #27992You almost had it right.
12345if opendayofweek = 5 and openhour >= 22 and openminute >= 55 thensig=1elsesig=0endifThe currenttimeof… constants cause PRT to act one bar later. Using opentimeof… fixes this.
3 users thanked author for this post.
10/04/2017 at 2:32 PM #4819510/04/2017 at 2:34 PM #48196You can implement it like this:
EXIT FOR THE WEEK END12345678910if opendayofweek = 5 and openhour >= 22 and openminute >= 55 thensig=1elsesig=0endifIF sig=1 THENSELL AT MARKETEXITSHORT AT MARKETENDIF1 user thanked author for this post.
07/31/2021 at 6:41 AM #174415Thanks this is very helpful. Being in Australia the IG markets are closed on our weekends eg from say Sat at 6am our time. I can certainly use the above to exit before close and ill make sure im set in my own time zone.
What about a way of not entering trades unless a market is open?
I could set something like the above to only enter IF market meets time positions – is that the best way? Or is it even necessary? I wonder what my algos do when the market is closed here? Are they still watching the data and not being able to trade? any ideas?
07/31/2021 at 9:07 AM #174419It’s impossible to trade when the market is closed, so there’s no way to do what is already being done.
07/31/2021 at 9:30 AM #17442607/31/2021 at 9:34 AM #174427Can you post an example?
07/31/2021 at 10:36 AM #17443707/31/2021 at 10:59 AM #174439That makes sense, there you go:
1234TradingHours = (time >= 090000) AND (time <= 170000) //you may replace TIME with OPENTIME, if you preferIF MyLongConditions AND TradingHours THENBUY AT MarketENDIF1 user thanked author for this post.
08/01/2021 at 9:31 AM #174481thank you for this topic. can you bring the piece of code that says “if the trade is positive” (we only come out if the trade is winning) + resuming the strategy on Monday according to open defined by everyone of course.
08/01/2021 at 10:04 AM #174485Well, I remember having read a similar question months ago, but I can’t find it.
It can easily be done, but you will have to pay spread as any new trade.
To recap, you want to close a profitable trade on Friday night at 22:00 (or any time of your choice), then it must be reopened on Monday (on the first Monday bar or at a time?) no matter conditions as if it were the same trade that had been closed?
08/01/2021 at 10:35 AM #174487Hi Roberto, thank U
It can easily be done, but you will have to pay spread as any new trade. yes sure
To recap, you want to close a profitable trade on Friday night at 22:00 (or any time of your choice), yes exact. no more trading after this close of course.
then it must be reopened on Monday (on the first Monday bar or at a time?) reopening on Monday according to the general conditions listed in the strategy
no matter conditions as if it were the same trade that had been closed? no forget the past, only trading according to the general conditions listed in the strategy
hope is clear, thanks again.
08/01/2021 at 11:18 AM #174489So, it’s just a matter of closing a profitable trade on Friday Night. There you go:
1234IF OnMarket AND PositionPerf > 0 AND OpenDayOfWeek = 5 AND OpenTime >= 220000 THENEXITSHORT AT MarketSELL AT MarketENDIF1 user thanked author for this post.
08/01/2021 at 11:26 AM #174491The above snippet will close any open trade, but it won’t prevent orther trades from being opened beyond that date. You need to use another snippet, like this one:
1234NoTradeHours = (OpenDayOfWeek = 5 AND OpenTime >= 210000)IF MyLongConditions AND Not NoTradeHours THENBUY AT MarketENDIFthis will prevent your strategy from entering new trades after 21:00 on Friday night.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on