Signal doesn't respect the time conditions to enter a trade

Questions about MultiCharts and user contributed studies.
dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

Signal doesn't respect the time conditions to enter a trade

Postby dvdkite » 08 Sep 2021

Hello Everyone,

I have a system that I actually use since months in real automated trading but very rarely it enter a trade before the time indicated in the time conditions.
My strategy works over a 3 minutes charts and is must enter a trade ONLY between 9:03 and 11:00 of the morning.
So basically I've done a simple code like this :

Code: Select all

//Time frame of the day where entries are allowed isTheRightTime = ( time >= Time_MorningStart_at and time <= Time_MorningStop_at) or ( time >= Time_AfternoonStart_at and time <= Time_AfternoonStop_at);
I'm using Time_MorningStart_at = 903 and Time_MorningStop_at = 1100.

My trading system has to start checking bars from 9:00 and the early trade possible is exactly at the close of the first 3 minutes candle after the opening european bell that is at 9:00 gmt. As i said I need that the first candle is closed so I set the Time_MorningStart_at = 903.

Ok so doing that 99% of times work correctly but I have experienced some STOPLOSS due some early enters made between the 9:00 and 9:03... this mean that the system checked the 3 minutes bar between the 8:57 and 9:00 and then found the conditions to enter a trade, so at the opening of the following bar ( 9:00 - 9:03) it entered the trade ( WRONGLY BECAUSE it has only to start trading AFTER the first 3 minute bar starting from 9:00 indeed it should only allow trading some milliseconds after 9:03).

So How can I solve this? If you think that It would be enough to set the start at 9:06 that's not working and it miss a LOT of trades).

Any help is appreciated.
Thanks

David

tpredictor
Posts: 108
Joined: 05 Mar 2014
Has thanked: 1 time
Been thanked: 12 times

Re: Signal doesn't respect the time conditions to enter a trade

Postby tpredictor » 08 Sep 2021

Does the afternoon portion work? Have you tried removing that to see if it works? Here's some code from George Pruitt. It looks like Time refers to bar end time. It looks like your other option is to check local computer time. The second link shows how to use the local computer time with CurrrentTIme. You could add it as an extra conditional check for live trading only and be sure to synchronize your clock.

http://georgepruitt.com/working-around- ... ylanguage/

https://www.tradingcode.net/multicharts ... me-period/


Return to “MultiCharts”