Take Profit from EMA value creeps higher
Take Profit from EMA value creeps higher
31 Jan 2025, 09:47
I have a robot that calls the following method from within OnBarClosed()
:
private void AdjustTakeProfitLevels() { if (Positions.Count > 0) { foreach (var position in Positions) { if (position.SymbolName == Symbol.Name) { var tpValue = Math.Round(_tpEma.Result.LastValue, Symbol.Digits); ModifyPosition(position, null, tpValue); } } } }
The issue I have is that when the cBot is started initially, the take profits are set correctly. After running for a while (about an hour+), the take profit begins to be set higher than the EMA. An example is in the image below. the purple line is set to represent the take profit EMA. The actual take profit is being set by the cBot.

Is there anything I might be missing that might be causing this issue? At the moment, I just restart the cBot and it corrects the take profit, but after a while it drifts higher again.
Thanks in advance for any help you can provide.
firemyst
07 Feb 2025, 02:54 ( Updated at: 14 Feb 2025, 18:18 )
Try rounding to (Symbol.Digits + 1) instead of just Symbol.Digits
@firemyst