Market Close Time
-
Hello
Usually the markets close on Friday about 23:00 depending on the server´s timezone. I would like to close any opened position before that time but as much closer as posible to the market´s closing time. Because my EA trades in high timeframes and it checks the project´s logic at the bar´s opening, I am not able to figure out how to close all opened trades if the bar´s open does not match with my condition.
As an example: TimeFrame == H8 (bar´s open at 0:00, 8:00 & 16:00 each day)
If I set: OncePerBar (H8) -> If DayOfWeek == Friday && HoursFilter == 16:00 - 23:00 -> CloseAll, it Works pretty well.

But what I would like to set is like: OncePerBar (H8) -> If DayOfWeek == Friday && HoursFilter (or Time) == 22:00 - 23:00 -> CloseAll
I tried

I have placed that block's group on the top´s Project to allow the ticks pass through it but it does not work. Block #81 is a "Pass" block.
Any suggestion Will be very welcome.
Thanks
-
Can you tell which block doesn't work? If you put Draw arrow after any block, you can detect whether it worked or not. Also do you have some error messages?
By the way, by default MarketCloseSwitch is set to "false", also try to see if you really changed it to "true", otherwise I don't see how block 79 can be reached.
-
Hi @fxDreema
The blocks work if I set the ClosingMarketTime at Bar´s open.
Let´s say, I want the EA trades in TF == H8. The EA only checks the project´s logic OncePerBar (bar´s open). Then, if I set
WeekDayFilter == Friday && HourFilter == 16:00 - 23:00 (connected to the OncePerBar block)
when the last bar on Friday (H8) opens at 16:00, the EA closes all the positions. This Works pretty well. Because my EA trades in H8, it is not posible to check that condition at any bar´s open after 16:00 because in H8 there is not any bar that opens at 22:00. For this reason, I placed the blocks group without connection to the "Once Per Bar" block and with a "Pass" block on the top to let the ticks do the condition check. But it does not work even though the MarketCloseSwitch is set to "true".
I Will try some more checks and I Will update on this.
Thanks for helping.
-
Hi @fxDreema

That Works if the tester execution is set to "Every tick". I was using "Open prices only" so there was no way to let the EA checks that condition.
Thanks for helping.
-
But in H8 there are 3 candles, one for 00:00, one for 08:00 and one for 16:00. Your "Hours filter" is between 22:00 and 23:00. If Open prices only works on the open prices only, there are only 3 "ticks" for the day - at 00:00, 08:00 and 16:00. No tick comes after 16:00.
-
Hi fxDreema
Yes, you are right and I know that.
What I wanted to say with "...after 16:00 because in H8 there is not any bar that opens at 22:00..." is that there is none bar after 16:00 on Friday in H8.
What I would like to find is a "trick" that allows me to check a condition at 22:00 on Friday in H8 to close the trades at Market Close time but using Once per bar. It works with Every Tick.
Thanks
-
I don't know how can you do that. "Once per bar" is made so that the EA can be backtested quickly, and MetaTrader "feeds" the EA with ticks - 1 per candle - but in H8 there is no candle at that time, and I don't know how can you tell MetaTrader to produce extra tick at 22:00. But why don't you try with another timeframe, maybe this can work somehow?
-
Hi fxDreema
It is just an idea. No worries. I have other options that I tested and it works pretty well even though there are not what I would like.
Thanks