Trade at the perfect time

 
Hey guys,
there are indexes where there is an opening auction, and the better positioned you enter that auction, the more chances you have to win.

The lion starts at 10:00:00 am and due to the latency I have I always come in a little late.

Therefore, I wanted to analyze latency line and send the order at the desired time (latency discounted), which would be the perfect time.

I know that the usual way doesn't work, so I'm reading about the EventSetMillisecondTimer but I would really like to know if anyone already has something done in this aspect.

Thanks
 
diegotfcastro:
Hey guys,
there are indexes where there is an opening auction, and the better positioned you enter that auction, the more chances you have to win.

The lion starts at 10:00:00 am and due to the latency I have I always come in a little late.

Therefore, I wanted to analyze latency line and send the order at the desired time (latency discounted), which would be the perfect time.

I know that the usual way doesn't work, so I'm reading about the EventSetMillisecondTimer but I would really like to know if anyone already has something done in this aspect.

Thanks

SetTimer is useful when you want to do a repeated action in special time distance

for instance you want to open position every 5 minute

if you want to trade at special timezones you should use TimeCurrent() , Hour(),... and set your desired function

 
I would like to point out, TimeCurrent is depending on the trading server. It gets updated with received ticks.

I would suggest using TimeLocal as a source and have the local computer time be synched with a time service.

The transmission latency to the server can be queried by TerminalInfo.

The question I am thinking about, is the market open at that point in time, and will you be able to send the request in the first place.

Maybe you need to cheat a little with your local time.


 
diegotfcastro:
Hey guys,
there are indexes where there is an opening auction, and the better positioned you enter that auction, the more chances you have to win.

The lion starts at 10:00:00 am and due to the latency I have I always come in a little late.

Therefore, I wanted to analyze latency line and send the order at the desired time (latency discounted), which would be the perfect time.

I know that the usual way doesn't work, so I'm reading about the EventSetMillisecondTimer but I would really like to know if anyone already has something done in this aspect.

Thanks

I doubt you will ever be able to do that with MT5 because it's only a gateway on Brazilian exchange. 

 
diegotfcastro:
Hey guys,
there are indexes where there is an opening auction, and the better positioned you enter that auction, the more chances you have to win.

The lion starts at 10:00:00 am and due to the latency I have I always come in a little late.

Therefore, I wanted to analyze latency line and send the order at the desired time (latency discounted), which would be the perfect time.

I know that the usual way doesn't work, so I'm reading about the EventSetMillisecondTimer but I would really like to know if anyone already has something done in this aspect.

Thanks

Yes, I use a similar logic to detect market opening and closing times. And sometimes some markets opens before the oficial time, for auction, then closes for some minutes, and re-open again.

This logic which will let you know that, exactly, and you can send or change orders while on that small period, being among the first ones, and/or send orders as soon as it officially opens. 


long AtivoTempoParado = 0;
int tempoTimer = 200; // 200ms


int OnInit()
{
        EventSetMillisecondTimer(tempoTimer);
}



void OnTimer()
{
        // AtivoTempoParado receives the timeslice since the last tick on the symbol
        // So when the market is open, it will always be ZERO, or very close to Zero,
        // because ticks are happening all the time.
        //
        // When the market closes, this variable will be kept increasing its values, which
        // corresponds to the time (in seconds) since the market was closed. (since the last
        // tick which occurred on such market. 
        // Ex: if the value is 120 means the market is closed for 2 hours.. 
        // 
        // While on the morning of a new day, this variable will have a high value in seconds, 
        // and as soon as the auction is open, instantly this variable it will become = Zero
        //
        // Once that happens, you can place your orders, being among the very first ones. 
        // 
        // This will be executed/checked every 200 milliseconds, which is a good time for checking.
        //

        AtivoTempoParado = TimeCurrent() -  SymbolInfoInteger(_Symbol, SYMBOL_TIME);


        MyExampleFunction();
}


void MyExampleFunction(){

        // now you can use your logic
        // to detect the exactly moment to place the first orders.


        if (AtivoTempoParado < 60) {
                PlaceMyOrders();
                DoWhateverElse();
                etc();
        
        } else {
                // else the market is closed
                WaitforSomething();
        }
}


// Change it to fit your needs.



 
rrocchi:

Yes, I use a similar logic to detect market opening and closing times. And sometimes some markets opens before the oficial time, for auction, then closes for some minutes, and re-open again.

This logic which will let you know that, exactly, and you can send or change orders while on that small period, being among the first ones, and/or send orders as soon as it officially opens. 


Thanks my friend, you helped me with exactly what I needed!!! Thanks


Obrigado

Reason: