Download MetaTrader 5

INDICATOR_MAXIMUM function not working on visual mode of strategy tester.

To add comments, please log in or register
Share your programs. That will improve your rating.
Young Ho Seo
15908
Young Ho Seo 2014.08.13 04:33 

Hello People.

I have very simple two code lines to fit separate chart window for my histogram like this: 

 

IndicatorSetDouble(INDICATOR_MINIMUM, min);
IndicatorSetDouble(INDICATOR_MAXIMUM, max);

This two code line works perfectly when I attach my indicator on chart.

However, when I apply my indicators on visual mode of Strategy Tester, these two code lines are not executed and chart (the separate window) is not fit to my histogram as I want.

Just curious if someone experience the same thing as me. Is there any workaround on this problem ?

Thanks in advance.  

Kind regards.

Alain Verleyen
Moderator
30775
Alain Verleyen 2014.08.13 10:00  
Tried with Ultimate_Oscillator from Indicators\Examples. It works without problem.
Young Ho Seo
15908
Young Ho Seo 2014.08.13 11:47  
angevoyageur:
Tried with Ultimate_Oscillator from Indicators\Examples. It works without problem.

Thanks but I didn't mentioned that the two code lines not placed inside "OnInit()" but it is called from "OnCalculate()" function whenever user change input variable.

So the code is slightly different from Ulimate Oscillator because I need to sue IndicatorSetDouble function dynamically from OnCalculate. :) :)

Stanislav Korotky
17942
Stanislav Korotky 2014.08.13 13:53  
FinanceEngineer:

Thanks but I didn't mentioned that the two code lines not placed inside "OnInit()" but it is called from "OnCalculate()" function whenever user change input variable.

So the code is slightly different from Ulimate Oscillator because I need to sue IndicatorSetDouble function dynamically from OnCalculate. :) :)

When user changes inputs, OnInit is called, so there is not need to move these two lines into OnCalculate.
Young Ho Seo
15908
Young Ho Seo 2014.08.13 15:20  
marketeer:
When user changes inputs, OnInit is called, so there is not need to move these two lines into OnCalculate.

very good point, marketeer.

However I need to calculate min and max value inside OnCalculate function.

So I can't avoid to use IndicatorSetDouble function inside OnCalcualte function.

The code is extremely simple and it is difficult to be wrong with code.

Also checked if min and max value is calculated correctly.

And they were correct.

So just curious if someone else is experiencing similar problem.

Maybe with IndicatorSetInteger function or IndicatorSetString function might have the same problem, I guess.

Kind regards.

Stanislav Korotky
17942
Stanislav Korotky 2014.08.13 16:09  
FinanceEngineer:

very good point, marketeer.

However I need to calculate min and max value inside OnCalculate function.

So I can't avoid to use IndicatorSetDouble function inside OnCalcualte function.

The code is extremely simple and it is difficult to be wrong with code.

Also checked if min and max value is calculated correctly.

And they were correct.

So just curious if someone else is experiencing similar problem.

Maybe with IndicatorSetInteger function or IndicatorSetString function might have the same problem, I guess.

Kind regards.

Without further deatails about the code it's hard to tell if you're right. You've mentioned that the window scale depends from inputs. If this is the only dependency, you can move this part of code into oninit freely.

Also, if you set indicators minimum and maximum not on every tick but only on some rare conditions, you may try to call ChartRedraw after changing the sizes.

Young Ho Seo
15908
Young Ho Seo 2014.08.13 22:58  
marketeer:

Without further deatails about the code it's hard to tell if you're right. You've mentioned that the window scale depends from inputs. If this is the only dependency, you can move this part of code into oninit freely.

Also, if you set indicators minimum and maximum not on every tick but only on some rare conditions, you may try to call ChartRedraw after changing the sizes.

Thanks. I at least got some temporary remedy. So I can go on. Later I will look for the real solution.

Kind regards.  

To add comments, please log in or register