Function definition unexpected

 

Hello to All

Thank you in the past for all your help. The help I have received is of course a learning experience for me, but in hopes that others will benefit from my mistakes.

In this problem, an error occurs 'Function definition unexpected' appears after I have modified a previous known good code. The modifications are NOT within the area where the error occurs. I give a portion of the code because when I attempted the first time, the text in the SRC was too long.

The description of the problem is thread, Part one.

Next thread will be the code with ??????????? indentifing the error.

Thanks for reading and for any clarification

Huckleberry

 
/ < 2.1.3. Code : Interface : iSignalClose >                     //<          >
int       iSignalClose ()   //???????????????????????????????????????????????????????????
{                                                                 //<          >
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     ) ; //<          >
}                                                                 //<          >
 
////////////////////////////////////////////////////////////////////<        10>
// < 2.1.6. 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 ) { iTradeBarTime = iTime ( 0 , 0 , 0 ) ;   //<          >
          Alert   ( sType , " closed with Hard "    , sAct  ) ; } //<          >
else    { Alert   ( sType , " close exception "     , iTrap ) ; } //<          >
}                                                                 //<          >
// </2.1.6. Code : Interface : iTryClose >                        //<          >
////////////////////////////////////////////////////////////////////<        11>
 

Thank you in advance for any help

 

Maybe this code was embedded in another function? or maybe the previous function wasn't closes correctly with a "}" ? or maybe an extra "{" was inserted in the previous function?

You see, it might be that this code you included is perfectly correct, but the compiler thinks that it's in an incorrect part of the overall program.

 

Put comments in to show where if statements begin and end for loops begin and end where functions begin and end this helps in debuging this type of error.

 

Hello and thank you for reading,

I can understand that I made a mistake by not disclosing the code completely. I will need to put it in an attachment. Thanks again for any help.

Best Regards

Huckleberry

 
Huckleberry:

Hello and thank you for reading,

I can understand that I made a mistake by not disclosing the code completely. I will need to put it in an attachment. Thanks again for any help.

Best Regards

Huckleberry

// < 2.1.2. Code : Interface : iSignalOpen >                      //<          >
int       iSignalOpen ()     //       - i      17 l       1 o     //<          >
{                                                                 //<          >
if    ( ( iTradeBarTime    == iTime   ( 0 , 0 , 0 ) )             //<          > 
     && ( iTradeBarOnce    == 1 ) )     return    ( EMPTY     ) ; //<          > 
//                                                                //<          >
static    int       iTime_0 = EMPTY                             ; //<          >  
if      (           iTime_0 < iTime   ( 0 , 0 , 0 ) )             //<          > 
        {           iTime_0 = iTime   ( 0 , 0 , 0 )             ; //<          >
          iTradeBarTime     = EMPTY                             ; //<          >
}
bool Buy_Highest=false;                                            // This the area where the
bool Sell_Lowest=false;                                            // modification begins.
                                                                   // Modified
if (High[0] > High[1] && High[1] > High[2] && High[2] > High[3] && // Modified
    High[3] > High[4])                                             // Modified
    return (Buy_Highest=true);                                     // Modified
                                                                   // Modified
if (Low [0] < Low [1] && Low [1] < Low [2] && Low [2] < Low [3] && // Modified
    Low [3] < Low [4])                                             // Modified
    return (Sell_Lowest=true);                                     // Modified 
                                                                   // Modified
    return ( 0 );                                                  // Modified
                                                                   // Modified up to here.
}                                                     

If statement: - missing "}"

And " return (True), not return (Buy_Highest=True)

 

Thank you to all,

My hurried modification induced my own problem. Rafaell, your explanation was clear and to the point. Thank you.

Huckleberry

Reason: