Reply

Order executed in the middle of the bar and not at the beginning or at the end of the bar after restarting MT4…

5 replies

Karish

Customer, bbp_participant, community, sq-ultimate, 443 replies.

Visit profile

7 years ago #115240

HIi, i got a problem..

 

The EA is working fine by the rules and opens and close orders on bar open/close,

but when lets say i restart my MT4 platform when it opens again and the rules are met, it will open an order immediately at the middle of the bar without waiting for a new formatted bar..

 

how do i stop it for happening please?, i want the EA to wait for a new formatted bar and then enter the order (like it should) and not on the first tick when restarting the MT4 platform or so..

 

thanks..

0

Karish

Customer, bbp_participant, community, sq-ultimate, 443 replies.

Visit profile

7 years ago #137719

@Mark @Thomas ?..,

 

that happens to me when i’m using offline charts.., maybe something to do with “sqIsBarOpen”  under the “drawStats()” function?…, please help ASAP…, because when i’m im reopening MT4 platform with an EA that works on OFFLINE charts it will just open a new position as soon as the first tick comes in, and wont wait till the new bar opens….,

 

waiting for some help…!, thank you!…

0

Karish

Customer, bbp_participant, community, sq-ultimate, 443 replies.

Visit profile

7 years ago #137740

Anybody………….?

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

7 years ago #137759

hello,

 

it seems to me that EA/chart load event causes isBarOpen to be true within DrawStats function. That is why the action is triggered. I will ask Mark to check it

0

Karish

Customer, bbp_participant, community, sq-ultimate, 443 replies.

Visit profile

7 years ago #137775

hello,

 

it seems to me that EA/chart load event causes isBarOpen to be true within DrawStats function. That is why the action is triggered. I will ask Mark to check it

Thanks thomas, i would love to hear how can i fix that issue ASAP please..!\

thanks again i will wait for an answer..!

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

7 years ago #137989

Karish, I looked at it and yes, this is how it works. When you start your EA in the middle of the bar it can open the order immediately, it doesn’t wait for start of a new bar.

 

The recognition of new bar open checks if it is a first tick of the current bar, which it is when you just started EA in the middle of the bar.

 

It is actually quite difficult to make it work only for the new open bars and not for the first bar you start your EA with.

 

It should possible by changing the MQL code a little – find a function drawStats() where the variable sqIsBarOpen is set.

 

Change the condition like this:

 

   if(tmp != Time[0] && Volume[0] < 5 ) {}
      tmp =  Time[0];
      open = Open[0];
      sqIsBarOpen = true;
   } else {
      sqIsBarOpen = false;
   }
 
This will check that also volume of the checked tick must be smaller than 5, so it should filter our the cases when it is checked in the middle of bar.
Please test it before you’ll use it.

Mark
StrategyQuant architect

0

Viewing 5 replies - 1 through 5 (of 5 total)