How to call custom indicator
How to call custom indicator
23 Mar 2019, 12:19
How to call a custom indicator?
Example, there is a custom indicator of abc.calgo in ...\cAlgo\Sources\Indicators. Now i want to call it in cBot with H1, and another with H4, in OnSart().
How should i to do ?
Thanks Advance.
Replies
lgwsyqnfr
24 Mar 2019, 13:43
( Updated at: 21 Dec 2023, 09:21 )
RE:
2bnnp said:
Sorry missed the part with the custom indicator.
First you need to add a reference for the custom indicator to call it in your bot.
Then you can call it with Indicators.GetIndicator<CustomIndicatorHere>(Param1, Param2, Param3)
Thanks your help. but i still get it.
One of the reasons why MT4 and 5 are so popular is that MQL has detailed practical application examples, so, anyone can write its own program according to the examples. CTrader does very poorly in this respect, after all, most traders are not professional programmers. Therefore, cTrader has a long way to go before it can be popularized in the market.
@lgwsyqnfr
PanagiotisCharalampous
26 Mar 2019, 11:07
Hi lgwsyqnfr,
The process of referencing custom indicators is documented here.
Best Regards,
Panagiotis
@PanagiotisCharalampous
jani
28 Oct 2019, 13:48
RE:
Panagiotis Charalampous said:
Hi lgwsyqnfr,
The process of referencing custom indicators is documented here.
Best Regards,
Panagiotis
We appreciate your help and you're doing a great job for the cAlgo community!
But unfortunately, lgwsyqnfr is correct. The instructional material and examples for cAlgo are hard to find and sometimes lack in-depth content
API reference is notoriously poor to search for anything and even syntax definitions are sometimes lacking in content and important info.
Good example is the issue of cBot referencing custom indicator's. The document here that is always used as a reference unfortunately has NO INFORMATION on how cBot references custom indicators.
Also I cannot find any info on how I reference past custom indicator values... for a C# programmer this would be an obvious case, but many of us are not programmers but self-learned developers that need more handholding.
I just migrated from MT4 to cTrader and I would hate to have to go back to MQL, because I cannot find enough educational and reference material for cAlgo... :( (ps. I'm currently paying programmers to teach me...and I should not have to... there should be at least comprehensive reference material available!)
@jani
PanagiotisCharalampous
29 Oct 2019, 09:12
Hi Jani,
Thanks for your feedback but it is not clear to me which information you thing is missing. Regarding
Also I cannot find any info on how I reference past custom indicator values
It is exacly the same as for built in indicators and an example is provided in the link you posted. Pasting it again below
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)] public class SampleReferenceSMA : Indicator { [Parameter("Source")] public DataSeries Source { get; set; } [Parameter(DefaultValue = 14)] public int SmaPeriod { get; set; } [Output("Referenced SMA Output")] public IndicatorDataSeries refSMA { get; set; } private SampleSMA sma; protected override void Initialize() { sma = Indicators.GetIndicator<SampleSMA>(Source, SmaPeriod); } public override void Calculate(int index) { refSMA[index] = sma.Result[index]; } }
If you need older values you can use the Last() function.
Best Regards,
Panagiotis
@PanagiotisCharalampous
2bnnp
24 Mar 2019, 09:34
@2bnnp