PlaceStopOrder - Stop Loss to be previous days low
PlaceStopOrder - Stop Loss to be previous days low
10 Aug 2020, 22:59
Hi Guys
I am trying to get my stop loss on a execute at market to be @ the previous days low. My code does'nt seem to work :( may be something simple...
Help needed please.
Replies
samuelbreezey
11 Aug 2020, 15:34
RE:
PanagiotisCharalampous said:
Hi samuelbreezey,
Shouldn't you use totalPipsB instead of slPriceB here?
ExecuteMarketOrder(TradeType.Buy, SymbolName, exactVolumeB, InstanceName, slPriceB, tpPrice);
Best Regards,
Panagiotis
Hi Panagiotis,
Won't both totalPipsB and slPriceB produce the same results? as they are both the same.
I thought I needed to incorporate the spread within my calculation. It improved the result a little but the stop loss is still a little out from the actual low or high of the previous candle.
Guessing it is to do with the market order not being the exact close price of the previous bar.
Many thanks
Sam
@samuelbreezey
PanagiotisCharalampous
11 Aug 2020, 15:41
Hi Sam,
Yes you are right, I misread the code. If the difference is slight then this is expected since you are calculating the stop loss distance based on the current price and not based on the position's entry price which might deviate due to slippage. If you need to place the stop loss on an exact price then you need to modify the position after it has been opened.
Best Regards,
Panagiotis
@PanagiotisCharalampous
samuelbreezey
11 Aug 2020, 16:21
RE:
PanagiotisCharalampous said:
Hi Sam,
Yes you are right, I misread the code. If the difference is slight then this is expected since you are calculating the stop loss distance based on the current price and not based on the position's entry price which might deviate due to slippage. If you need to place the stop loss on an exact price then you need to modify the position after it has been opened.
Best Regards,
Panagiotis
Thank you Panagiotis
That is alright :) I thought this may be the case but was doing everything I could to not have to modify the price.
Is it not possible to calculate the stop loss distance from the position entry price? If not, then I will modify the position. Can you send me to where I can find the code.
Thank you for your help as always
Sam
@samuelbreezey
PanagiotisCharalampous
11 Aug 2020, 16:30
Hi Sam,
It is not possible to know the entry price before the order is executed. To modify the stop loss price use ModifyStopLossPrice
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
11 Aug 2020, 07:54
Hi samuelbreezey,
Shouldn't you use totalPipsB instead of slPriceB here?
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous