Trading at specified time with OnTimer problem - page 3

 
Fernando Carreiro:

@AngeloSK: I still believe you are going about this with the wrong mindset. Why not just place pending orders leisurely well before the time, and as the time approaches adjust the opening prices with the OrderModify() function. That way even if there are delays and not exact synchronization, you will still have orders in place within the expected opening price, even if slightly off. It is not like you are trading for a single point change and profits are you?

 Because sometimes between 8:00 - 9:00 is dax so volatile that it would spike into one direction and im worried that EA wouldnt react so quickly with modifying pending orders and execute my orders at wrong price. Well im not going to trade for single point change but sometimes (with functioning EA) price went opposite direction when it was only 1 point from pending order so that 1 point saved me from loss when i would have not care about few points. Also big problem with modyfing orders is that that sometimes current price is also max/min of that 8:00 - 9:00 range and so i should enter with market order and not with pending.  
 
AngeloSK:
 Because sometimes between 8:00 - 9:00 is dax so volatile that it would spike into one direction and im worried that EA wouldnt react so quickly with modifying pending orders and execute my orders at wrong price. Well im not going to trade for single point change but sometimes (with functioning EA) price went opposite direction when it was only 1 point from pending order so that 1 point saved me from loss when i would have not care about few points. Also big problem with modyfing orders is that that sometimes current price is also max/min of that 8:00 - 9:00 range and so i should enter with market order and not with pending.  
I am afraid that MetaTrader was never designed for lightning speed reactions of High-Frequency trading. You will probably not be able to achieve your objective with the latency involved. You will have to rethink your strategy!
 
Fernando Carreiro:
I am afraid that MetaTrader was never designed for lightning speed reactions of High-Frequency trading. You will probably not be able to achieve your objective with the latency involved. You will have to rethink your strategy!
If it is within 2 seconds before 9:00 i am still cool with it i just wanted to figure out how to use timer everyday in this time range of 8:59:58 - 9:00 
 
AngeloSK:
If it is within 2 seconds before 9:00 i am still cool with it i just wanted to figure out how to use timer everyday in this time range of 8:59:58 - 9:00 
Did you see the code I posted before?
 
honest_knave:
Did you see the code I posted before?

Yeah i saw it and i think this will solve my problem so thank you very much. Maybe just one question (okay maybe two) count of eventsettimer isnt a request to a broker right ? (just asking because i wouldnt like to overload server with constatn pings every 250 ms ) and second question can i use EventSetTimer like i wrote it ? I mean if EventSetTimer could be inside of OnTick and still work. 

 

Thanks guys you are very helpful. 

 
AngeloSK:

count of eventsettimer isnt a request to a broker right ? (just asking because i wouldnt like to overload server with constatn pings every 250 ms )

No, nothing is sent. It just tells your code to do something at a fixed interval.

AngeloSK:

second question can i use EventSetTimer like i wrote it ? I mean if EventSetTimer could be inside of OnTick and still work. 

You can set (and kill) the timer from anywhere in your code. But I don't see why you would want to involve OnTick if all your trades are based on time? The code you actually posted wouldn't work:

if (( h>= 8 && h<=9) && (m >= 59 && m <=00) && r = false)

This never evaluates as true.

 
honest_knave:

No, nothing is sent. It just tells your code to do something at a fixed interval.

You can set (and kill) the timer from anywhere in your code. But I don't see why you would want to involve OnTick if all your trades are based on time? The code you actually posted wouldn't work:

if (( h>= 8 && h<=9) && (m >= 59 && m <=00) && r = false)

This never evaluates as true.

yeah i fixed that mistake also with r == false and not = 

 

thanks for rwply i tested it and works perfectly i will test your code as well so thank you very much.  

I was just confused wit EventSetTimer because in Book it states it should be called in OnInit or class constructor (im not very skilled atMQ and didnt know what class constructor is) so your answer helped me a lot. 
 

I'm glad we helped.

BTW, when you're working with booleans:

if(r == true)

 is the same as writing

if(r)

 

And for the opposite:

if(r == false)

is the same as writing

if(!r)



 

 
AngeloSK: yeah i fixed that mistake also with r == false and not =
But did you fix the problem actually stated?
if (( h>= 8 && h<=9) && (m >= 59 && m <=00) && r = false)

This never evaluates as true.

Reason: