Indicator Line-Order Troubles

Posted By black Tuesday, June 26, 2012
Add to Favorites0
Author Message
black
 Posted Tuesday, June 26, 2012
Supreme Being

Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)

Group: Forum Members
Last Active: Sunday, July 13, 2014
Posts: 520, Visits: 1,004
I have found that the TLineGraph / TPointGraph / TVolumeGraph variables in an Indicator script must remain in order for the script to work properly. What I mean can be illustrated with the following from a custom "High/Low Activator" that I built. In my script there are the following TLineGraph parts.

----------
var
HiLine, LoLine, CLine: TLineGraph;

procedure ApplySettings;
begin
HiLine.Color := strtocolor(GetSetting('colorhl'));
LoLine.Color := strtocolor(GetSetting('colorhl'));
CLine.Color := strtocolor(GetSetting('colorc'));
end;

procedure Init;
begin
HiLine := TLineGraph.Create();
LoLine := TLineGraph.Create();
CLine := TLineGraph.Create();
end;

procedure Add(const ValueIndex: Integer);
var
i, digit: integer;
hilocal, lolocal, clocal: Double;
begin

HiLine.AddXY(SourceGraph.XValue(ValueIndex), hilocal);
LoLine.AddXY(SourceGraph.XValue(ValueIndex), lolocal);
CLine.AddXY(SourceGraph.XValue(ValueIndex), clocal);

end;
----------

Notice in the above script that every time the variables HiLine, LoLine, and CLine are used, they are in the same order within the sections of the script. I have found that if they are scripted out-of-order in one section, the Indicator will not act correctly. For example, if I change:

procedure Init;
begin
HiLine := TLineGraph.Create();
LoLine := TLineGraph.Create();
CLine := TLineGraph.Create();
end;

to

procedure Init;
begin
CLine := TLineGraph.Create();
LoLine := TLineGraph.Create();
HiLine := TLineGraph.Create();
end;

but I leave the rest of the script the same as it is, there will be a problem with the way the Indicator acts. There may even be error messages.

So, always keep all the TLineGraph / TPointGraph / TVolumeGraph variables in order to make the scrip work correctly.

Smile
Tuesday, June 26, 2012 by black
Admin
 Posted Thursday, July 05, 2012
Administrator

Administrator - (124,195 reputation)

Group: Administrators
Last Active: Friday, June 02, 2017
Posts: 548, Visits: 3,295
Dear Black,

Please provide the script where this error occurs.

The order of description of TGraph object should not matter.


Best regards

-ACTFX© Forum Administrator
black
 Posted Thursday, July 05, 2012
Supreme Being

Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)Supreme Being - (96,525 reputation)

Group: Forum Members
Last Active: Sunday, July 13, 2014
Posts: 520, Visits: 1,004
I can not duplicate the error. So I must apologize.

I do not remember which Indicator it was that caused this error for me. But I cannot duplicate it in my custom Indicators.

Perhaps there was a momentary System anomaly when it happened. Or maybe there was a different error in scripting that I corrected at the same time and attributed the error to the wrong thing.

Sorry for the mistake.

Smile

Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Back To Top