Download MetaTrader 5

IG Index OrderSend

To add comments, please log in or register
scarr
126
scarr  

Hi All,

I have been trying to get OrderSend working without any joy, I am sure this is simple but I cannot figure it out. anyone got a good example of using OrderSend with IG Index on the FTSE100?

Steve

Marco vd Heijden
Moderator
5498
Marco vd Heijden  

Where is the code?

scarr
126
scarr  

Hi Marco,

tbh I don't want to show it, I have been so frustrated and messed about with it so much I am not sure what it does ;-)

Anyway, here you go

   ticket=OrderSend(Symbol(),OP_SELL,1,Bid,3,10,Bid-10,"My order",16384,0,clrGreen);
   if(ticket<0){
      WriteLog("OrderSend failed with error #"+IntegerToString(GetLastError()));
   }else{
      WriteLog("OrderSend placed successfully");      
   }

Sell

Slip of 3

Target Bid -10


Steve

Marco vd Heijden
Moderator
5498
Marco vd Heijden  
Bid-10*Point()
whroeder1
15902
whroeder1  
scarr:

I have been trying to get OrderSend working without any joy,

   ticket=OrderSend(Symbol(),OP_SELL,1,Bid,3,10,Bid-10,"My order",16384,0,clrGreen);

Slip of 3

Target Bid -10

  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here. What's the error code.
  2. Slippage is 3, but 3 what? You are not adjusting SL, TP, and slippage; for 4/5 digit brokers and for JPY pairs. See item 3
  3. Google says FTSE100 is around 7500. What is your SL?
  4. You buy at the Ask and sell at the Bid. Therefor your buy order stops are relative to the Bid, and sell order stops the Ask.What happens to your TP if the spread is more than your 10.
scarr
126
scarr  
  1. Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here. What's the error code. <<<< I Get Error #0
  2. Slippage is 3, but 3 what? You are not adjusting SL, TP, and slippage; for 4/5 digit brokers and for JPY pairs. See item 3 <<< is the slippage not Bid +-3 pips?
  3. Google says FTSE100 is around 7500. What is your SL? <<<< Is stoploss not Bid +-10 pips
  4. You buy at the Ask and sell at the Bid. Therefor your buy order stops are relative to the Bid, and sell order stops the Ask.What happens to your TP if the spread is more than your 10. <<<< I thought the spread was fixed on market (FTSE100) is it not 1 pip can it be 10 pips!!!
This is why I didn't want to supply the code, I wanted someone who has worked with IG Index or is a guru to write a sample line of code as I have managed to totally confuse myself and that line of code.
scarr
126
scarr  

OK can we go back to basics


This is OrderSend

int  OrderSend(
   string   symbol,              // symbol
   int      cmd,                 // operation
   double   volume,              // volume
   double   price,               // price
   int      slippage,            // slippage
   double   stoploss,            // stop loss
   double   takeprofit,          // take profit
   string   comment=NULL,        // comment
   int      magic=0,             // magic number
   datetime expiration=0,        // pending order expiration
   color    arrow_color=clrNONE  // color
   );

But can someone answer these questions

int  OrderSend(
   string   symbol,              // symbol
   int      cmd,                 // operation
   double   volume,              // volume       >>>>>> Is MT4 again the FTSE100 is says "Bet in £1 per 1.0 points", does this mean if I put a volume of 1.0 I am betting £1 per pip?
   double   price,               // price        >>>>>> I think I know this should be "Bid" for Sell and "Ask" for buy, am I correct? (does this need any type of conversion?)
   int      slippage,            // slippage     >>>>>> I think this is the number of pip slippage I am happy with in pips e.g. 3 pips? (does this need any type of conversion?)
   double   stoploss,            // stop loss    >>>>>> I think this is the "market value" I want to stop the trade at in pips e.g. 7400 (does this need any type of conversion?)
   double   takeprofit,          // take profit  >>>>>> I think this is the "market value" I want to close my trade and take profit at, in pips 7450 (does this need any type of conversion?)
   string   comment=NULL,        // comment
   int      magic=0,             // magic number
   datetime expiration=0,        // pending order expiration
   color    arrow_color=clrNONE  // color
   );


How this is clearer :-)

Steve


Marco vd Heijden
Moderator
5498
Marco vd Heijden  

Please look in codebase for examples.

scarr
126
scarr  

OK I now get this error

2017.06.26 20:05:18 OrderSend failed with error #4109

   ticket=OrderSend(Symbol(),OP_SELL,1,Bid,3,Bid+((1*Point)*10),Bid-((1*Point)*10),"My order",16384,0,clrGreen);

But I have checked the "allow live trading" box, anybody any ideas apart from Marco who thinks helping is saying "go look at the manual", Marco, its called a FORUM, where people help each other, so please unless your going to actually help me please do not reply.

Thx

Steve

JC
1515
JC  
scarr:

But I have checked the "allow live trading" box, anybody any ideas apart from Marco who thinks helping is saying "go look at the manual", Marco, its called a FORUM, where people help each other, so please unless your going to actually help me please do not reply.

In brief, I'm afraid...

You have two separate problems. Firstly, the error #4109 can mean either that "Allow live trading" is not turned on, or that the large "AutoTrading" button on MT4's main toolbar is not turned on. In your case, it is apparently the latter.

Returning to your original question, whose details are very broker specific...

On IG's FTSE100, "Point" is 0.1.  Therefore, Point*10 = 1.0. You are trying to place a stop and limit at a difference of 1.0 from the current price. The minimum which IG allow is 10 points from the current price. Their MODE_STOPLEVEL on FTSE100 is 100, meaning "100 times Point"; which equals 100 * .1; which equals 10.

In addition, for the stop-loss, the minimum distance is measured from the other side of the spread. So, on FTSE 100, you cannot place a stop closer than 10 points plus the spread.

The following should mostly work, placing its exit at 100 times Point rather than 10 times point, and measuring the s/l from the other side of the spread (Ask rather than Bid)...

OrderSend(Symbol(),OP_SELL,1,Bid,3,Ask+((1*Point)*100),Bid-((1*Point)*100),"My order",16384,0,clrGreen);

... but it's vulnerable to price changes between you placing the order and it being accepted. The tiniest change in the current ask and bid during transmission of the order will mean that your request fails to satisfy the rules.

Marco vd Heijden
Moderator
5498
Marco vd Heijden  
scarr:

OK I now get this error

2017.06.26 20:05:18 OrderSend failed with error #4109

But I have checked the "allow live trading" box, anybody any ideas apart from Marco who thinks helping is saying "go look at the manual", Marco, its called a FORUM, where people help each other, so please unless your going to actually help me please do not reply.

Thx

Steve

Go look at my history i have 250+ forum pages of helping people.

I developed a sense when to help someone and when to point them to the available documentation.( which is there if you care to look)

In your case, i can not help you other then to Point() you in the right direction by referencing content with available working code.

Please do not expect that i am going to hold your hand and tell you every parameter of the ordersend function. it is not going to happen.

In stead study code that is already present to learn more about the function, or you can open up a job in freelance as well.

12
To add comments, please log in or register