Finding it difficult to send orders. - page 2

 
"2014.04.02 00:19:50.590 2010.10.15 00:00:00   failed exchange buy 0.07 GBPUSD at 1.60082 [Invalid volume]"

 
MetaNt:
"2014.04.02 00:19:50.590 2010.10.15 00:00:00   failed exchange buy 0.07 GBPUSD at 1.60082 [Invalid volume]"

Please run this little script on a GBPUSD chart, and report the result.

void OnStart()
  {
   printf("Volume min = %f, volume step = %f for symbol %s.",
          SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN),
          SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP),
          _Symbol);

  }
 
angevoyageur:

Please run this little script on a GBPUSD chart, and report the result.

Sorry, I didn't see the post. I was dealing with some of issues I had been having with the mql4 version of this on demo mode.

I'll run the script thanks 

 

Report

 

"2014.04.02 15:11:27.158 Lot (GBPUSD,D1) Volume min = 0.010000, volume step = 0.010000 for symbol GBPUSD."

 
MetaNt:

Report

 

"2014.04.02 15:11:27.158 Lot (GBPUSD,D1) Volume min = 0.010000, volume step = 0.010000 for symbol GBPUSD."

It's weird. Can you post all the relevant code, including ordersend call and error processing (printing) ?
 
angevoyageur:
It's weird. Can you post all the relevant code, including ordersend call and error processing (printing) ?

Yes, it's below as requested

 

Lot=LotSize/8;


MqlTradeResult StageOneBuyRes={0};
MqlTradeRequest StageOneBuy={0};

StageOneBuy.action=TRADE_ACTION_DEAL;  
StageOneBuy.magic=MagicNumber;  
StageOneBuy.symbol=_Symbol;            // symbol
StageOneBuy.volume=Lot;
StageOneBuy.price=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
StageOneBuy.sl=0;                  // Stop Loss is not specified
StageOneBuy.tp=0;                 // Take Profit is not specified 
StageOneBuy.deviation =7;  
StageOneBuy.type=ORDER_TYPE_BUY; // order type
StageOneBuy.type_filling = ORDER_FILLING_FOK;
StageOneBuy.comment = "test";
 

MqlTradeResult StageOneSellRes={0};
MqlTradeRequest StageOneSell={0};

StageOneSell.action=TRADE_ACTION_DEAL;  
StageOneSell.magic=MagicNumber;  
StageOneSell.symbol=_Symbol;            // symbol
StageOneSell.volume=Lot;
StageOneSell.price=SymbolInfoDouble(_Symbol,SYMBOL_BID);
StageOneSell.sl=0;                  // Stop Loss is not specified
StageOneSell.tp=0;                 // Take Profit is not specified 
StageOneSell.deviation =7;  
StageOneSell.type=ORDER_TYPE_SELL; // order type
StageOneSell.type_filling = ORDER_FILLING_FOK;
StageOneSell.comment = "test";

 

if(SymbolInfoInteger(_Symbol,SYMBOL_SESSION_DEALS)==0){if(OrderSend(StageOneBuy,StageOneBuyRes))buyticket1=(int)OrderGetInteger(ORDER_POSITION_ID);}
       if(buyticket1>0){Print("Order Placed ","Order Ticket ", buyticket1," Order Lots ",OrderGetDouble(ORDER_VOLUME_INITIAL));return;}else{Print("Order Placement Unsuccessful ", GetLastError());return;}

 

if(SymbolInfoInteger(_Symbol,SYMBOL_SESSION_DEALS)==0){if(OrderSend(StageOneSell,StageOneSellRes))sellticket1=(int)OrderGetInteger(ORDER_POSITION_ID);}
       if(sellticket1>0){Print("Order Placed ","Order Ticket ", sellticket1," Order Lots ", OrderGetDouble(ORDER_VOLUME_INITIAL));return;}else{Print("Order Placement Unsuccessful ", GetLastError());return;}
 
MetaNt:

Yes, it's below as requested


This code isn't right, you can't use it as you do.

buyticket1=(int)OrderGetInteger(ORDER_POSITION_ID);

You have to use the StageOneBuyRes structure to get information about your order/deal. Mainly you have to check the retcode, please see the documentation or search the site for examples of the use of OrderSend(), it doesn't work like with mql4.

Your code is probably returning an error where there is not. Did you check the terminal to see if a position was open or increased ?

As a side note, but not related to this topic, the following code probably don't do what you think it does.

SymbolInfoInteger(_Symbol,SYMBOL_SESSION_DEALS)
 

Right I will emend that.

 I'm not sure what you mean by checking the terminal, there are not any backtesting results shown there. 

 
MetaNt:

Right I will emend that.

 I'm not sure what you mean by checking the terminal, there are not any backtesting results shown there. 

Ah ok, I didn't catch it was a backtesting.
 
angevoyageur:

This code isn't right, you can't use it as you do.

You have to use the StageOneBuyRes structure to get information about your order/deal. Mainly you have to check the retcode, please see the documentation or search the site for examples of the use of OrderSend(), it doesn't work like with mql4.


Btw how will this cause the error to show up?
Reason: