I need to check stop level before sending OP_BUY_STOP and OP_SELL_STOP.
But I'm not sure about the price which I should check for distance and compare to stop level,
is it ask for buy stop and bid for sell stop?
and should I care about the distance between current market price and pending order SL and TP ?
if yes, please tell me which price should be used for any of them.
Added a day later:I think for Buy pending orders, in the future when the price arrived, it will be executed with Ask, So I guess I need to check the current Ask to be far enough from the price which I want to place my buy pending order, and for Pending sells vice versa.
Is it correct?
The simplest answer is : anything to do with Buy will be Ask, and anything to do with Sell will be Bid.
Ideally, you should code somewhere to alter SL and TP prices accordingly AFTER the pending order has been executed, to take into account price slippages.
Thanks Seng Joo Thio
But not always.
For buy you will enter with Ask and exit with Bid
For sell you will enter with Bid and exit with Ask
Your second suggestion is good, this is what i'm doing usually ,thanks
But I'm trying to learn more about it.