[INVALID STOP LEVEL] TP Removed (WIN BRL)

 

Hello everyone,

For the past few weeks, I have been encountering an [invalid stop level] issue with a robot I am developing to trade in the Brazilian futures index market (WIN and WDO).

The problem is that my robot enters a trade and places (plots) position increase orders on the chart if the trade moves against my position. What happens is that when my robot calculates the average price, for some reason, when a position increase order is larger than 1 contract, the robot ends up removing the TP from the trade and displaying the message [invalid stop level] . My TP always repositions based on the trade's average price... so when my robot executes position increases, adjusting the trade's average price, the TP also adjusts as it always positions itself relative to the trade's average price. For example: TP = 2 pts... this means that whenever the average price adjusts with position increases, the TP also repositions.

I have already tried various approaches to verify the minimum level required by the broker, tried adding the NormalizeDouble function... and so on. When position increases are with only 1 contract, this error does not occur, but when I set a number greater than 1 for the increases, the robot always removes my TP when executing the increases.

Anyway, I am looking for a solution because I've been stuck on this problem for a few weeks. Has anyone had a similar issue and has any suggestions for a possible solution?

Thank you everyone!

 
if you wont show your coding attempt, you will NOT get much response.