Why the same indicator two lines are different

Questions about MultiCharts and user contributed studies.
chaoruixinxi
Posts: 8
Joined: 09 Apr 2013
Has thanked: 2 times

Why the same indicator two lines are different

Postby chaoruixinxi » 13 May 2016

one of the indicators to re calculate every once in a while,the other i didn‘t do anything,how to solve

Code: Select all

value1=Average(close,5) of data2;
plot1(value1);
Attachments
MultiCharts1.png
(52.31 KiB) Downloaded 615 times

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Why the same indicator two lines are different

Postby Henry MultiСharts » 13 May 2016

Hello chaoruixinxi,

Please study the following information:
viewtopic.php?f=16&t=6929#p31165
https://www.multicharts.com/trading-sof ... y_Matching

chaoruixinxi
Posts: 8
Joined: 09 Apr 2013
Has thanked: 2 times

Re: Why the same indicator two lines are different

Postby chaoruixinxi » 13 May 2016

Thank you,Please tell me how can I "turn on/off" indicator or signal per time automatically,The results seems different from manual。“RecalcLastBarAfter” and “recalculate” may be unavailable

Code: Select all

value1=Average(close,5) of data2;
plot1(value1);
RecalcLastBarAfter(1);

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Why the same indicator two lines are different

Postby Henry MultiСharts » 16 May 2016

Thank you,Please tell me how can I "turn on/off" indicator or signal per time automatically,The results seems different from manual。“RecalcLastBarAfter” and “recalculate” may be unavailable

Code: Select all

value1=Average(close,5) of data2;
plot1(value1);
RecalcLastBarAfter(1);
There is no way to turn off the study from the code.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Why the same indicator two lines are different

Postby JoshM » 28 May 2016

Thank you,Please tell me how can I "turn on/off" indicator or signal per time automatically,The results seems different from manual。“RecalcLastBarAfter” and “recalculate” may be unavailable
You can turn off an indicator with the RaiseRunTimeError() keyword.

That will be 'hard' disabling however; after you turn off the indicator with this keyword, you cannot re-enable it programmatically again. That's because, when the script is turned off, its code isn't executed anymore and so it cannot re-enable itself. So you'll need to do that manually.

You can also more or less "turn off" an indicator by placing all of its calculations inside an if statement. Then whenever that if statement's condition is invalidated, none of the code inside the if statement executes anymore.

For instance:

Code: Select all

Variables:
IntrabarPersist calculateScript(true);

if (calculateScript = true) then begin

// Execute the script's code here

end;

// Turn off the script's calculations when 'something' happens
if (something) then
calculateScript = false;


Return to “MultiCharts”