stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

'if' - expressions are not allowed on a global scope
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4449
Page 1 of 1
Author:  sheriffonline [ Mon Oct 12, 2015 3:13 pm ]
Post subject:  'if' - expressions are not allowed on a global scope

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?
Author:  milanese [ Mon Oct 12, 2015 4:36 pm ]
Post subject:  'if' - expressions are not allowed on a global scope

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
All times are UTC Page 1 of 1