Changing the values of extern variables not updated

 

Hi,


I have an existing indicator where I added a new bool extern variable. For some reason when I change it when the indicator is running, the code still thinks it is the default value of when it was declared. There is nothing in my code that changes the variable state. I am only reading it. Also, if I change the default value that was first declared, then that value is used when the indicator runs regardless of what the user had selected and saved with the template.


Has anyone run across this before?


Thanks for any help.


--Lenard

 
It would help if u show your code... (and please use the SRC button).
 

Hi Gordon,

Sorry for the delay. Enclosed is the indicator.


I modified the code with two changes: I added the "testState" extern variable and a print statement to show the extern variable states. It is best to disconnect from a live feed for this test. To reproduce the problem, do as follows:

  1. Create a new chart and add the attached indicator.
  2. Change the indicators TimeFrame variable from 0 to 60.
  3. Switch to the M30 view.
  4. Start terminal and select the Experts tab.
  5. Note the initialized outputs for the M30 and H1 view. For this test, only concentrate on the last 2 digits.
  6. It will show "xxxx10" where the "1" is for the "alertsAfterBarClose" variable and 0 for the "testState" variable. The " - 60" is the "TimeFrame" variable of the indicator and not the view timeframe.
  7. The outputs for both view timeframes will be the same.
  8. Now change the "testState" state to true.
  9. Note how they are NOT the same for both views (i.e., M30 and H1)
  10. Now change the "alertsAfterBarClose" to false.
  11. Note how they ARE the same for both views (as they should be).
  12. Why does it work properly with one variable but not the other?

Am I missing something?

Thanks for any help you can provide.

--Lenard

 
lenardd:
  1. Why does it work properly with one variable but not the other?
When TF <> Period() it executes
         sslHup[i] = iCustom(NULL,TimeFrame,IndicatorFileName,Lb,sslMA_method,SSL_BarLevel,alertsOn,alertsMessageBox,
                                          alertsSound,alertsSoundFile,alertsEmail,alertsAfterBarClose,0,y);
Which does not have all the externals
extern bool alertsAfterBarClose  = true;
extern bool testState = false;
extern int     TimeFrame    =  0;
extern string  TimeFrames   = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";
extern string  MA_method_   = "SMA0 EMA1 SMMA2 LWMA3";
 

WHRoeader,


Thanks for pointing it out.


I knew it was going to be something really silly. :)


--Lenard
Reason: