Problemi di chiusura, per favore aiutatemi - pagina 6

 
////////////////////////////////////////////////////////////////////<         1>
// < Program : Property >                                         //<          >
//   #define   1    " "                                           //<          >
//   #define   2    " "                                           //<          >
// </Program : Property >                                         //<          >
//                                                                //<          >
//                                                                //<          >
// < Program : Content >                                          //<          >
//                                                                //<          >
// < Structure             15 elements  in      3 domains       > //<          >
// < 1. Data                7 elements  in      1 domains      /> //<          >
// < 2. Code                8 elements  in      2 domains      /> //<          >
// </Structure             15 elements  in      3 domains       > //<          >
//                                                                //<          >
// < 1. Data                7 =       4 i       3 d       - s   > //<          >
// < 1.1. Input             7 =       4 i       3 d       - s  /> //<          >
// </1. Data                7 =       4 i       3 d       - s   > //<          >
//                                                                //<          >
// < 2. Code                8 /       - i      77 l       3 o   > //<          >
// < 2.1. Interface         5 /       - i      66 l       3 o  /> //<          >
// < 2.2. Special           3 /       - i      11 l       - o  /> //<          >
// </2. Code                8 /       - i      77 l       3 o   > //<          >
//                                                                //<          >
// </Program : Content >                                          //<          >
     

////////////////////////////////////////////////////////////////////<         2>
// < 1.1. Data : Input >                                          //<          >
//                                                                //<          >
// < 1.1. Input             7 =       4 i       3 d       - s   > //<          >
// <      1. Strategy       4 =       2 i       2 d       - s  /> //<          >
// <      2. Trading        3 =       2 i       1 d       - s  /> //<          >
// </1.1. Input             7 =       4 i       3 d       - s   > //<          >
//                                                                //<          >
// <      1. Strategy 4 >=========================================//<          >
                    int       iBaseLag          = 20            ; //<          >
                    int       iBaseBar          = 1             ; //<          >
                    double    dFactorTP         = 1.0           ; //<          >
                    double    dFactorSL         = 2.0           ; //<          >
// </     1. Strategy 4 >=========================================//<          >
//                                                                //<          >
// <      2. Trading 3 >==========================================//<          >
                    int       iSlippage         = 1             ; //<          >
                    int       iMagic            = 1             ; //<          >
                    double    dLots             = 0.1           ; //<          >
// </     2. Trading 3 >==========================================//<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
// </1.1. Data : Input >                                          //<          >
     
 
////////////////////////////////////////////////////////////////////<         3>
// < 2.1. Code : Interface >                                      //<          >
//                                                                //<          >
// < 2.1. Interface         5 /       - i      66 l       3 o   > //<          >
// <      1. iSignalOpen              - i      14 l       1 o  /> //<          >
// <      2. iSignalClose             - i      15 l       1 o  /> //<          >
// <      3. iGetTicket               - i       7 l       1 o  /> //<          >
// <      4. iTryOpen                 - i      15 l       - o  /> //<          >
// <      5. iTryClose                - i      15 l       - o  /> //<          >
// </2.1. Interface         5 /       - i      66 l       3 o   > //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
// </2.1. Code : Interface >                                      //<          >
     

////////////////////////////////////////////////////////////////////<         4>
// < 2.1.1. Code : Interface : iSignalOpen >                      //<          >
int       iSignalOpen ()     //       - i      14 l       1 o     //<          >
{                                                                 //<          >
static    int       iTime_0 = EMPTY                             ; //<          >
if      (           iTime_0 < iTime   ( 0 , 0 , 0 ) )             //<          >
        {           iTime_0 = iTime   ( 0 , 0 , 0 )             ; //<          >
          static    double    dHighest , dLowest                ; //<          >
//                                                                //<          >
          dHighest = High   [ iHighest ( 0 , 0    , MODE_HIGH ,   //<          >
                              iBaseLag , iBaseBar           ) ] ; //<          >
//                                                                //<          >
          dLowest  = Low    [ iLowest  ( 0 , 0    , MODE_LOW  ,   //<          >
                              iBaseLag , iBaseBar           ) ] ; //<          >
        } // if                                                   //<          >
//                                                                //<          >
double    dAsk    = MarketInfo        ( Symbol () , MODE_ASK  ) ; //<          >
double    dBid    = MarketInfo        ( Symbol () , MODE_BID  ) ; //<          >
//                                                                //<          >
if      ( dAsk    > dHighest )          return    ( OP_BUY    ) ; //<          >
if      ( dBid    < dLowest  )          return    ( OP_SELL   ) ; //<          >
                                        return    ( EMPTY     ) ; //<          >
}                                                                 //<          >
// </2.1.1. Code : Interface : iSignalOpen >                      //<          >
     
 
////////////////////////////////////////////////////////////////////<         5>
// < 2.1.2. Code : Interface : iSignalClose >                     //<          >
int       iSignalClose ()    //       - i      15 l       1 o     //<          >
{                                                                 //<          >
static    int       iTime_0 = EMPTY                             ; //<          >
if      (           iTime_0 < iTime   ( 0 , 0 , 0 ) )             //<          >
        {           iTime_0 = iTime   ( 0 , 0 , 0 )             ; //<          >
          static    double    dATR    , dProfit  , dLoss        ; //<          >
          dATR    = iATR    ( 0 , 0   , iBaseLag , iBaseBar   ) ; //<          >
        } // if                                                   //<          >
//                                                                //<          >
double    dDelta  = OrderOpenPrice () - OrderClosePrice ()      ; //<          >
//                                                                //<          >
if      ( OrderType ()     == OP_BUY  )                           //<          >
        { dProfit = -dDelta ; dLoss  =  dDelta                ; } //<          >
else if ( OrderType ()     == OP_SELL )                           //<          >
        { dProfit =  dDelta ; dLoss  = -dDelta                ; } //<          >
else                                    return    ( EMPTY     ) ; //<          >
//                                                                //<          >
if      ( dProfit > dATR * dFactorTP )  return    ( TRUE      ) ; //<          >
if      ( dLoss   > dATR * dFactorSL )  return    ( TRUE      ) ; //<          >
                                        return    ( EMPTY     ) ; //<          >
}                                                                 //<          >
// </2.1.2. Code : Interface : iSignalClose >                     //<          >
     

