Come posso impostare il TP a meno di 5 pip? - pagina 5

 
Intendi da questa parte?
extern double TPforBuys=1;
extern double TPforSells=1;
extern double TimeForEA=120;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{

return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{

return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
for(int a=OrdersTotal()-1;a>=0;a--)

double TPbuy = TPforBuys / 10000;
if( OrderSelect(a,SELECT_BY_POS, MODE_TRADES) && 
      OrderType()==OP_BUY && OrderSymbol()==Symbol() )
double TPB=OrderOpenPrice()+ TPbuy;

// Close Buys
if(Bid>TPB)
{
   
      if( OrderSelect(a,SELECT_BY_POS, MODE_TRADES) && 
      OrderType()==OP_BUY && TimeCurrent()-OrderOpenTime() <= (TimeForEA * 60)  &&
      OrderSymbol()==Symbol() )
         if( !OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 1000, White) )
            Print("OrderClose failed, error: ", GetLastError());
            }



double TPsell = TPforSells / 10000;
if( OrderSelect(a,SELECT_BY_POS, MODE_TRADES) && 
      OrderType()==OP_SELL && OrderSymbol()==Symbol() )
double TPS=OrderOpenPrice()- TPsell;



// Close Sells
if(Ask<TPS)
{
   
      if( OrderSelect(a,SELECT_BY_POS, MODE_TRADES) && 
      OrderType()==OP_SELL &&  TimeCurrent()-OrderOpenTime() <= (TimeForEA * 60) &&
      OrderSymbol()==Symbol() )
         if( !OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 1000, White) )
            Print("OrderClose failed, error: ", GetLastError());
            }


return(0);
}
 
ats:
Intendi da questa parte?
Non so. . . fa quello che vuoi?
 
RaptorUK:
Non so. . . fa quello che vuoi?
No. Non lo fa! Non è più corretto!
 
Forse potresti spiegare cosa stai cercando di fare esattamente, a mio beneficio, a beneficio dionewithzachy e, naturalmente, a tuo beneficio.
 

Certo, scusa! Non ci avevo pensato!

Abbiamo fatto questo EA per lo scalping! L'EA dovrebbe chiudere ogni ordine di scalping con 1 pip di profitto! Per non chiudere gli ordini a lungo termine abbiamo usato il comando OrderOpenTime(). Gli ordini di scalping sono impostati manualmente! Agisce come TP ma solo con 1 pip di profitto!

Grazie a tutti

 
Ah, capisco, non vuoi che l'EA chiuda gli ordini non scalping, a breve termine.
 
RaptorUK:
Ah, capisco, non vuoi che l'EA chiuda gli ordini non scalping, a breve termine...
Esattamente!
 

OK, alcuni commenti . . .

1. Il tuo ciclo non fa praticamente nulla, hai bisogno di racchiudere tra parentesi graffe, { } quello che vuoi fare all'interno del ciclo . . .

2. Hai 2 chiamate OrderSelect(), se metti tutto nel ciclo ne avrai bisogno solo di una . ..

3. la sezione close buys dovrebbe essere eseguita solo per gli ordini Buy, la close sells dovrebbe essere eseguita solo per gli ordini Sell

4. il tuo profitto di 1 pip è codificato per coppie a 4 cifre, quindi non funzionerà per coppie come USDJPY

 

Forse qualcosa del genere...

extern double TPforBuys=1;
extern double TPforSells=1;
extern double TimeForEA=120;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{

return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{

return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
for(int a=OrdersTotal()-1;a>=0;a--)
   {
   double TPbuy = TPforBuys / 10000;
   
   if( OrderSelect(a,SELECT_BY_POS, MODE_TRADES) && 
   OrderType()==OP_BUY && OrderSymbol()==Symbol() )  // order type and Symbol checked here
      {
      double TPB=OrderOpenPrice()+ TPbuy;
      
      // Close Buys
      if(Bid>TPB)
         {
         
         if( TimeCurrent()-OrderOpenTime() <= (TimeForEA * 60) )  // no need to check type and symbol here
            if( !OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 1000, White) )
               {
               Print("OrderClose failed, error: ", GetLastError());
               }
            else continue;        // if order has been closed move to the next position, no need to check if it's a SELL
         } // end of if(Bid>TPB)
      } // end of if( OrderSelect(a 
      
   double TPsell = TPforSells / 10000;
   
   if( OrderSelect(a,SELECT_BY_POS, MODE_TRADES) && 
   OrderType()==OP_SELL && OrderSymbol()==Symbol() )
      {
      double TPS=OrderOpenPrice()- TPsell;

      // Close Sells
      if(Ask<TPS)
         {
   
         if( TimeCurrent()-OrderOpenTime() <= (TimeForEA * 60) )
            if( !OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 1000, White) )
               Print("OrderClose failed, error: ", GetLastError());
            
         } // end of if(Ask<TPS)
      } // end of if( OrderSelect(a
   } // end of for(int a=OrdersTotal()

return(0);
}
 
RaptorUK:

Forse qualcosa del genere...

A proposito, non ho compilato o testato questo codice . . .
Motivazione: