I would say that the second one is what you want to use, but chart prices are bid, so don't use ask , only bid.
So for both open buy and sell order I should use the bid price?
Compare the bid price with the SAR, the SAR is calculated with the bid price, not the ask.
Compare the bid price with the SAR, the SAR is calculated with the bid price, not the ask.
Thanks for the reply Keith!. I already did like what you suggest but I got somewhat odd result. This is my code and I attach an image and to pin point the odd result. The order would not be close when the parabolic SAR change direction and close really far from it suppose to be. Is there an error in my code?
//closing open order if(OrderSelect(orderId,SELECT_BY_TICKET,MODE_TRADES)) //check the order by the ticket { if(OrderSymbol() == Symbol() && OrderType()==OP_BUY) { if(PSARValue > Bid) { bool res = OrderClose(orderId,OrderLots(),Bid,0); if(!res) Print("Error in OrderModify. Error code=",GetLastError()); else Print("Order closed successfully."); } } if(OrderSymbol() == Symbol() && OrderType()==OP_SELL) { if(PSARValue < Bid) { bool res = OrderClose(orderId,OrderLots(),Ask,0); if(!res) Print("Error in OrderModify. Error code=",GetLastError()); else Print("Order closed successfully."); } } }
Thanks for the reply Keith!. I already did like what you suggest but I got somewhat odd result. This is my code and I attach an image and to pin point the odd result. The order would not be close when the parabolic SAR change direction and close really far from it suppose to be. Is there an error in my code?
Hello,
Try setting
PSARValue>ASK, and
PSARValue<BID respectively.
I am working on a similar bot and had a similar problem.
Try setting
PSARValue>ASK, and
PSARValue<BID respectively.
Please do not give wrong information.
I have already explained why NOT to use ask.
Thanks for the reply Keith!. I already did like what you suggest but I got somewhat odd result. This is my code and I attach an image and to pin point the odd result. The order would not be close when the parabolic SAR change direction and close really far from it suppose to be. Is there an error in my code?
I can't see anything obviously wrong with the snippet that you have shown except you only have slippage set to 0 which is low.
if(OrderSelect(orderId,SELECT_BY_TICKET,MODE_TRADES)) //check the order by the ticket
Where does orderId come from? Are you sure that an open order is being selected?
Incidentally
if(OrderSelect(orderId,SELECT_BY_TICKET)) //check the order by the ticket
There is no need for the MODE_TRADES as this is ignored when selecting by ticket. If the order is closed already, it will still be selected.
I can't see anything obviously wrong with the snippet that you have shown except you only have slippage set to 0 which is low.
Where does orderId come from? Are you sure that an open order is being selected?
Incidentally
There is no need for the MODE_TRADES as this is ignored when selecting by ticket. If the order is closed already, it will still be selected.
orderId is variable to contain the ordersend function.
orderId = OrderSend(Symbol(),OP_SELL,lotSize,Bid,0,stopLossPrice,0,NULL,magicNumber1);
Already tried to give up to 1 pip to the slippage but the result still the same. Really doesn't know what cause the close order behave like that.
Is it a globalscope variable?
Is it a globalscope variable?
Yes it is.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
1. comparing the previous bar with the current bar. 2. comparing with the price
which one of this two logic that's correct to apply if I want to close the order using PSAR?