how to open a trade at the exact time, without using pending order?

 

Dear Friends,


For example, I want to open a Sell/Buy position at the 12:05 o'clock. how can I do it?

it seems that it is not very difficult for you to help me.

I am really thankful

 
mh.vasheghany:

Dear Friends,


For example, I want to open a Sell/Buy position at the 12:05 o'clock. how can I do it?

it seems that it is not very difficult for you to help me.

I am really thankful

How do you know how difficult it is if you don't know how to do it??

 
Keith Watford:

How do you know how difficult it is if you don't know how to do it??

hi dear
I do believe that my question is not very difficult for the person who has knowledge in mql5 coding, but I have no knowledge enough to solve my problem
 
Try the freelance section
 
mh.vasheghany:
hi dear
I do believe that my question is not very difficult for the person who has knowledge in mql5 coding, but I have no knowledge enough to solve my problem

Hi

In Metatrader OnTick() function is called when forming a candle, which does not know what hour or minute the event will take place.

I think you get the current server time using TimeTradeServer (dt_struc)

Then turn it into seconds.

For example:

your clock=12:05:30

current time server=11:01:00

long TimeRemainingInSeconds=((12-11)*60*60)+((05-01)*60)+30;

and call ontimer()  function:

OnTimer(1sec);


and then  in OnTimer function:

if(TimeRemainingInSeconds==0)///////////////////////////At this point the server clock is equal to the clock you want(12:05:30)

  {

     sendorder();

}

else

{

    TimeRemainingInSeconds--;

}





I hope my solution works.

If you have any questions, I'm at your service.

Documentation on MQL5: Date and Time / TimeCurrent
Documentation on MQL5: Date and Time / TimeCurrent
  • www.mql5.com
Returns the last known server time, time of the last quote receipt for one of the symbols selected in the "Market Watch" window. In the OnTick() handler, this function returns the time of the received handled tick. In other cases (for example, call in handlers OnInit(), OnDeinit(), OnTimer() and so on) this...
 
mh.vasheghany: I want to open a Sell/Buy position at the 12:05 o'clock. how can I do it?

You wait for a tick. Check if the time is 12:05. If not don't open. If so, open. When in doubt, THINK.

 
William Roeder:

You wait for a tick. Check if the time is 12:05. If not don't open. If so, open. When in doubt, THINK.

In some markets (for example Iran market)

It is known as the Pre-Opening phase from 08:30 to 9:00 (meaning no deals are made and the buyer or seller sends the order Only but  No deals, so no candels will be made during this time).

In fact, the trading time is from 9:00 to 12:30 .

 
mh.vasheghany:

Dear Friends,


For example, I want to open a Sell/Buy position at the 12:05 o'clock. how can I do it?

it seems that it is not very difficult for you to help me.

I am really thankful

Though I konw, but sorry you are not my dear friend.

 

Try this.

if(Hour()==12 && Minutes()==5)
{
        //Your code here.
}
 
Joel Protusada:

Try this.

Dear Joel,

thanks dear

 
Milad Yarzamn :

In some markets (for example Iran market)

It is known as the Pre-Opening phase from 08:30 to 9:00 (meaning no deals are made and the buyer or seller only orders but no deals, so no candles will be made during this time).

In fact, the trading time is from 9:00 to 12:30.

Dear Milad,

thanks.

Reason: