Download MetaTrader 5

HELP: the order open priceis not the open price of the candle ????

To add comments, please log in or register
sadik
29
sadik  

hello everybody

i am trying to program an expert advisor using parbolic SAR indicator 

and i have some tiny problems that affect the result in a huge way

1- i want the order open price to be exactly the open price of the candle (the problem : there are always delay in opening price)

as you can see in the chart (the price of  BUY order is more than the open price of the candle with 8 points), and sometimes become more and more bigger.

i am using this code for making the order:

double sar1=iSAR(NULL,0,Step,Maximum,1);
double close1=iClose(NULL,0,1);
double sar0=iSAR(NULL,0,Step,Maximum,0);
double close0=iOpen(NULL,0,0);

if((sar1>close1)&& (sar0<close0))

{
int openbuy=OrderSend(Symbol(),OP_BUY,lot,Ask,slippage,NormalizeDouble(Ask-StopLoss*Point,Digits),NormalizeDouble(Ask+TakeProfit*Point,Digits),"MY1 trader buy order",0,0,Green);

}


any body can help me how to fix this problem!!!..

and thanks in advance.

Tjipke de Vries
6433
Tjipke de Vries  
sadik:

hello everybody

i am trying to program an expert advisor using parbolic SAR indicator 

and i have some tiny problems that affect the result in a huge way

1- i want the order open price to be exactly the open price of the candle (the problem : there are always delay in opening price)

as you can see in the chart (the price of  BUY order is more than the open price of the candle with 8 points), and sometimes become more and more bigger.

i am using this code for making the order:

double sar1=iSAR(NULL,0,Step,Maximum,1);
double close1=iClose(NULL,0,1);
double sar0=iSAR(NULL,0,Step,Maximum,0);
double close0=iOpen(NULL,0,0);

if((sar1>close1)&& (sar0<close0))

{
int openbuy=OrderSend(Symbol(),OP_BUY,lot,Ask,slippage,NormalizeDouble(Ask-StopLoss*Point,Digits),NormalizeDouble(Ask+TakeProfit*Point,Digits),"MY1 trader buy order",0,0,Green);

}


any body can help me how to fix this problem!!!..

and thanks in advance.


There is no problem we can help you with

candle prices are bid prices,  Buytrades get open at Ask      

Check difference Bid and Ask   with weekendtesting you can have you are testing with big spread value 

sadik
29
sadik  
deVries:


There is no problem we can help you with

candle prices are bid prices,  Buytrades get open at Ask      

Check difference Bid and Ask   with weekendtesting you can have you are testing with big spread value 

 


Thanks for your answer


but the difference between Bid and Ask in currencies is 3 points.

why i have big difference?

is there any way to catch the Ask at the beginning of the candle so it will be very close to Open[0] of the candle??

Tjipke de Vries
6433
Tjipke de Vries  
sadik:

Thanks for your answer


but the difference between Bid and Ask in currencies is 3 points.

why i have big difference?

is there any way to catch the Ask at the beginning of the candle so it will be very close to Open[0] of the candle??

NO your condition for opening is not true that moment
At opening you have still this condition

sar1>close1   &&  sar0>close0

 when price hits point sar0   sar direction change

and you get condition

if((sar1>close1)&& (sar0<close0))

 so the trade is not opened at new candle  but the moment sar direction is changed

whroeder1
17084
whroeder1  
  1. sadik: but the difference between Bid and Ask in currencies is 3 points.

    It may be 3 pips or it may be variable depending on the broker. Your broker is a 5 digit broker: a pip is NOT a point. The spread is definitely not 0.3 pips


  2. why i have big difference?
    You didn't bother to show the prices in your image - we have no idea how far that is. Right click -> properties -> show ask line so you see how big the spread is.
sadik
29
sadik  
deVries:

NO your condition for opening is not true that moment
At opening you have still this condition

 when price hits point sar0   sar direction change

and you get condition

 so the trade is not opened at new candle  but the moment sar direction is changed

 

 


so can you give me a condition that make the trade opened at new candle?
sadik
29
sadik  
WHRoeder:
  1. sadik: but the difference between Bid and Ask in currencies is 3 points.

    It may be 3 pips or it may be variable depending on the broker. Your broker is a 5 digit broker: a pip is NOT a point.


  2. why i have big difference?
    You didn't bother to show the prices in your image - we have no idea how far that is. Right click -> properties -> show ask line so you see how big the spread is.

my broker is 4 digits after the point( like 1.2914) for currencies.

and this is the prices.



sadik
29
sadik  

this is another trade with 49 point difference between Buy order and  open price


Tjipke de Vries
6433
Tjipke de Vries  
sadik:

so can you give me a condition that make the trade opened at new candle?


read my explanation why it is not opened at beginning new candle

if you want it then the trade has to be opened at the next candle  

whroeder1
17084
whroeder1  
  1. sadik: my broker is 4 digits after the point( like 1.2914) for currencies.
    Your screen shot shows a price of 1.27916 THAT'S FIVE (5) digits.
  2. sadik: this is another trade with 49 point difference between Buy order and  open price
    Thats 4.9 pips. That's not what you previous said.
    sadik: but the difference between Bid and Ask in currencies is 3 points.
  3. Turn on the Ask line!
  4. When a new candle starts, open your buy at the Ask. That is as close as it will ever be.
sadik
29
sadik  
WHRoeder:
  1. sadik: my broker is 4 digits after the point( like 1.2914) for currencies.
    Your screen shot shows a price of 1.27916 THAT'S FIVE (5) digits.
  2. sadik: this is another trade with 49 point difference between Buy order and  open price
    Thats 4.9 pips. That's not what you previous said.
    sadik: but the difference between Bid and Ask in currencies is 3 points.
  3. Turn on the Ask line!
  4. When a new candle starts, open your buy at the Ask. That is as close as it will ever be.

thanks for your time, but i am still confused, in the last chart

the candle open price is 1.27916 and the Buy price(Ask) is 1.28401

so there is delay 1.28401-1.27916=485 pips

and what you mean by turning on the Ask line???

and for the same chart, there is no way to open the order at price 1.27916 or close to it????.

thanks again.

12
To add comments, please log in or register