OrderSend Error 130???

 

i keep getting this OrderSend Error 130 error when i back test my expert advisor, i already googled it and found out that it is related to stoploss and take profit value being lower than the brokers limit hence i raised it over eer the brokers allowance but the error still persist in my journal after every test. the best part is i downloaded sample EA and run it and same problem happens...

 

how shud i fix it? 

 
cyxstudio:

i keep getting this OrderSend Error 130 error when i back test my expert advisor, i already googled it and found out that it is related to stoploss and take profit value being lower than the brokers limit hence i raised it over eer the brokers allowance but the error still persist in my journal after every test. the best part is i downloaded sample EA and run it and same problem happens...

 

how shud i fix it? 

Show your code.
 

ermmm guys its fixed...i add in another line and the error doesnt show anymore but i backtested it and nothing happened. no trades went through LOL. I pretty much think the problem still exists it didnt show when i backtests because no trades were executed.

ps: this is the forth day i learn mql4 hehe. i just started forex 1 week ago.

This is my code. I am trying to write an EA that will execute the trades as shown in the picture here.

 

 

 

//All Variables here

extern double UpperBound    =  90;      //set upper bound value

extern double LowerBound    =  5;      //set lower bound value

extern double VarPeriod     =  2;      //number of periods

extern double BuyVolume     = 5;       //set buying volume, preset to 5

extern double SellVolume    = 5;       //set selling volume, preset to 5

extern double StopLoss      = Ask-60*Point;   //Set the stop loss level

extern double TakeProfit    = Ask+60*Point;   //Set the take profit level

int start()

  {

//----



   double CurrentRSI;                  //Finds out the RSI for now

   double CurrentMA;                   //Finds out the moving average now             

   double CurrentAsk;                  //Finds out the Ask price now

   double CurrentBid;                  //Finds out the Bid price now

   

   CurrentAsk = MarketInfo(Symbol(), MODE_ASK);

   CurrentBid = MarketInfo(Symbol(), MODE_BID);

   CurrentMA = iMA(NULL, 0, VarPeriod, 8,MODE_SMA,PRICE_CLOSE, 0)    ;

   CurrentRSI = iRSI (NULL, 0, VarPeriod,PRICE_CLOSE ,0);

   

   

    if (CurrentRSI < LowerBound && CurrentAsk - CurrentMA > 200 ) {    //If RSI value is less than lowerbound value and Ask price is 200 units higher than Moving Average

        OrderSend(Symbol(), OP_BUY, BuyVolume, Ask, 3, StopLoss, TakeProfit, "", 0,0,Yellow)   ;       //execute buy order

   }

   if (CurrentRSI > UpperBound && CurrentMA - CurrentBid > 200 ) {     //If RSI value is more than upperbound and Moving Average is 200 units higher than Bid price 

       OrderSend(Symbol(), OP_SELL, SellVolume, Bid, 3, StopLoss, TakeProfit, "",0, 0, Yellow)  ;     //execute sell order

   }

   

   

   

//----

   return(0);

  }

//+------------------------------------------------------------------+ 
 
cyxstudio:

ermmm guys its fixed...i add in another line and the error doesnt show anymore but i backtested it and nothing happened. no trades went through LOL. I pretty much think the problem still exists it didnt show when i backtests because no trades were executed.

ps: this is the forth day i learn mql4 hehe. i just started forex 1 week ago.

This is my code. I am trying to write an EA that will execute the trades as shown in the picture here.

It does not trade, because your code does not compile. I recommend you to start here. If you look at the simple EA example, you may get an idea of what is needed to write only a simple program.

 

This is your problem,  the extern variables are read at the start of the code execution,  at the time that your order is placed your SL & TP values can be very very wrong.  Also TP & SL are not the same for Buys and Sells.

extern double StopLoss      = Ask-60*Point;   //Set the stop loss level

extern double TakeProfit    = Ask+60*Point;   //Set the take profit level

Do this . . .

extern double StopLoss      = 60;   //Set the stop loss level

extern double TakeProfit    = 60;   //Set the take profit level

and this . .

   if (CurrentRSI < LowerBound && CurrentAsk - CurrentMA > 200 )     //If RSI value is less than lowerbound value and Ask price is 200 units higher than Moving Average
      {
      OrderSend(Symbol(), OP_BUY, BuyVolume, Ask, 3, Bid - ( StopLoss * Point ), Ask + ( TakeProfit * Point ), "", 0,0,Yellow)   ;       //execute buy order
      }

   if (CurrentRSI > UpperBound && CurrentMA - CurrentBid > 200 )      //If RSI value is more than upperbound and Moving Average is 200 units higher than Bid price 
      {
      OrderSend(Symbol(), OP_SELL, SellVolume, Bid, 3, Ask + ( StopLoss * Point ), Bid - ( TakeProfit * Point ), "", 0, 0, Yellow)  ;     //execute sell order
      }

 

You should also adjust your TP & SL to work with both 4 digit and 5 digit Brokers.  You should also check the return values from the OrderSend() function calls to make sure it has worked,  read this:  What are Function return values ? How do I use them ?

 
thank you guys, currently working on it. 
 
1 more question, as shown as the pic i need to find the 200 simple moving average and 5 simple moving average....may i know which parameter to set on iMA()? is it the shift thing?
 
cyxstudio:
1 more question, as shown as the pic i need to find the 200 simple moving average and 5 simple moving average....may i know which parameter to set on iMA()? is it the shift thing?

No,  it's not   shift  -  Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

 it's  period  -  Averaging period for calculation.

Reason: