How to make sure that only one order is executed and not more? On Mql5

 
hi guys im creating an EA that will place a pending order at a specific time,for example lets say i decide that at 3:30 pm i decide that my EA places a pending buy order,however what tends to happen and is the obstacle right now is that,at 3:30 the EA makes the pending order just as instructed,but after this order has been closed it continues to make more orders,for as long as the time is still 3:30 on the clock,which means it only stops making these orders after 3:30 whic is 3:31,this is not what i want thouh,i want the EA to only make one oder and nothing more at 3:30.If any one can help guys how can i do this?
 
Princy333:
hi guys im creating an EA that will place a pending order at a specific time,for example lets say i decide that at 3:30 pm i decide that my EA places a pending buy order,however what tends to happen and is the obstacle right now is that,at 3:30 the EA makes the pending order just as instructed,but after this order has been closed it continues to make more orders,for as long as the time is still 3:30 on the clock,which means it only stops making these orders after 3:30 whic is 3:31,this is not what i want thouh,i want the EA to only make one oder and nothing more at 3:30.If any one can help guys how can i do this?

Fix your code

 
  1. Princy333: im creating an EA that will place a pending order

    There is no need to create pending orders in code.

    1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)
    2. Don't worry about it unless you're scalping M1 or trading news.
    3. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.

  2. Princy333i want the EA to only make one oder and nothing more at 3:30.If any one can help guys how can i do this?

    Place a new bar test inside your 3:30 test so it tries only once.

    For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
              MT4: New candle - MQL4 programming forum #3 (2014)
              MT5: Accessing variables - MQL4 programming forum #3 (2022)

    I disagree with making a new bar function, because it can only be called once per tick (second call returns false). A variable can be tested multiple times.
              Running EA once at the start of each bar - MQL4 programming forum (2011)

 
William Roeder #:
  1. There is no need to create pending orders in code.

    1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)
    2. Don't worry about it unless you're scalping M1 or trading news.
    3. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.

  2. Place a new bar test inside your 3:30 test so it tries only once.

    For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
              MT4: New candle - MQL4 programming forum #3 (2014)
              MT5: Accessing variables - MQL4 programming forum #3 (2022)

    I disagree with making a new bar function, because it can only be called once per tick (second call returns false). A variable can be tested multiple times.
              Running EA once at the start of each bar - MQL4 programming forum (2011)


Hi William,i actually thought about the new bar class and im thinking perhaps it could work, but wait im a bit confused by your response,first you say i should create the new bar test,but then again you say bars are unreliable,then u say u are against creating a new bar function because it can only be called once per tick(But isnt that what im looking for?the EA to only execute a single trade)and another thing i would like you to clarify,if you say bars are unreliable,but then again you said i must always use time so again im not sure if you sayin i should place the new bar test as you recommend or not place it and just rely on time?

 
William Roeder #:
  1. There is no need to create pending orders in code.

    1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)
    2. Don't worry about it unless you're scalping M1 or trading news.
    3. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.

  2. Place a new bar test inside your 3:30 test so it tries only once.

    For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
              MT4: New candle - MQL4 programming forum #3 (2014)
              MT5: Accessing variables - MQL4 programming forum #3 (2022)

    I disagree with making a new bar function, because it can only be called once per tick (second call returns false). A variable can be tested multiple times.
              Running EA once at the start of each bar - MQL4 programming forum (2011)

Oh william im so sorry i hadnt read the response you linked before answering,ive just read it and i actually understand you,i feel so stupid for my previous answer...and thank you soo much.