I see, unfortunately, changing the approach as you said before hasn't resolved the issue with the inexplicable placement of OrderLimit.
Even though the correct price level is displayed in the print statement, it's not being placed accurately in the market.
In the attached image, priceO(0) and the OrderLimit variable are printed, showing a difference of 0.02%. Despite this, a sell position is opened at 0.00006 immediately afterward. What could be going wrong here?
if(priceC(0) <= priceO(0) and NumPendingShort <= 0)
{
OrderLimit = priceO(0)-(priceO(0)*(0.2/100)); // 0.2% Distance from current Price
MaxShort = 1;
enterShort();
}
else if(priceC(0) >= priceO(0) and NumPendingLong <= 0)
{
OrderLimit = priceO(0)+(priceO(0)*(0.2/100));// 0.2% Distance from current Price
MaxLong = 1;
enterLong();
}