I give up! We tell you where things are wrong! We tell you where to place debug prints (and you don’t). And you give us the results of separate testing which has nothing to do with printing the actual values happening in your real-time code debugging.
We tell you to break up your code (for real, not just testing) so that it can be read and debugged more easily and you don’t!
If you are unwilling to follow advice, then we can’t help you much!
This is very bad coding:
if(orderType == 0){ //buy order
orderPips = MathAbs((NormalizeDouble(((orderPriceCurrent - PositionGetDouble(POSITION_PRICE_OPEN))/SymbolInfoDouble(position_symbol,SYMBOL_POINT)),SymbolInfoInteger(position_symbol,SYMBOL_DIGITS)))/point_compat); //price 2 is current, price 1 is open
if(orderPriceCurrent < PositionGetDouble(POSITION_PRICE_OPEN)){orderPips = orderPips * -1;}
}