Opening the position outside of the candle

 

Hello. 

Somebody could explain me why the position is opening out of reach (picture)??

I uinstalled MT4 , i tried my strategy in onother account.


I will be grreatfull for explain my question 

 Best regards. 

CODE:: 

...

   if (MovingAvarage1 > x && MovingAvarage2> y && MovingAvarage3 > z && i==0)

   {    

      ZakladBuy[i] = OrderSend(Symbol(), OP_BUY, 0.01, Ask, 0, (Ask-200*_Point), 0, 0, 0);

      i=1;      

   }

       if (KorektaBuy == true && i > 0 && MovingAvarage3 > z)

   { 


      ZakladBuy[i] = OrderSend(Symbol(), OP_BUY, 0.01, Ask, 0, (Ask-500*_Point), 0, 0, 0);

      i++;

   }

...

Files:
Picture.png  262 kb
 
The chart is Bid, the entry is Ask
 
forexmilflis: Somebody could explain me why the position is opening out of reach (picture)??

ZakladBuy[i] = OrderSend(Symbol(), OP_BUY, 0.01, Ask, 0, (Ask-200*_Point), 0, 0, 0);

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