come posso ottenere il più alto dopo che orderopenprice è stato aperto.

 

Cari,

qualcuno può controllare il seguente link e rispondere alla mia domanda (come posso ottenere il più alto dopo l'apertura dell'ordine).

http://www.forexfactory.com/showthread.php?t=307937

 
string PriceToStr(double p){ return( DoubleToStr(p, Digits) ); }
:
datetime    OOT         = OrderOpenTime();          // Assumes OrderSelect() done already
int         iOOT        = iBarShift(NULL,0, OOT);   // Bar of the open.
#define     iBarCURRENT   0                         // Include current bar.
int         nSince  = iOOT - iBarCURRENT + 1;       // No. bars since open.
int         iHi         = iHighest(NULL,0, MODE_HIGH, nSince, iBarCURRENT);
double      HH          = High[iHi];                // Highest high.
Print( "High since order opened on ", TimeToStr(OOT)," is ", PriceToStr(HH) );
 
WHRoeder:


Qui ci sono alcuni errori per il codice di cui sopra.

'(' - definizione della funzione inaspettata D:\Files di programma\FXDD Malta - MetaTrader 4\experts\test2.mq4 (343, 18)

questo errore per la stringa PriceToStr(double p)

per questo errore non so come posso risolverlo


'iBarCurrent' - variabile non definita D:\Program Files\FXDD Malta - MetaTrader 4\experts\test2.mq4 (348, 30)

questo errore perché tu definisci #define iBarCURRENT poi lo metti come iBarCurrent

lo correggerò.


2 errore(i),

 

Mettete questa linea alla fine del vostro codice, fuori dalla funzione start.

string PriceToStr(double p){ return( DoubleToStr(p, Digits) ); }

e inizia a leggere questo se vuoi imparare a codificare: https://book.mql4.com//

 

È chiaro ragazzi ( RaptorUK e WHRoeder ),

Grazie.

datetime    OOT         = OrderOpenTime();          // Assumes OrderSelect() done already
int         iOOT        = iBarShift("EURUSD",PERIOD_H1, OOT);   // Bar of the open.
#define     iBarCURRENT   0                         // Include current bar.
int         nSince  = iOOT - iBarCURRENT + 1;       // No. bars since open.
int         iHi         = iHighest("EURUSD",PERIOD_H1, MODE_HIGH, nSince, iBarCURRENT);
double      HH          = High[iHi];                // Highest high.
int         iLi         = iLowest("EURUSD",PERIOD_H1, MODE_LOW, nSince, iBarCURRENT);
double      LL          = Low[iLi];                 // Lowest low. 

Ho un'altra domanda:

se ho 2 ordini aperti uno per comprare e l'altro per vendere:

come posso fare in modo che il mio EA capisca e prenda iOOT = iBarShift("EURUSD",PERIOD_H1, OOT); // Barra dell'apertura. Per la barra da cui ho ottenuto la posizione di acquisto e calcolare il massimo da quel punto.

E

Prendete l'iOOT = iBarShift("EURUSD",PERIOD_H1, OOT); // Barra dell'apertura. Per la barra che ho ottenuto posizione di vendita da esso e calcolare il più basso da quel punto.

Molte grazie

 
Per ottenere OOT devi aver già fatto un orderSelect
for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
    OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
&&  OrderMagicNumber()  == magic.number             // my magic number
&&  OrderSymbol()       == Symbol()                 // and my pair.
){
    datetime    OOT         = OrderOpenTime();          // Assumes OrderSelect() done already
    int         iOOT        = iBarShift("EURUSD",PERIOD_H1, OOT);   // Bar of the open.
    #define     iBarCURRENT   0                         // Include current bar.
    int         nSince      = iOOT - iBarCURRENT + 1;   // No. bars since open.
    if (OrderType == OP_BUY){
        int     iHi         = iHighest("EURUSD",PERIOD_H1, MODE_HIGH, nSince, iBarCURRENT);
        double  HH          = High[iHi];                // Highest high.
    }
    else{
        int     iLi         = iLowest("EURUSD",PERIOD_H1, MODE_LOW, nSince, iBarCURRENT);
        double  LL          = Low[iLi];                 // Lowest low. 
    }
}
 
WHRoeder:
Per ottenere OOT è necessario aver già fatto un orderSelect


Grazie ragazzi.

Ho anche un'altra domanda:

Come posso fare questa condizione: se (ultimo OrderClosePrice() per la vendita > prima dell'ultimo OrderClosePrice per la vendita) && ( prima dell'ultimo OrderClosePrice per la vendita >= bid)

chiudere la posizione

è qualcosa di simile a questo andrà bene

if ( (OrderType == OP_SELL)&& OrderSelect(pos+1, SELECT_BY_POS,MODE_TRADES ) )          { if( pos>pos+1  && pos+1>MarketInfo("EURUSD",MODE_BID);
            // close the position


 

Semplicemente,

Voglio sapere come posso ottenere: l'ordine prima dell'ultimo ordine (aperto o chiuso) prezzo() per (comprare o vendere) per aggiungerli per alcuni calcoli.

Molte grazie.

 
Nessuna risposta, ho solo bisogno di ottenere l'ordine prima dell'ultimo ordine anche per comprare o vendere, anche se l'ordine è aperto o chiuso, in attesa del vostro aiuto.
 
Hand:
Voglio sapere come posso ottenere: l'ordine prima dell'ultimo ordine (aperto o chiuso) prezzo() per (comprare o vendere) per aggiungerli per alcuni calcoli.
Trovare l'ultimo ordine, ricordare, trovare il successivo precedente.
    for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
        OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
    &&  OrderMagicNumber()  == magic.number             // my magic number
    &&  OrderSymbol()       == Symbol()                 // and my pair.
    ){
       datetime OOTlatest = OrderOpenTime();  // found latest open order
       break;
    }
    for(pos--; pos >= 0 ; pos--) if (
        OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
    &&  OrderMagicNumber()  == magic.number             // my magic number
    &&  OrderSymbol()       == Symbol()                 // and my pair.
    ){
       datetime OOTprevious = OrderOpenTime(); // found the previous
       break;
    }
    if (OOTlastest == 0) // no open orders
    if (OOTprevious == 0) // no previous
:
 

Grazie WHRoeder,

Per il tuo aiuto reale. se ho bisogno di ottenere l'ultimo ordine di acquisto e l'ultimo ordine di vendita poi confrontarli facendo :

if ( l'ultimo ordineopenforbuy == OOTlastest )

{ fare qualcosa }

else

{ } ....... è il seguente codice funzionerà.

for(int pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
    OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
&&  OrderMagicNumber()  == magic.number             // my magic number
&&  OrderSymbol()       == Symbol()                 // and my pair.
){
    if (OrderType() == OP_BUY){
        int lastorderforbuy= OrderOpenPrice();
    }
    else{
        int lastorderforsell= OrderOpenPrice(); 
         }
    }   for(pos--; pos >= 0 ; pos--) if (
        OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
    &&  OrderMagicNumber()  == magic.number             // my magic number
    &&  OrderSymbol()       == Symbol()                 // and my pair.
    ){
       if (OrderType() == OP_BUY){
        int previousorderforbuy= OrderOpenPrice();
    }
    else{
        int previousorderforsell= OrderOpenPrice(); 
         }
     } 
    if ( ((lastorderforbuy+ previousorderforsell)/2)<=MarketInfo("EURUSD",MODE_BID))
               {  CLOSESHORT("EURUSD") ;}