How to avoid error 1 in order modify - page 3

 
Luandre Ezra:

already debugging every section of the EA and still the error exist. Found out it is not the code that I used or any of you guys wrote, using point and ticksize has the same ability of solving the problem. The root of it is the indicator itself. I'm debugged it from the start using print statement and found out the value that the data window showed for the supertrend indicator is different with the data that I got from the print statement. I'm still trying to figure it out why the value is different between the data window and the print statement.

this is the screen capture of the chart using the supertrend indicator. The data showed on the data window is different from the alert and supertrend downtrend value should have been around 1.19100 and the value which the alert showed is 1.2000 which is almost 1000 pips away.

You haven't used NormalizeDouble. the other is you need to use the code below. If you install the inverter, you will be helped with the form. ("MQLTA MT4 Supertrend Line.ex4 or mq4)

Example

if(!CheckIfOpenOrdersByMagicNumber(MagicNumber) && SupertrendUpTrend()!=EMPTY_VALUE
if(!CheckIfOpenOrdersByMagicNumber(MagicNumber) && SupertrendUpTrend()!=EMPTY_VALUE


)
     {
      if(newBar && FuncMACDCrossover(1) == 1)
        {
         if(SupertrendDirection() == 1)
            stopLossPrice = SupertrendUpTrend();
         else
            stopLossPrice = NormalizeDouble((Bid - stoplossPoint),Digits);

         double lotSize       = NormalizeDouble(OptimalLotSize(Risk_Per_Trade,Ask,stopLossPrice),2);
         if(lotSize < MarketInfo(Symbol(),MODE_MINLOT))
            lotSize = MarketInfo(Symbol(),MODE_MINLOT);

            orderId              = OrderSend(Symbol(),OP_BUY,lotSize,Ask,slippage,stopLossPrice,0,"Strong BUY",MagicNumber);
        }
 
Mehmet Bastem:

You haven't used NormalizeDouble. the other is you need to use the code below. If you install the inverter, you will be helped with the form. ("MQLTA MT4 Supertrend Line.ex4 or mq4)

Example

No I change it back to not used it because the problem is not based on using or not using normalize double. Normalize Double only normalize the data. I understand that MT see 1.900 different with 1.900001231 but this is not the underlying problem of this threads. Using Point or Ticksize already solve the error 1 in order modify. Just like screenshot that I post before the SupertrendUptrend() value is lower than the actual value in data window and chart and SupertrendDowntrend() value is higher than the actual value in data window and chart.

trailingStop = SupertrendUpTrend();
if(OrderStopLoss() < SupertrendUpTrend())

or

trailingStop = SupertrendDownTrend();
if(OrderStopLoss() > SupertrendDownTrend())

The above code won't trigger order modify because the actual value that the EA receive is either higher for SupertrendDownTrend() or lower for SupertrendUpTrend() and since it is lower than trailingstop it doesn't need to do order modify.

 
Luandre Ezra:

No I change it back to not used it because the problem is not based on using or not using normalize double. Normalize Double only normalize the data. I understand that MT see 1.900 different with 1.900001231 but this is not the underlying problem of this threads. Using Point or Ticksize already solve the error 1 in order modify. Just like screenshot that I post before the SupertrendUptrend() value is lower than the actual value in data window and chart and SupertrendDowntrend() value is higher than the actual value in data window and chart.

The above code won't trigger order modify because the actual value that the EA receive is either higher for SupertrendDownTrend() or lower for SupertrendUpTrend() and since it is lower than trailingstop it doesn't need to do order modify.

Luandre Ezra:

No I change it back to not used it because the problem is not based on using or not using normalize double. Normalize Double only normalize the data. I understand that MT see 1.900 different with 1.900001231 but this is not the underlying problem of this threads. Using Point or Ticksize already solve the error 1 in order modify. Just like screenshot that I post before the SupertrendUptrend() value is lower than the actual value in data window and chart and SupertrendDowntrend() value is higher than the actual value in data window and chart.

The above code won't trigger order modify because the actual value that the EA receive is either higher for SupertrendDownTrend() or lower for SupertrendUpTrend() and since it is lower than trailingstop it doesn't need to do order modify.

trailingStop = SupertrendUpTrend();
if(OrderStopLoss() < SupertrendUpTrend() &&   SupertrendUpTrend()!=EMPTY_VALUE) // 

or

trailingStop = SupertrendDownTrend();
if(OrderStopLoss() > SupertrendDownTrend() &&   SupertrendDownTrend()!=EMPTY_VALUE)
 
Mehmet Bastem:

Thank you Mehmet for your reply. Adding an EMPTY_VALUE condition is not a solution since the supertrend indicator always returning a value. My code in my post before is not to tell where the error code 1 is occur since the first problem is not in the code (for trailing stop) but rather on the indicator itself.