Download MetaTrader 5
To add comments, please log in or register
Your conversation partner speaks foreign language? Automatic translation will help you!
Heiko Kendziorra
9034
Heiko Kendziorra 2014.07.23 18:55 

I thought when sending the order cbt is set to 1 so no second order wil be sent. But on my demo account another order was set within 40 ms, how can this happen, what is wrong in that code?

How can I impeed that in the code?

Thanxx for help!


2014.07.23 18:40:51.796    '9013517': order was opened : #4831827 buy stop 0.40 EURAUD at 1.42480 sl: 1.42280 tp: 1.44770
2014.07.23 18:40:51.753    '9013517': order was opened : #4831826 buy stop 0.40 EURAUD at 1.42480 sl: 1.42280 tp: 1.44770


static int cbt=0;  int res=0;

 
  if(Volume[0]<2) {cbt=0;cst=0;}
 
 
  if(Bid<=prlb&&cbt==0&&prlb!=0)           
               
   {
  res= OrderSend(Symbol(),OP_BUYSTOP,LotAnzahlB(),..., ..);
  cbt++;
  }
Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.07.23 19:27  
highflyer:

I thought when sending the order cbt is set to 1 so no second order wil be sent. But on my demo account another order was set within 40 ms, how can this happen, what is wrong in that code?

How can I impeed that in the code? 

Can't tell from the code you have shown . . .  try printing  Volume[0]

Heiko Kendziorra
9034
Heiko Kendziorra 2014.07.23 21:02  
RaptorUK:

Can't tell from the code you have shown . . .  try printing  Volume[0]


Can't print a this because it doesn't repeat.  The EA runs in 12 pairs and opened dozens of pending orders without doing a order 2 times.  So I thought the logic shown above is right. But then suddenly ...

What should I print?

As EA runs in H4 chart Volume[0] is far higher than 2 ...

Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.07.23 23:04  
highflyer:

Can't print a this because it doesn't repeat.  The EA runs in 12 pairs and opened dozens of pending orders without doing a order 2 times.  So I thought the logic shown above is right. But then suddenly ...

What should I print? 

As EA runs in H4 chart Volume[0] is far higher than 2 ...

Show the code and add a Print() statement just before each and every OrderSend() to print the Volume information . . . then you will actually know if it was > 2 when the Orders were placed.  It's how you debug code in mql4 . . .
Heiko Kendziorra
9034
Heiko Kendziorra 2014.07.24 00:10  

But of course I know, that Volume[0] was > 2 when the Orders were placed.

 In a H4 chart Volume[0] can't be <2 at 18:40h.


Or does Volume[0] jump randomly from number to number instead of counting upward?

Or is it reset to 0 sometimes in the middle of the time of a bar?

Or ist it posible that for transmission problems in internet or inside my server (mt4 runs on a server) Volume[0] isn't transmitted, so shown as 0, so <2 for the EA?


If my way to avoid double orders doesn't work always correct, what else could I write in the code?


Maybe this helps?

if(Volume[0]==1) {cbt=0;cst=0;}


Thanxx!!

whroeder1
13627
whroeder1 2014.07.24 00:24  
highflyer: Maybe this helps?

if(Volume[0]==1) {cbt=0;cst=0;}

Volume is unreliable, you can miss ticks.
Bars is unreliable, max Bars In Chart.
Always use time.
Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.07.24 07:53  
highflyer:

But of course I know, that Volume[0] was > 2 when the Orders were placed.

 In a H4 chart Volume[0] can't be <2 at 18:40h.


Yes it can . . . if for example you are looping within start()  Volume[] will become out of date . . .  but you don't show enough code to see what is going on.  Keep assuming and keep looking at your code . . .
Heiko Kendziorra
9034
Heiko Kendziorra 2014.07.24 19:50  

Thanxs for your comments guys. I'm not a programmer, learning by doing ...

@ WHRoeder: I thought about a solution with time, but isn't time lowest in seconds? Then time can't be a solution when the EA sends the 2. order within the same second.

U're right, it seems the EA is missing ticks. following code showed it, onces was printed 2 instead of 1. This can only happen if the fist tick was missed. Or am I wrong?


@ RaptorUK: Well, my EA is not looping within start(), but maybe for missing data (transmission problem) Volume[0]==0

I think with the code below Volume[0]==0 triggers nothing and the EA must miss the first 5 ticks to not trigger.

Or am I wrong?

Thanks!

static int trig;
           
if (Volume[0]>0&&Volume[0]<6) trig++;
           

 if (Volume[0]>5) trig=0;

 


if(trig==1) 

{

Print (Volume[0]);

cbt=0;

cst=0;

}

          

whroeder1
13627
whroeder1 2014.07.24 20:34  
highflyer:@ WHRoeder: I thought about a solution with time, but isn't time lowest in seconds? Then time can't be a solution when the EA sends the 2. order within the same second.
Resolution of a datetime is one second. The resolution of Time[0] is 60 seconds (M1 chart) and up. Search new bar.
/
To add comments, please log in or register