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

 
( OrderType() < OP_BUYLIMIT ) è uguale a ( OrderType () == OP_BUY ||OrderType() == OP_SELL )
 
Hand:


ragazzi,

Grazie mille,

Vi spiego perché voglio utilizzare LastOpenPrice(OP_BUY) e LastOpenPrice(OP_SELL) perché voglio utilizzarli in alcune condizioni come

if ( LastOpenPrice(OP_BUY) -LastOpenPrice(OP_SELL)) > 0.0090 // per questo motivo ho bisogno di mantenere l'ultimo ordine aperto per comprare e l'ultimo ordine aperto per vendere, quindi ho bisogno di un ultimo ordine separato uno per comprare e l'altro per vendere.

Puoi farlo . . funzionerà . . prova.
 
O forse intendi l'ultimo ordine BUY che ora è chiuso?
 

la spiegazione della funzione n.4 è chiara?

funzione numero 4:

// voglio ottenere l'ordine chiuso prima dell'ultimo ordine chiuso whatover comprare o vendere.

4- funzione per ottenere e mantenere il precedente prezzo di chiusura prima dell'ultimo ordine chiuso whatover comprare o vendere. grazie

 

ragazzi,

Non funziona davvero

// Used to keep global variables

extern int MagicNumberLong = 6658641;                     //Identifies long positions
extern int MagicNumberShort = 4167090;                    //Identifies short positions
  
 






double LastOpenPrice(int ordertype)
   { 

   double OpenPrice;                         
   datetime lastOpen;
   for ( int pos = OrdersTotal()- 1 ; pos >= 0 ; pos--)
      if ( OrderSelect (pos, SELECT_BY_POS) // Only my orders w/
      && OrderMagicNumber() == MagicNumberLong || MagicNumberShort // my magic number       //  <-------  what Magic Number do you use when you place a trade ?  it must match  ! !
      && OrderSymbol() == Symbol()    // and my pair.                  //            magic.number  should be a Globally defined variable that has your Magic Numer  
      && OrderType() == ordertype 
      && OrderOpenTime() > lastOpen )
         {
         OpenPrice = OrderOpenPrice();
         break;
         }
   return (OpenPrice);                                             //  <-------  this returns the Order Open Price  NOT the ticket
}

if (  ((iOpen("EURUSD",PERIOD_H1,0)-0.0030)>=MarketInfo("EURUSD",MODE_BID))   ) 
  {   BUY("EURUSD",B_EURUSD_LS_0,B_EURUSD_TP_0,B_EURUSD_SL_0,B_EURUSD_TS_0,"if (  ( ((iOpen(EURUSD,PERIOD_H1,0)-0.00...") ;}
if (  ( (LastOpenPrice(OP_BUY)-0.0030)>MarketInfo("EURUSD",MODE_BID) )  ) 
   {  SELL("EURUSD",S_EURUSD_LS_1,S_EURUSD_TP_1,S_EURUSD_SL_1,S_EURUSD_TS_1,"if (  ( (LastOpenPrice(OP_BUY)-0.0030)>=MarketInfo(" EURUSD",MODE_BID) )  )") ;}
if (  ( ((iOpen("EURUSD",PERIOD_H1,0)+0.0030)<=MarketInfo("EURUSD",MODE_BID)) )  ) 
  {   SELL("EURUSD",S_EURUSD_LS_0,S_EURUSD_TP_0,S_EURUSD_SL_0,S_EURUSD_TS_0,"if (  ((iOpen(EURUSD,PERIOD_H1,0)+0.00...") ;}
if (  ( (LastOpenPrice(OP_SELL)+0.0030)<MarketInfo("EURUSD",MODE_BID) )  ) 
   {  BUY("EURUSD",B_EURUSD_LS_1,B_EURUSD_TP_1,B_EURUSD_SL_1,B_EURUSD_TS_1,"if (  ( (LastOpenPrice(OP_SELL)+0.0030)<MarketInfo(" EURUSD",MODE_BID) )") ;}

Come potete vedere nelle immagini

ho iniziato a testare l'EA dal 01/03/2011 al 11/04/2011

nella prima ora del 01/03/2011

la posizione è stata aperta ma nessuno delle condizioni sopra citate era disponibile. questo mi ha fatto davvero impazzire

 
Hand:

la spiegazione della funzione n.4 è chiara?

funzione numero 4:

// voglio ottenere l'ordine chiuso prima dell'ultimo ordine chiuso whatover comprare o vendere.

4- funzione per ottenere e mantenere il precedente prezzo di chiusura prima dell'ultimo ordine chiuso whatover comprare o vendere. grazie

Prezzo di chiusura ? prezzo di chiusura della barra prima della barra in cui si è chiuso l'ultimo ordine ? o il prezzo di chiusura dell'ordine di acquisto o vendita che ha chiuso prima dell'ultimo che ha chiuso ?
 

la seconda opzione:

il prezzo di chiusura dell'ordine del Buy o Sell che ha chiuso prima dell'ultimo che ha chiuso ?

 
Hand:

la seconda opzione:

il prezzo di chiusura dell'ordine del Buy o Sell che ha chiuso prima dell'ultimo che ha chiuso ?

Prova questo...

Per ottenere l'ultimo prezzo di chiusura dell'ultimo ordine che era un acquisto o una vendita e che corrispondeva al simbolo e al numero magico, fate così LastClosePrice(1)

Per ottenere quello precedente, fai così... LastClosePrice(2 )

double LastClosePrice(int Order)
   { 
 
   double ClosePrice;                         

   for ( int pos = OrdersHistoryTotal()- 1 ; pos >= 0 ; pos--)
      if ( OrderSelect (pos, SELECT_BY_POS, MODE_HISTORY)            // Only my CLOSED  orders 
      && OrderMagicNumber() == magic.number // my magic number       //  <-------  what Magic Number do you use when you place a trade ?  it must match  ! !
      && OrderSymbol() == Symbol()  // and my pair.                  //            magic.number  should be a Globally defined variable that has your Magic Numer  
      && OrderType() < OP_BUYLIMIT )
         {
         Order--;
         if (Order == 0)                                            //  determines if we have found the Order we are interested in
            {
            ClosePrice = OrderCloseprice();
            break;
            }
         }
   return (ClosePrice);                                             //  <-------  this returns the Order Open Price  NOT the ticket
}

NOTA: questo codice NON FUNZIONERA' con i tuoi numeri magici come mostrato nel tuo codice sopra . . .

extern int MagicNumberLong = 6658641;                     //Identifies long positions
extern int MagicNumberShort = 4167090; 


WHY ? ? ? ?
 

Ragazzi.

C'è qualcuno che può usare il programma teamviewer e poi potremo accedere insieme e controllare qual è il vero problema.

 
Hand:

ragazzi,

Non funziona davvero

Come potete vedere nelle immagini

ho iniziato a testare l'EA dal 01/03/2011 al 11/04/2011

nella prima ora del 01/03/2011

la posizione è stata aperta ma nessuno delle condizioni sopra citate era disponibile. questo mi ha fatto davvero impazzire

Non è pazzo. E' "ragionevole" che un ordine venga aperto perché:

double LastOpenPrice(int ordertype)
   { 

   double OpenPrice;                         
   datetime lastOpen;
   for ( int pos = OrdersTotal()- 1 ; pos >= 0 ; pos--)
      if ( OrderSelect (pos, SELECT_BY_POS) // Only my orders w/
      && OrderMagicNumber() == MagicNumberLong || MagicNumberShort // my magic number       
      && OrderSymbol() == Symbol()    // and my pair.             
      && OrderType() == ordertype 
      && OrderOpenTime() > lastOpen )
         {
         OpenPrice = OrderOpenPrice();
         break;
         }
   return (OpenPrice); //  <-------  this returns the Order Open Price OR ZERO.

Se la funzione di cui sopra restituisce ZERO, allora può verificarsi qualsiasi scenario come quello qui sotto

 if (  ( (LastOpenPrice(OP_SELL)+0.0030)<MarketInfo("EURUSD",MODE_BID) )  ) <--------------- 0+0.0030=0.0030<Bid: TRUE
   {  BUY("EURUSD",B_EURUSD_LS_1,B_EURUSD_TP_1,B_EURUSD_SL_1,B_EURUSD_TS_1,"if (

Ti suggerisco di mettere una logica "master", al di là di questo. Se la funzione LastOpenPrice(...) restituisce zero.... qual è il tuo piano di gioco?

Motivazione: