short but complex Q: modifying value of preprocesser directives in

 

i am trying to set my indicator scale value (vertical y axis values) as an external variable by changing the values of these (

#property indicator_minimum 25

#property indicator_maximum 75

)

preprocesser directives in the body of the program.

so far i have:

//-----------------BEGIN----------------------

//-----------------------------------------------

#property indicator_minimum 25

#property indicator_maximum 75

extern bool scale = false

//-----------------------------------------------

//-----------------------------------------------

int(start)

if(scale==true)

{

#property indicator_minimum 40;

#property indicator_maximum 50;

}

//-------------------------------------------

//---------------END-----------------------

so i am not even seeking to create a user input for specific indicator scale values only to

create a true false toggle which will change the scale between the default values i have set

in the preprocesser directives and an alternate set of values.

first of all it needs to be acknowledged that there is a compiling error but the program will

run fine nonetheless except it EXECUTES the if statement (changing the scale values regardless

of whether scale==false or scale==true)

is there another way to do this? i am dealing with volatile data and want to focus on specific

segments of indicator activity and the auto-scale is making the areas of interest too small

and insignificant for me to properly see

 
I suspect a clue is in the name . . . pre processor, I don't think you can do what you are looking to do, but I could be wrong.
 

Preprocessor - they are constants.

If you don't use them at all, the window will auto scale.

 
WHRoeder:

Preprocessor - they are constants.

If you don't use them at all, the window will auto scale.


i mentioned that the auto scale isn't useful because there are trending periods of changing volatility in the indicator values, the larger volatility is

scattered with intermittent periods of extremely low volatility which sometimes I want to look closely. the larger volatility affects the autoscale making it too large

diminishing my ability to visually perceive the relative values in areas of low volatility which appear almost like a straight line. when I change scale values,

all the data outside my band is just gone and perception of the periods of low volatility is now possible. due to the nature of the indicator those values during (low vol)

are dependably around a certain range which would represent my "alternate scale" and also the reason I did not need to make external variables for specific scale values

just a external bool variable to toggle between full and zoomed . its not a big deal to edit the scripts each time before, or make two separate indicators. just neither felt

truly correct and wanted to make sure there was not a way. thank you.


as a sidenote is interesting that when the program is executed the if statement is executed despite the condition being false. the mq4 book explains that when the if statement is false

the terminal does not pass control to the body of the if cycle. but since the if statement does execute even when false it must be receiving some (degree) of control... or maybe

during during the compiling stage where we change file types it somehow sets that value? i dont know.

 

at program compile-time your if statement is turned in to this because the code in there is pulled out by the preprocessor.

if(scale==true)
  {
  }

one gets the impression the statement is being executed because these preprocessor directives are the last ones in the source code and over-ride anything prior with the same directive name.

try this

if(scale==true)
  {
  #property indicator_minimum 40;
  #property indicator_maximum 50;
  }
else
  {
  #property indicator_minimum 45;
  #property indicator_maximum 55;
  }

you will always get the appearance the else clause being execute, but it is not, the pre-processor picks up the else as the last definition

sn