iATR usuage

 

Hi, 

In MQL4

After I do "OrderSend (Symbol(), OP_BUY, 1.0, Ask, 0, Ask - iATR(NULL, 0,14,1)*1.5, Ask + iATR(NULL, 0,14,1), "TEST", 123, 0, GREEN);" on a backtest, I reviewed the trades and it showed me SL and TP that are calculated using a different ATR value than the value from loading the ATR indicator on the chart and hovering over the previous closed bar, "1". 


I tried a test with the iATR values alone with "Alert" and it matches what I hover over. I didn't expect the ATR indicator to repaint, so not sure what is happening here. Shouldn't the value of the ATR be fixed after a candle closes or does it have something to do with OrderSend or the actual placement of the order with the server?


I'm testing with Oanda and I believe it's not a ECN broker, so it shouldn't have the seperate SL and TP requirement, unless I'm wrong. 

 

drinkyd:

After I do "OrderSend (Symbol(), OP_BUY, 1.0, Ask, 0, Ask - iATR(NULL, 0,14,1)*1.5, Ask + iATR(NULL, 0,14,1), "TEST", 123, 0, GREEN);" on a backtest,

I reviewed the trades and it showed me SL and TP that are calculated using a different ATR value than the value from loading the ATR indicator on the chart and hovering over the previous closed bar, "1".

I tried a test with the iATR values alone with "Alert" and it matches what I hover over.

I didn't expect the ATR indicator to repaint,

so not sure what is happening here.

Shouldn't the value of the ATR be fixed after a candle closes or

does it have something to do with OrderSend or the actual placement of the order with the server?

so it shouldn't have the seperate SL and TP requirement,

unless I'm wrong. 

  1. You buy at the Ask and sell at the Bid. So for buy orders you pay the spread on open. For sell orders you pay the spread on close.
    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Not the Ask. Your SL is shorter by the spread and your TP is longer.
    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask 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.)

  2. Not possible. You are reading something wrong.
  3. As expected.
  4. It doesn't.
  5. You are reading something wrong.
  6. It is.
  7. Nothing.
  8. No idea what you mean.
  9. Obviously you are.