I have a question aboiut a part of a code I am working on. Basically I tell to enter a trade at the high of a bar.
I the set my stop at the low of the bar and I calculate the difference between these two points. I then multiply this by 2 and that will be my target.
Now after a while I find that due to slippage the entry point is usual a few points above the bar high. Is there a possibility to use the actual executed price in the calculation of stop and target?
Please Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.
Thank you 🙂
1. I suggest that you move lines 10-11 to a new line just before line 8, so that they don’t move each new bar due to lines 1-3.
2. TradePrice (or PositionPrice when cumulating positions) is only known when the bar where the trade entered CLOSES, so you can check when you are OnMarket but weren’t the previous bar (using If OnMarket AND Not OnMarket[1]) then re-calculate SL & TP according to the real price and setting them again will overwrite the previous one.