////////////////////////////////////////////////////////////////////<         6>
// < 2.1.3. Code : Interface : iGetTicket >                       //<          >
int       iGetTicket ()      //       - i       7 l       1 o     //<          >
{                                                                 //<          >
for     ( int i   = OrdersTotal () - 1 ; i >= 0 ; i -- )          //<          >
        {                                                         //<          >
          if      ( OrderSelect ( i , SELECT_BY_POS ) == TRUE   ) //<          >
          if      ( OrderMagicNumber ()               == iMagic ) //<          >
                                      return ( OrderTicket () ) ; //<          >
        } // for                                                  //<          >
                                      return ( EMPTY          ) ; //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
}                                                                 //<          >
// </2.1.3. Code : Interface : iGetTicket >                       //<          >
     
 
////////////////////////////////////////////////////////////////////<         7>
// < 2.1.4. Code : Interface : iTryOpen >                         //<          >
int       iTryOpen ()        //       - i      15 l       - o     //<          >
{                                                                 //<          >
int       iCommand          = iSignalOpen ()                    ; //<          >
if      ( iCommand         == EMPTY  )                return    ; //<          >
if      ( iCommand         == OP_BUY )                            //<          >
        { string    sType   = "Buy"  ;  int  iColor = Blue    ; } //<          >
else    {           sType   = "Sell" ;       iColor = Red     ; } //<          >
//                                                                //<          >
if      ( iCommand         == OP_BUY )  int  iMode  = MODE_ASK  ; //<          >
                                        else iMode  = MODE_BID  ; //<          >
double    dPrice  = MarketInfo ( Symbol () , iMode            ) ; //<          >
//                                                                //<          >
OrderSend  ( Symbol ()       , iCommand             , dLots   ,   //<          >
             NormalizeDouble ( dPrice , Digits )              ,   //<          >
             iSlippage  , 0  , 0 , "" , iMagic , 0  , iColor  ) ; //<          >
//                                                                //<          >
int       iTrap   = GetLastError ()                             ; //<          >
if      ( iTrap  == 0 )                                           //<          >
          Alert   ( sType , " Was a Big Success"              ) ; //<          >
else      Alert   ( sType , " open exception "      , iTrap   ) ; //<          >
}                                                                 //<          >
// </2.1.4. Code : Interface : iTryOpen >                         //<          >
     

////////////////////////////////////////////////////////////////////<         8>
// < 2.1.5. Code : Interface : iTryClose >                        //<          >
int       iTryClose ()       //       - i      15 l       - o     //<          >
{                                                                 //<          >
int       iCommand          = iSignalClose ()                   ; //<          >
if      ( iCommand         == EMPTY  )                return    ; //<          >
if      ( OrderType ()     == OP_BUY )                            //<          >
        { string    sType   = "Buy"  ;  int  iColor = Red     ; } //<          >
else    {           sType   = "Sell" ;       iColor = Blue    ; } //<          >
//                                                                //<          >
if      ( OrderProfit ()    > 0      )  string sAct = "Take"    ; //<          >
                                        else   sAct = "Stop"    ; //<          >
double    dPrice  = OrderClosePrice ()                          ; //<          >
//                                                                //<          >
OrderClose ( OrderTicket ()  , OrderLots ()                   ,   //<          >
             NormalizeDouble ( dPrice , Digits )              ,   //<          >
             iSlippage                              , iColor  ) ; //<          >
//                                                                //<          >
int       iTrap   = GetLastError ()                             ; //<          >
if      ( iTrap  == 0 )                                           //<          >
          Alert   ( sType , " closed with Hard "    , sAct    ) ; //<          >
else      Alert   ( sType , " close exception "     , iTrap   ) ; //<          >
}                                                                 //<          >
// </2.1.5. Code : Interface : iTryClose >                        //<          >
     
 
////////////////////////////////////////////////////////////////////<         9>
// < 2.2. Code : Special >                                        //<          >
//                                                                //<          >
// < 2.2. Special           3 /       - i      11 l       - o   > //<          >
// <      1. init                     - i       1 l       - o  /> //<          >
// <      2. deinit                   - i       1 l       - o  /> //<          >
// <      3. start                    - i       9 l       - o  /> //<          >
// </2.2. Special           3 /       - i      11 l       - o   > //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
// </2.2. Code : Special >                                        //<          >
     

////////////////////////////////////////////////////////////////////<        10>
// < 2.2.1. Code : Special : Init >                               //<          >
int       init    ()         //       - i       1 l       - o     //<          >
{                                                                 //<          >
Alert   ( ""               , "Start " , UninitializeReason () ) ; //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
}                                                                 //<          >
// </2.2.1. Code : Special : Init >                               //<          >
     
 
////////////////////////////////////////////////////////////////////<        11>
// < 2.2.2. Code : Special : Deinit >                             //<          >
int       deinit  ()         //       - i       1 l       - o     //<          >
{                                                                 //<          >
Alert   ( ""               , "Stop "  , UninitializeReason () ) ; //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
//                                                                //<          >
}                                                                 //<          >
// </2.2.2. Code : Special : Deinit >                             //<          >
     

////////////////////////////////////////////////////////////////////<        12>
// < 2.2.3. Code : Special : Start >                              //<          >
int       start   ()         //       - i       9 l       - o     //<          >
{                                                                 //<          >
// < 2.2.3.1. History data inspection 4 >`````````````````````````//<          >
static    int       iTrigger   = 0       ; if ( iTrigger == 0 ) { //<          >
  if  ( ( iTime ( 0 , 0 , 0 ) == 0                          )     //<          >
  ||    ( iBars ( 0 , 0     )  < iBaseLag     + iBaseBar    ) )   //<          >
          return                         ; else iTrigger  = 1 ; } //<          >
// </2.2.3.1. History data inspection 4 >`````````````````````````//<          >
//                                                                //<          >
// < 2.2.3.2. Main routine 3 >````````````````````````````````````//<          >
int       iTicket           = iGetTicket ()                     ; //<          >
//                                                                //<          >
if      ( iTicket < 0 )       iTryOpen   ()                     ; //<          >
else                          iTryClose  ()                     ; //<          >
// </2.2.3.2. Main routine 3 >````````````````````````````````````//<          >
//                                                                //<          >
// < 2.2.3.3. Exception handler 2 >```````````````````````````````//<          >
int       iTrap   =           GetLastError ()                   ; //<          >
if      ( iTrap   > 0 )       Alert  ( "Exception " , iTrap   ) ; //<          >
// </2.2.3.3. Exception handler 2 >```````````````````````````````//<          >
}                                                                 //<          >
// </2.2.3. Code : Special : Start >                              //<          >
////////////////////////////////////////////////////////////////////<         0>
     
 

Elenco completo dei cambiamenti:

1. Il valore iniziale del fattore di profitto virtuale "double dFactorTP = 1.0 ;" è stato cambiato.
2. Il dominio "Dati : Buffer" è stato cancellato.
3. La funzione "iNewBar ()" è stata eliminata.
4. La funzione "iSignalOpen ()" è stata modificata.
5. La funzione "iSignalClose ()" è stata cambiata.

Ultima modifica: 2010.03.18 20:47
Stato: Pronto

File:
1_26.mq4  24 kb
 
Ais,
Grazie per aver condiviso il tuo sistema...
Questo è un sistema di codifica che hai lì. hai una disciplina incredibile :) lo scrivi in excel, per farlo allineare?
 
cameofx:
Ais,
Grazie per aver condiviso il tuo sistema...
Questo è un sistema di codifica che hai lì. hai una disciplina incredibile :) lo scrivi in excel, per farlo allineare?

forse è una domanda stupida, ma sono curioso come l'inferno :))

PS. Huckleberry grazie per continuare questo.

 

Ciao Cameofx,
Grazie per la gentile risposta.
Questo sistema di codifica è molto semplice e facile.
Tutto fatto manualmente in MetaEditor.
Infatti, il sistema è stato progettato per sviluppare grandi programmi facilmente e con alta velocità.
Il sistema dovrebbe essere anche flessibile e affidabile.
Cordiali saluti!

Motivazione: