Code works on one account but not the other? Very simple, Ordersend

 

I'm very new to coding, and would really appreciate an answer.

I'm learning how to send orders to the platform. When I run the code below on my FXCM demo account, it works perfectly. When I run it on my IG demo account, I get a 130 error. I've tried changing the TP and SL many times and it doesn't help. The MarketInfo() returns 40/50 on the IG and 0 on the FXCM.


    double SL = Ask - 0.05;
   double TP = Ask + 0.1;
   OrderSend(NULL,OP_BUYLIMIT,0. 1,Ask,1,SL,TP);
   
 

   Alert(GetLastError());
   Alert("SL = " + MarketInfo(Symbol(), MODE_STOPLEVEL));


Thanks so much in advance
  

 
When I change it to OP_BUY, it works fine. I thought OP_BUYLIMIT at Ask should have the same effect?
 
Stevie011:
When I change it to OP_BUY, it works fine. I thought OP_BUYLIMIT at Ask should have the same effect?

buylimit will need to be at least a minimum distance away from the current price...

 
Paul Anscombe:

buylimit will need to be at least a minimum distance away from the current price...

thank you, i think this is the answer. so it's not possible to place a buylimit order at the ask price here? this must be exchange/broker specific?
 
Stevie011:

I'm very new to coding, and would really appreciate an answer.

I'm learning how to send orders to the platform. When I run the code below on my FXCM demo account, it works perfectly. When I run it on my IG demo account, I get a 130 error. I've tried changing the TP and SL many times and it doesn't help. The MarketInfo() returns 40/50 on the IG and 0 on the FXCM.


    double SL = Ask - 0.05;
   double TP = Ask + 0.1;
   OrderSend(NULL,OP_BUYLIMIT,0. 1,Ask,1,SL,TP);
   
 

   Alert(GetLastError());
   Alert("SL = " + MarketInfo(Symbol(), MODE_STOPLEVEL));


Thanks so much in advance
  

eee
//example EURUSD Price now 1.19311;
//BUY LIMIT -50 Pips;
//SL=50
//TP=50;
   double EntryPrice=NormalizeDouble((Ask-500*Point),Digits);
   double SL = NormalizeDouble((EntryPrice-500*Point),Digits);
   double TP = NormalizeDouble((EntryPrice + 500*Point),Digits);
  //Buy Limit 
  bool result=OrderSend(NULL,OP_BUYLIMIT,0.1,EntryPrice,3,SL,TP);
  // BUY
//example EURUSD Price now 1.19501;
//SL=50
//TP=50;
   EntryPrice=NormalizeDouble(Ask,Digits);
  SL = NormalizeDouble((EntryPrice-500*Point),Digits);
  TP = NormalizeDouble((EntryPrice + 500*Point),Digits);
  //Buy Limit 
  result=OrderSend(NULL,OP_BUY,0.1,EntryPrice,3,SL,TP);
 
Mehmet Bastem:

Thanks so much, I see how you've used the Points variable and the NormalizeDouble function there to keep the format of the numbers more consistent.

Still, surely the fact that the identical code worked on one exchange and not the other, and also the fact that MarketInfo(Symbol(), MODE_STOPLEVEL)) returned different values on both means that different things are allowed on either exchange?

Reason: