open the position once new candle opened

 

Hi dear,

I heard that I can use below cods to open the position once new candle opened :


               if (iVolume(Symbol(),time,0)<=1 )   int tiketbuy=OrderSend(Symbol(),OP_BUY,lot,Ask,5,Ask-(st*Point),Ask+(tp*Point),"Aras",1111,0,clrGreen);

OR

       if (Volume[0]<=1 )   int tiketbuy=OrderSend(Symbol(),OP_BUY,lot,Ask,5,Ask-(stoploss*Point),Ask+(takeprofit*Point),"Aras",1111,0,clrGreen);


 but it seams above cods are not trust-able, some times it missed the candles, I think some of the " Volume[0] " pockets are missing in poor internet situation.

do you know better trigger condition,  do we have any boolean function which returns candle open moment ? or any other suggestion.


Br,

Aras

 
ArasRaesi
 if (iVolume(Symbol(),time,0)<=1 )   int tiketbuy=OrderSend(Symbol(),OP_BUY,lot,Ask,5,Ask-(st*Point),Ask+(tp*Point),"Aras",1111,0,clrGreen);
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. 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.

    I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
              New candle - MQL4 programming forum 2014.04.04

  3. You buy at the Ask and sell at the Bid.
    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using the Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

    3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)

Reason: