Problem with referencing custom indicator

Created at 27 Oct 2015, 10:02
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
TZ

tzoleto8

Joined 24.10.2015

Problem with referencing custom indicator
27 Oct 2015, 10:02


Hello guys,

I am new here and I cannot involve my custom indicator in my cBot. When I am actually try to initialize the custom indicator like this:  

bulls = Indicators.GetIndicator<ElderRay>(Source, 13); 

build is successful but the code in onTick() doesn't run at all.

I have followed the reference process but the problem is still there... The only reason this is happening, is maybe related to some problem with libraries but I am really new here and I am not sure.

Could you give an explanation to this?

Thank you!

 

 


@tzoleto8
Replies

Spotware
27 Oct 2015, 10:39

Dear Trader,

Could you please provide us with more information regarding your issue?

Do you receive any error messages? 

When you write for example a single print method in the OnTick() method, does it still not work?

Did you have any problems performing any of the steps described in the Referencing Custom Indicators section of our support site? 

The following code snippet illustrates the use of an indicator in a cBot.

        private SampleSMA sma;

        protected override void OnStart()
        {
            sma = Indicators.GetIndicator<SampleSMA>(Source, SmaPeriod);
        }

        protected override void OnTick()
        {
            Print("{0}", sma.Result.LastValue);
        }

 


@Spotware

tzoleto8
27 Oct 2015, 11:09

My code is exactly the same with what you wrote but different custom indicator.

I don't have error messages and everything seems to be fine. The problem is that when I include the initialization line  bulls = Indicators.GetIndicator<ElderRay>(Source, 13); in OnStart() ,nothing is executed in OnTick(). I

t's like compiler finds some problem in this line and doesn't look further.

 

 

 

 


@tzoleto8

Spotware
27 Oct 2015, 12:12

Dear Trader,

Could you please send us your code at troubleshooting@spotware.com?

It will be used only for troubleshooting purposes.


@Spotware

tzoleto8
27 Oct 2015, 12:20

RE:

Spotware said:

Dear Trader,

Could you please send us your code at troubleshooting@spotware.com?

It will be used only for troubleshooting purposes.

Ok


@tzoleto8

Spotware
28 Oct 2015, 08:07

Dear Trader,

In the log you will see the message:

Crashed in OnStart with ArgumentException: Incorrect parameters count. Parameter name: parameterValues

This means that when you call an indicator you used an incorrect number of parameters, in your case, you need to add a parameter to this line OnStart():

bulls = Indicators.GetIndicator<ElderRay>(Source, 13, MovingAverageType.Exponential);

In addition, you need to switch the parameters on the second custom indicator you referenced

// currently
//you defined it 
example(String x, int y)

//you are calling it 
example ( 35, "hello");

A very simple and quick way to troubleshoot/check your code is to use the Print() method between the lines of your code to verify that the code reach these lines with an expected result.  


@Spotware