What happen if the Close value is very tight? You should not use SET STOP PTRAILING with this kind of calculation. Be aware that SET STOP PTRAILING performs not the same way in backtests than on real/demo accounts because of the minimal stop distance defined by the broker for the step value (it usually makes the backtests much better than in real life).
Anyway, the main problem here is that the value you set is not respecting this behavior and therefore the trailing stoploss is rejected.
For example, if the DAX minimal stop distance is 5 points, you could modify the code like this:
For trailing stop functionnalities, you should use coded versions that exist around in the forums.
Warning: Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced clients who have sufficient financial means to bear such risk. The articles, codes and content on this website only contain general information. They are not personal or investment advice nor a solicitation to buy or sell any financial instrument. Each investor must make their own judgement about the appropriateness of trading a financial instrument to their own financial, fiscal and legal situation.