Fractal Break Out-Stuck - pagina 4

 
for(int i=OrdersTotal()-1; i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)  break;


if(OrderMagicNumber()!=MagicNumber || OrderSymbol() !=Symbol()) continue;

double SL=OrderStopLoss();
bool result;
int  error;
//-----The Differnt Order types---//

if(OrderType()==OP_BUY)
{
 if(BreakEven>0)
    {
     if(Bid-OrderOpenPrice() >= Point*BreakEven*mypoint)
      {
       if(OrderStopLoss() <OrderOpenPrice())
         {
          SL=OrderOpenPrice()*Point*mypoint;
          }}}}}

if(SL!=OrderStopLoss()) result=OrderModify(OrderTicket(),OrderOpenPrice(), SL,OrderTakeProfit(),0,CLR_NONE);
if(result!=true){error=GetLastError(); Print("ModifyError=",OrderTicket()," ",error);}

//--------CHECKING FOR ERRORS-------------------//

return(0);
}
}



Ho creato anche il lato di vendita, ma poi l'ho cancellato perché stavo ottenendo errori, quindi ho rimesso quello che deVries mi ha mostrato, ottenendo ancora gli stessi codici di errore.


4051

4108


Inoltre, perché aggiungiamo Point a OrderOpenPrice()=SL ? Questo aggiunge solo le cifre corrette allo stop loss.

 
ZacharyRC:

Ho creato anche il lato di vendita, ma poi l'ho cancellato perché stavo ottenendo errori, quindi ho rimesso quello che mi ha mostrato deVries, ottenendo ancora gli stessi codici di errore.

for(int i=OrdersTotal()-1; i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)  break;


if(OrderMagicNumber()!=MagicNumber || OrderSymbol() !=Symbol()) continue;

double SL=OrderStopLoss();
bool result;
int  error;
//-----The Differnt Order types---//

if(OrderType()==OP_BUY)
{
 if(BreakEven>0)
    {
     if(Bid-OrderOpenPrice() >= Point*BreakEven*mypoint)
      {
       if(OrderStopLoss() <OrderOpenPrice())
         {
          SL=OrderOpenPrice()*Point*mypoint;       // WRONG HERE
          }}}}}

if(SL!=OrderStopLoss()) result=OrderModify(OrderTicket(),OrderOpenPrice(), SL,OrderTakeProfit(),0,CLR_NONE);
if(result!=true){error=GetLastError(); Print("ModifyError=",OrderTicket()," ",error);}
     //Where is the  }  ??
//--------CHECKING FOR ERRORS-------------------//

return(0);
}
}

4051

4108


Inoltre, perché aggiungiamo Point a OrderOpenPrice()=SL? Questo aggiunge solo le cifre corrette allo stop loss.

Guardate di nuovo il mio codice e cambiate la linea rossa

è diversa da quella che ho dato a !!!!

Possiamo vedere il codice come è ora

e il messaggio che si legge dando questi errori

aggiungere un punto a orderopenprice è per evitare di provare a modificare il trade di nuovo a breakevenogni tick

 
deVries:

Guarda di nuovo il mio codice e cambia quella linea rossa

è diversa da quella che ho dato a !!!!

Possiamo vedere il codice come è ora

e il messaggio che si legge dando questi errori

aggiungere un punto a orderopenprice è per evitare di provare a modificare il trade di nuovo a breakeven ogni tick


Sì, ho individuato quell'errore, stavo solo cambiando alcune cose e ho dimenticato di cancellarlo prima di postare il codice. Mi scuso.


//-----------------EXITING ORDERS---------------//

for(int i=OrdersTotal()-1; i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)  break;


if(OrderMagicNumber()!=MagicNumber || OrderSymbol() !=Symbol()) continue;

double SL=OrderStopLoss();
bool result;
int  error;
//-----The Differnt Order types---//

if(OrderType()==OP_BUY)
{
 if(BreakEven>0)
    {
     if(Bid-OrderOpenPrice() >= Point*BreakEven*mypoint)
      {
       if(OrderStopLoss() <OrderOpenPrice())
         {
          SL=OrderOpenPrice()+Point;
          }}}}}
          

if(OrderType()==OP_SELL)
{
 if(OrderOpenPrice()-Ask >= Point*BreakEven*mypoint)
 {
  if(OrderStopLoss()>OrderOpenPrice())
   {
    SL=OrderOpenPrice() + Point;
    
}}}


if(SL != OrderStopLoss()) result=OrderModify(OrderTicket(),OrderOpenPrice(),SL,OrderTakeProfit(),0,CLR_NONE);
         if(result!=TRUE) { error=GetLastError(); Print("ModifyError = ",OrderTicket(),"   ",error);}     
//--------CHECKING FOR ERRORS-------------------//
Print(GetLastError());
return(0);
}
}
 
2013.03.18 17:55:51 2013.03.11 23:59 Tester: order #6 is closed
2013.03.18 17:55:51 2013.03.11 15:48 BreakOutEA EURUSD,M1: 0
2013.03.18 17:55:51 2013.03.11 15:48 BreakOutEA EURUSD,M1: ModifyError = 6 0
2013.03.18 17:55:51 2013.03.11 15:48 BreakOutEA EURUSD,M1: modify #6 buy 0.03 EURUSD at 1.30390 sl: 1.30055 tp: 1.30855 ok
2013.03.18 17:55:51 2013.03.11 15:48 BreakOutEA EURUSD,M1: open #6 buy 0.03 EURUSD at 1.30390 ok
2013.03.18 17:55:51 2013.03.11 15:47 BreakOutEA EURUSD,M1: 0
2013.03.18 17:55:51 2013.03.11 15:47 BreakOutEA EURUSD,M1: ModifyError = 5 4108
2013.03.18 17:55:51 2013.03.11 15:47 BreakOutEA EURUSD,M1: OrderModify error 4108
2013.03.18 17:55:51 2013.03.11 15:47 BreakOutEA EURUSD,M1: ticket 5 sconosciuto per funzione OrderModify
2013.03.18 17:55:51 2013.03.11 15:47 BreakOutEA EURUSD,M1: 0
 
Ok! Quindi per una vendita dovrei anche togliere 1 punto
 
//-----------------EXITING ORDERS---------------//

for(int i=OrdersTotal()-1; i>=0;i--)
   {
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)  break;
   if(OrderMagicNumber()!=MagicNumber || OrderSymbol() !=Symbol()) continue;
   double SL=OrderStopLoss();
   bool result;
   int  error;
   //-----The Differnt Order types---//
   if(OrderType()==OP_BUY)
      {
      if(BreakEven>0)
         {
         if(Bid-OrderOpenPrice() >= Point*BreakEven*mypoint)
            {
            if(OrderStopLoss() <OrderOpenPrice())
               {
               SL=OrderOpenPrice()+Point;
               }}}}   }     //PLACE THE BRACKETS IN LINE OPEN/CLOSE BRACKET AND YOU WILL SEE THE ERROR HERE
          

   if(OrderType()==OP_SELL)
      {
      if(OrderOpenPrice()-Ask >= Point*BreakEven*mypoint)
         {
         if(OrderStopLoss()>OrderOpenPrice())
            {
            SL=OrderOpenPrice() + Point;    //OrderStopLoss has to become point lower then orderopenprice
            }}}


   if(SL != OrderStopLoss()) result=OrderModify(OrderTicket(),OrderOpenPrice(),SL,OrderTakeProfit(),0,CLR_NONE);
         if(result!=TRUE) { error=GetLastError(); Print("ModifyError = ",OrderTicket(),"   ",error);} 
   }    
//--------CHECKING FOR ERRORS-------------------//
Print(GetLastError(
return(0);
}
}

All'interno del ciclo controlliamo ogni modifica per l'errore, non all'esterno del ciclo non sappiamo per quale ordine l'ultimo errore è in questo caso

ultima linea print( getlasterror()) b non è necessario

Mi piace vedere più parentesi in una linea

RaptorUK e non ho messo parentesi di chiusura in questo modo }}}}}}

ora hai fatto degli errori a causa di questo

 
for(int i=OrdersTotal()-1; i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)  break;


if(OrderMagicNumber()!=MagicNumber || OrderSymbol() !=Symbol()) continue;

double SL=OrderStopLoss();
bool result;
int  error;
//-----The Differnt Order types---//

if(OrderType()==OP_BUY)
{
 if(BreakEven>0)
   {
     if(Bid-OrderOpenPrice() >= Point*BreakEven*mypoint)
      {
       if(OrderStopLoss() <OrderOpenPrice())
         {
          SL=OrderOpenPrice()+Point;
}
   }
      }
         }
                  
          

if(OrderType()==OP_SELL)
{
 if(OrderOpenPrice()-Ask >= Point*BreakEven*mypoint)
 {
  if(OrderStopLoss()>OrderOpenPrice())
   {
    SL=OrderOpenPrice() - Point;
    
}
 }
   }


if(SL != OrderStopLoss()) result=OrderModify(OrderTicket(),OrderOpenPrice(),SL,OrderTakeProfit(),0,CLR_NONE);
         if(result!=TRUE) { error=GetLastError(); Print("ModifyError = ",OrderTicket(),"   ",error);}     
}
return(0);
}
}




È questo l'ordine che stai richiedendo per le parentesi di apertura e chiusura {{{ }}}?

Questo è stato un problema per me, mi sento molto disorganizzato all'interno del codice.

 

Nessun errore ora, ma nel backtest visivo, lo SL non viene spostato. Avevo fiducia in questo, ma ora fa male, mi scuso per dipendere così tanto dalla bacheca.

Le parentesi erano l'errore, ma ancora non funziona correttamente.



Ho anche riletto il libro.

 
if(OrderType()==OP_BUY){

 if(BreakEven>0){
   
     if(Bid-OrderOpenPrice() >=BreakEven*mypoint*Point){
      
       if(OrderStopLoss() <OrderOpenPrice()){
         
          SL=OrderOpenPrice()+Point;
}
  }
     }
       }
                  

Penso che anche questo mi aiuterà, mettendo le staffe direttamente sotto l'operatore.
 
ZacharyRC:
Penso che anche questo mi aiuterà, mettendo le parentesi direttamente sotto l'operatore.

A me sembra orribile, ma se per te ha senso, allora è fantastico. Io lo faccio così, così il rientro mostra dove si trova un blocco...

if(OrderType()==OP_BUY)
   {
   if(BreakEven>0)
      {
      if(Bid-OrderOpenPrice() >=BreakEven*mypoint*Point)
         {
         if(OrderStopLoss() <OrderOpenPrice())
            {
            SL=OrderOpenPrice()+Point;
            }
         }
      }
   }

o fare così . . .

if(OrderType() == OP_BUY && BreakEven > 0 && 
   Bid - OrderOpenPrice() >= BreakEven * mypoint * Point &&
   OrderStopLoss() < OrderOpenPrice() )
   {
   SL = OrderOpenPrice() + Point;
   }