'if' - expressions are not allowed on a global scope

Post Reply
sheriffonline
Posts: 6
Joined: Fri Aug 28, 2015 8:09 pm

'if' - expressions are not allowed on a global scope

Post by sheriffonline »

Code: Select all

double   round_down(    double v, double to){   return to * MathFloor(v / to); }
/// Round a double to a multiple of an amount.
double   round_up(      double v, double to){   return to * MathCeil( v / to); }
/// Round a double to a multiple of an amount.
double   round_nearest( double v, double to){   return to * MathRound(v / to); }

int      pips_to_points(double n){           if( (_Digits&1) == 1)   n *= 10.0;
                                             return int(n);                    }
double   points_to_change(int n){            return n * _Point;                }
double   pips_to_change(double n){  return points_to_change(pips_to_points(n));}

double price = Bid;                                       // 1.11xxx
double next100 =  round_up( price, pips_to_change(100) ); // 1.1200
double prev50  =  next100 - pips_to_change(50);           // 1.1150
if(prev50 <= price) // current price is above 1.1150
Comment(Close[0]);
what could be the problom to resolve?
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

'if' - expressions are not allowed on a global scope

Post by milanese »

sheriffonline » Mon Oct 12, 2015 3:13 pm wrote:

Code: Select all

double   round_down(    double v, double to){   return to * MathFloor(v / to); }
/// Round a double to a multiple of an amount.
double   round_up(      double v, double to){   return to * MathCeil( v / to); }
/// Round a double to a multiple of an amount.
double   round_nearest( double v, double to){   return to * MathRound(v / to); }

int      pips_to_points(double n){           if( (_Digits&1) == 1)   n *= 10.0;
                                             return int(n);                    }
double   points_to_change(int n){            return n * _Point;                }
double   pips_to_change(double n){  return points_to_change(pips_to_points(n));}

double price = Bid;                                       // 1.11xxx
double next100 =  round_up( price, pips_to_change(100) ); // 1.1200
double prev50  =  next100 - pips_to_change(50);           // 1.1150
if(prev50 <= price) // current price is above 1.1150
Comment(Close[0]);
what could be the problom to resolve?
Your if expression is outside of a function, that is why you get this error...

Cheers :)

Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
Post Reply

Return to “Coders Hangout”