I have submitted your problem to I.A, hereinafter the answer:
Incorrect calculations: Calculations for shortbreakeven, Fullshortexitet stop-loss conditions seem to correspond to arbitrary price levels ( minsteps, positionprice). These values should be based on the actual performance of the position.
Initializing Variables: There is no ShortStopProfit, which can cause problems.
Fuzzy logic: The logic to determine when to place a stop-loss or increase it seems complex and possibly subject to
Exit conditions:
Using BarIndex: Using BarIndexpor to measure profit time can be prone to errors as it depends on the number of bars you have loaded and the frequency of your data.
Management of Short Positions: The code seems mainly intended for the management of short positions. Make sure this fits your trading strategy.
To correct these problems, it may be necessary to rethink the logic of position management and adapt the