Profile Picture

How to use custom indicator in another custom indicator? Need sample.

Posted By JoeChangSi 6 Years Ago

How to use custom indicator in another custom indicator? Need sample.

Message
Posted Tuesday December 13 2011
I have my own custom indicator, e.g. Indicator_slave, which I use in my second custom indicator, e.g. Indicator_master.
In CalcNewValue() method of Indicator_master I'd like do get value of Indicator_slave on the same Index. But I always have value of Indicator_slave for Index = 0, only.

My samples in attachment. Please correct my samples or get yours.
Thanks.

Attachments
Indicator_master.cs (214 views, 1.00 KB)
Indicator_slave.cs (179 views, 743 bytes)
vsn
Supreme Being (366 reputation)Supreme Being (366 reputation)Supreme Being (366 reputation)Supreme Being (366 reputation)Supreme Being (366 reputation)Supreme Being (366 reputation)Supreme Being (366 reputation)Supreme Being (366 reputation)Supreme Being (366 reputation)
Posted Wednesday February 01 2012
That's a good question, i'm interested in this too.
Posted Tuesday February 07 2012
Based on your code it looks like what you want is for the value of Indicator_master to be the square of the "bar index" of the current bar. It would start at 0 for the first bar, then go 1, 4, 9, 16, 25, etc. I've modified the code to make it work like this and attach it.

The issue with the code is that index is a "lookback" value, where zero means the most recent bar. When running a system this will always be zero. If you drag the indicator onto a chart it would not be. I realize that this is confusing and am planning to make it simpler in a future version of RightEdge.

So the main change in the code was to use (Count - index - 1) instead of index in the calculations. I also got rid of the NewBar() override in Indicator_master, and updated the Reset() method there.

Sorry for the late response on this.

Thanks,
Daniel

Attachments
Indicator_master.cs (217 views, 1.00 KB)
Indicator_slave.cs (216 views, 755 bytes)
Posted Tuesday February 07 2012
Daniel, thank you very much for your answers.

In the example you sent, there is a small error.

protected override void Reset ()
{
ind_slv.NewSeries (Count); / / Error: count should have been 5000, but was 0
}

I made a new example. As far as I understand, there are two important things in this case, override NewSeries and the use of LookBack(index) instead of Current Property. The indicator value in this example does not matter, let it be simply the closing price. If my sample is written correctly, I could upload it to the examples (http://www.rightedgesystems.com/TradingSystems.aspx).

At the moment I have NinjaTrader and WealthLab. But they have some disadvantages that are essential for me. So I'm interested in using RE. But before I can start working with RE I have to make sure that I can do whatever I need quickly and easily and get the correct results.

Attachments
Indicator_master.cs (234 views, 1.00 KB)
Indicator_slave.cs (239 views, 768 bytes)


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems