Error #130 - Invalid stops - page 2

 
malc659:

I believe I can confirm that for eg. Alpari Micro Account (it has to be a "live" account), you have to do OrderSend with zero SL and TP and then straightaway afterwards, modify the order with the required SL and TP to get it to work. I do an OrderSelect straight after so that I can use OrderOpenPrice() as the open price in the OrderModify parameter list.

That's what I changed in my code and it seems to work now.

I think I had the same problem with Axis trader so maybe I'll try it on there again some time.

The only other thing I did was make sure that when I sent the OrderSend, there was a magic number not zero on it.

Good luck to all.


>>I believe I can confirm that for eg. Alpari Micro Account (it has to be a "live" account), you have to do OrderSend with zero SL and TP I believe I can confirm that for eg. Alpari Micro Account (it has to be a "live" account), you have to do OrderSend with zero SL and TP

No, is not.

But this broker have 3/5 digits and in this case you need to multiply your TP/SL with 10.

TakeProfit = 10 so you need TakeProfit = 100;

 
extern double TakeProfitPip = 10;
extern double StopLossPip = 21;
  1. On a 5 digit broker 21*point is 2.1 pips. Must adjust TP, SL, and slippage.

    //++++ These are adjusted for 5 digit brokers.
    double  pips2points,    // slippage  3 pips    3=points    30=points
            pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
    int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
    int init(){
        if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                    pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
        } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
        // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl

  2. On an ECN broker, you must OrderSend with No (zero) TP, SL. Then modify the order.

 

Helo Mqlforum..could anyone plz correct the code fr me..i m nt able to take "1pip as takeprofit"

 

here is the code

//+------------------------------------------------------------------+

//|                                                      MY3STEA.mq4 |

//|                        Copyright 2016, MetaQuotes Software Corp. |

//|                                             https://www.mql4.com |

//+------------------------------------------------------------------+

extern double LotSize=0.1;

extern double TakeProfit=1;

extern double StopLoss=0;

extern int MagicNumber=1155;

extern double TimeFrame=0;

extern int Period=25;

extern int Rsilevel=55;


extern   int            ADX_Period           =  14;

extern   double         ADX_BuyLevel         =  25;

extern   double         ADX_SellLevel        =  25;

//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

  {

   return(0);

  }

      

  

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

int deinit()

  {

//---

   

   return(0);

  }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

int start()

  {



double RXI=iRSI(Symbol(),0,14,0,1);

double ADXMAIN=iADX(NULL,0,ADX_Period,0,MODE_MAIN,1);

double ADXPD1=iADX(NULL,0,ADX_Period,0,MODE_PLUSDI,1);

double ADXMD1=iADX(NULL,0,ADX_Period,0,MODE_MINUSDI,1);




if(RXI>Rsilevel && ADXMAIN>ADX_BuyLevel && ADXPD1 > ADX_BuyLevel )

{

   int bop=OrderSend=(Symbol(),OP_BUY,LotSize,Ask,3,0,0,NULL,MagicNumber,0,Blue);

      

     

      if(bop<0)

      {

      Print("OrderSend failed with error #",GetLastError());     

      }

      else 

      {

         Print("OrderSend placed successfully");

      }

      

      

   bool  bop = OrderModify(bop,OrderOpenPrice(),Ask-StopLoss*Point(),Ask+TakeProfit*Point(),0);

            prevTime = Time[0];

            buyflag = 1;

            sellflag = 0;

   

      if(bop<0)

      {

         Print("Error in OrderModify. Error code=",GetLastError());

      }

      else

      {

         Print("Order modified successfully.");

      }

      




if(RXI>Rsilevel &&  ADXMAIN>ADX_SellLevel && ADXMD1 >ADX_SellLevel)


     {

      int soo = OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,0,0,"SELL",MagicNumber,0,Red);

   

      

      if(soo<0)

      {

         Print("OrderSend failed with error #",GetLastError());

      }

      else

      {

         Print("OrderSend placed successfully");

        

      }

                 

    bool soo = OrderModify(soo,OrderOpenPrice(),Bid+StopLoss*Point(),Bid-TakeProfit*Point(),0);

            prevTime = Time[0];

            buyflag = 0;

            sellflag = 1;


      if(soo<)

      {

         Print("Error in OrderModify. Error code=",GetLastError());

      }

      else

      {

         Print("Order modified successfully.");

      }    

      

    

return(0);

 

this is my contact email=<Removed>

 
tasaoirse: ..could anyone plz correct the code fr me..i m nt able to take "1pip as takeprofit"
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. extern double TakeProfit=1;
    bool  bop = OrderModify(bop,OrderOpenPrice(),Ask-StopLoss*Point(),Ask+TakeProfit*Point(),0);
    What are your limits? Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial 1 pip may not be possible.
  3. You can not use any Trade Functions - MQL4 Reference unless you select the trade first.
  4. You buy at the Ask, so stops are relative to the Bid. You are trying to set a SL above the market, if the spread is more than 1 point.
  5. Where are you adjusting for 4/5 digit brokers? On a 5 digit broker Point is 1/10 pips.
  6. What is the first argument to OrderModify - Trade Functions - MQL4 Reference and what are you passing?
 
soorry unable to help
 
Malcolm Boekhoff:

I believe I can confirm that for eg. Alpari Micro Account (it has to be a "live" account), you have to do OrderSend with zero SL and TP and then straightaway afterwards, modify the order with the required SL and TP to get it to work. I do an OrderSelect straight after so that I can use OrderOpenPrice() as the open price in the OrderModify parameter list.

That's what I changed in my code and it seems to work now.

I think I had the same problem with Axis trader so maybe I'll try it on there again some time.

The only other thing I did was make sure that when I sent the OrderSend, there was a magic number not zero on it.

Good luck to all.

Thanks a lot. Spent hours in futility.

Your answer saved me!

Reason: