How can I create a script that create both buy and sell order at 10 pips apart from the current price?

 

How can I create a script that create both buy and sell order at 10 pips apart from the current price?

One script create 2 orders buy and sell at the 10 pips apart from the current price.

Is it possible?

 
paul.seldon:

How can I create a script that create both buy and sell order at 10 pips apart from the current price?

One script create 2 orders buy and sell at the 10 pips apart from the current price.

Is it possible?

Yes it is possible . . . use OrderSend() to send the orders.
 
paul.seldon:

How can I create a script that create both buy and sell order at 10 pips apart from the current price?

One script create 2 orders buy and sell at the 10 pips apart from the current price.

Is it possible?


you can place pendingtrades 10 pips from current price if price goes in the direction of your pendingtrade and it reach its level then it will become normally a buy or sell
 
RaptorUK:
Yes it is possible . . . use OrderSend() to send the orders.

So strange - it only execute the first OrderSend(), not the second
 
RaptorUK:
Yes it is possible . . . use OrderSend() to send the orders.


OrderSend(Symbol(), OP_BUYSTOP, 0.5, Ask + 100.0, 0, 0, 0);

OrderSend(Symbol(), OP_SELLSTOP, 0.5, Bid - 100.0, 0, 0, 0);

It complies without errors but it doesn't execute. Chart shows nothing. What's wrong?

 
paul.seldon:


OrderSend(Symbol(), OP_BUYSTOP, 0.5, Ask + 100.0, 0, 0, 0);

OrderSend(Symbol(), OP_SELLSTOP, 0.5, Bid - 100.0, 0, 0, 0);

It complies without errors but it doesn't execute. Chart shows nothing. What's wrong?

Ask + 100 ? did you mean . . .

Ask + (100 * Point)


Please use the SRC button to post code: How to use the SRC button.

 
OrderSend(Symbol(), OP_BUYSTOP, 0.5, Ask + (100.0 *Point), 0, 0, 0);

OrderSend(Symbol(), OP_SELLSTOP, 0.5, Bid - (100.0*Point), 0, 0, 0);


Yes - I changed to what you wrote.

But still only the first buystop was executed not the 2nd sell stop.

 
paul.seldon:


Yes - I changed to what you wrote.

But still only the first buystop was executed not the 2nd sell stop.

What error is reported ? you are checking return values and reporting errors ?
 
RaptorUK:
What error is reported ? you are checking return values and reporting errors ?


When it is compiled, no error. When it is executed, only the first one is executed.

Why don't you try?

-------

How can I print the error to see?

 
paul.seldon:


When it is compiled, no error. When it is executed, only the first one is executed.

Why don't you try?

I don't have your code so I can't try it . . .

paul.seldon:


How can I print the error to see?

What are Function return values ? How do I use them ?
 

Raptor ~ This is the code. ;->

//+------------------------------------------------------------------+
//| OrderSendBothDirection.MPQ4           |
//+------------------------------------------------------------------+
int start()
  {
//----    
   
   int  iSLPips=120;         //Stop Loss in Pips
   int  iTPPips=1000;        //Take Profit in Pips
   int  sp = 30;             // Slippage
   double lot = 0.5; 
   double dStopLoss  = Bid - NormalizeDouble(iSLPips*Point,MarketInfo(Symbol(),MODE_DIGITS));
   double dTakeProfit= Ask + NormalizeDouble(iTPPips*Point,MarketInfo(Symbol(),MODE_DIGITS));       
  
   OrderSend(Symbol(), OP_BUYSTOP,  lot, Ask + (100*Point), sp, dStopLoss, dTakeProfit);
   OrderSend(Symbol(), OP_SELLSTOP, lot, Bid - (100*Point), sp, dStopLoss, dTakeProfit);
              
   return(0);
  }
//+------------------------------------------------------------------+

It seems like OrderSend() function exit out of the script after its execution, if I am not mistaken.

Reason: