Trovare difficoltà nell'inviare ordini. - pagina 2

 
"2014.04.02 00:19:50.590 2010.10.15 00:00:00 fallito scambio acquistare 0,07 GBPUSD a 1,60082[volume non valido]"

 
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]"

Si prega di eseguire questo piccolo script su un grafico GBPUSD e riportare il risultato.

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

  }
 
angevoyageur:

Per favore, esegui questo piccolo script su un grafico GBPUSD e riporta il risultato.

Scusa, non avevo visto il post. Mi stavo occupando di alcuni problemi che avevo avuto con la versione mql4 di questo in modalità demo.

Eseguirò lo script grazie

 

Segnala

"2014.04.02 15:11:27.158 Lotto (GBPUSD,D1) Volume min = 0,010000, volume step = 0,010000 per il simbolo GBPUSD."

 
MetaNt:

Segnala

"2014.04.02 15:11:27.158 Lotto (GBPUSD,D1) Volume min = 0,010000, volume step = 0,010000 per il simbolo GBPUSD."

È strano. Puoi postare tutto il codice rilevante, compresa la chiamata ordersend e l'elaborazione degli errori (stampa)?
 
angevoyageur:
È strano. Puoi postare tutto il codice rilevante, compresa la chiamata all'ordersend e l'elaborazione degli errori (stampa)?

Sì, è sotto come richiesto

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:

Sì, è qui sotto come richiesto


Questo codice non è corretto, non puoi usarlo come fai tu.

buyticket1=(int)OrderGetInteger(ORDER_POSITION_ID);

Devi usare la struttura StageOneBuyRes per ottenere informazioni sul tuo ordine/commercio. Principalmente devi controllare il retcode, vedi la documentazione o cerca nel sito per esempi dell'uso di OrderSend(), non funziona come con mql4.

Il tuo codice sta probabilmente restituendo un errore dove non c'è. Hai controllato il terminale per vedere se una posizione era aperta o aumentata?

Come nota a margine, ma non correlata a questo argomento, il seguente codice probabilmente non fa quello che pensate faccia.

SymbolInfoInteger(_Symbol,SYMBOL_SESSION_DEALS)
 

Bene, lo modificherò.

Non sono sicuro di cosa intendi per controllare il terminale, non ci sono risultati di backtesting mostrati lì.

 
MetaNt:

Bene, lo modificherò.

Non sono sicuro di cosa intendi per controllare il terminale, non ci sono risultati di backtesting mostrati lì.

Ah ok, non avevo capito che fosse un backtesting.
 
angevoyageur:

Questo codice non è corretto, non puoi usarlo come fai tu.

Devi usare la struttura StageOneBuyRes per ottenere informazioni sul tuo ordine/commercio. Principalmente devi controllare il retcode, vedi la documentazione o cerca sul sito degli esempi di utilizzo di OrderSend(), non funziona come con mql4.


Btw in che modo questo causerà l'errore?
Motivazione: