Risposta

Funzione TrailingStop - discutibile

5 risposte

Mike H.

Abbonato, bbp_partecipante, comunità, 76 risposte.

Visita il profilo

9 anni fa #112526

Quando ho visualizzato la funzione TrailingStop nell'Editor, ho notato che il codice era identico

sia per il tipo di ordine BUY che per il tipo di ordine SELL.

 

Mi chiedevo perché le mie regole di TrailingStop per i miei SHORT TRADES non si attivassero...

 

Di seguito viene mostrato come l'EA Wizard scrive la funzione: (ho sottolineato i segmenti in questione) (notare i diversi MagicNumbers)

 

double getOrderTrailingStop(int orderMagicNumber, int orderType, double price) {
   doppio valore = 0;
   if(orderMagicNumber == 2456) {
      valore = ( 11 * getPointCoef(orderMagicNumber));
      if(valore > 0) {
         if(orderType == OP_BUY || orderType == OP_BUYSTOP || orderType == OP_BUYLIMIT) {        
            valore = Offerta - valore;
         } else {
            valore = Ask + valore;
         }
      }

 

Lo stesso vale per OrderBreakEven:
   }
   if(orderMagicNumber == 3798) {
      valore = ( 11 * getPointCoef(orderMagicNumber));
      if(valore > 0) {
         if(orderType == OP_BUY || orderType == OP_BUYSTOP || orderType == OP_BUYLIMIT) {        
            valore = Offerta - valore;
         } else {
            valore = Ask + valore;
         }
      }
   }
   return(NormalizeDouble(value, Digits));
}
 

Lo stesso vale per OrderBreakEven:

 

double getOrderBreakEven(int orderMagicNumber, int orderType, double price) {
   doppio valore = 0;
   if(orderMagicNumber == 2456) {
      valore = ( 7 * getPointCoef(orderMagicNumber));
      if(valore > 0) {
         if(orderType == OP_BUY || orderType == OP_BUYSTOP || orderType == OP_BUYLIMIT) {
            valore = Offerta - valore;
         } else {
            valore = Ask + valore;
         }
      }
   }
   if(orderMagicNumber == 3798) {
      valore = ( 7 * getPointCoef(orderMagicNumber));
      if(valore > 0) {
         if(orderType == OP_BUY || orderType == OP_BUYSTOP || orderType == OP_BUYLIMIT) {
            valore = Offerta - valore;
         } else {
            valore = Ask + valore;
         }
      }
   }
   return(NormalizeDouble(value, Digits));
}
 

Caro Mark, Invece di dover aspettare l'aggiornamento della procedura guidata di EA, potresti mostrarmi come apportare le modifiche nell'editor?

 

??? Cambiare BUY in SELL e il valore = ????

0

Mike H.

Abbonato, bbp_partecipante, comunità, 76 risposte.

Visita il profilo

9 anni fa #126086

Caro Mark, non potevo aspettare, quindi ho già fatto le modifiche necessarie...

 

   if(orderMagicNumber == 3978) {
      valore = ( 11 * getPointCoef(orderMagicNumber));
      if(valore > 0) {
         se(orderType == OP_SELL || orderType == OP_SELLSTOP || orderType == OP_SELLLIMIT) {
            valore = Ask + valore;
         } else {
            valore = Offerta - valore;
 

   if(orderMagicNumber == 3798) {
      valore = ( 0 * getPointCoef(orderMagicNumber));
      if(valore > 0) {
         se(orderType == OP_SELL || orderType == OP_SELLSTOP || orderType == OP_SELLLIMIT) {
            valore = Ask + valore;
         } else {
            valore = Offerta - valore;
 

 

Le funzioni TrailingStop e BreakEven funzionano bene...

 

Più tardi, Mike H.

0

Mark Fric

Amministratore, sq-ultimate, 2 risposte.

Visita il profilo

9 anni fa #126096

Ciao Mike,

 

Mi dispiace, ma ioSe non mi sbaglio questi sono funzionalmente equivalenti.

 

se(orderType == OP_SELL || orderType == OP_SELLSTOP || orderType == OP_SELLLIMIT) {
   valore = Ask + valore;
} else {
   valore = Offerta - valore;

}

 

è funzionalmente uguale a:

 

if(orderType == OP_BUY || orderType == OP_BUYSTOP || orderType == OP_BUYLIMIT) {

   valore = Offerta - valore;
} else {
   valore = Ask + valore;
}

 

La condizione If riconosce se l'ordine è di acquisto o di vendita e utilizza il valore appropriato. Quello che avete fatto è cambiare solo il controllo, ma dovrebbe funzionare esattamente allo stesso modo.

 

Quindi, se improvvisamente funziona, forse è stato causato da qualcosa di diverso da questo.

Marchio
Architetto StrategyQuant

0

Mike H.

Abbonato, bbp_partecipante, comunità, 76 risposte.

Visita il profilo

9 anni fa #126108

Ciao Mark, Il primo post di questo topic mostra come l'EA Wizard produce il codice...

L'EA Wizard produce il codice come segue:

 

double getOrderTrailingStop(int orderMagicNumber, int orderType, double price) {
   doppio valore = 0;
   if(orderMagicNumber == 2456) {
      valore = ( 11 * getPointCoef(orderMagicNumber));
      if(valore > 0) {
         if(orderType == OP_BUY || orderType == OP_BUYSTOP || orderType == OP_BUYLIMIT) {        
            valore = Offerta - valore;
         } else {
            valore = Ask + valore;
         }
      }

 

Lo stesso vale per OrderBreakEven:
   }
   if(orderMagicNumber == 3798) {
      valore = ( 11 * getPointCoef(orderMagicNumber));
      if(valore > 0) {
         if(orderType == OP_BUY || orderType == OP_BUYSTOP || orderType == OP_BUYLIMIT) {        
            valore = Offerta - valore;
         } else {
            valore = Ask + valore;
         }
      }
   }
   return(NormalizeDouble(value, Digits));
}

 

Quello che vedo è che non c'è una condizione di VENDITA... I due IF sono identici...

Qui sopra è riportato il modo in cui l'EA Wizard scrive il codice >>> IF identici sottolineati per numeri magici diversi...

0

Mark Fric

Amministratore, sq-ultimate, 2 risposte.

Visita il profilo

9 anni fa #126147

Sì, ma la logica è corretta. Se l'ordine è di acquisto, il prezzo viene calcolato in un modo, altrimenti (l'ordine deve essere di vendita) il prezzo viene calcolato in un altro modo.

 

 

 if(orderType == OP_BUY || orderType == OP_BUYSTOP || orderType == OP_BUYLIMIT) {  

  significa che si tratta di un ordine di acquisto

  …

} else {

  significa che si tratta di un ordine di vendita

  …

}

 

Non sembra esserci alcun errore nell'EA, che è stato testato su entrambi i lati.

Marchio
Architetto StrategyQuant

0

Mike H.

Abbonato, bbp_partecipante, comunità, 76 risposte.

Visita il profilo

9 anni fa #126157

Ora lo vedo e lo capisco... Grazie Mark!!!

0

Stai visualizzando 5 risposte - da 1 a 5 (di 5 totali)