NexusFi: Find Your Edge


Home Menu

 





NinjaTrader methods to compare indicator values


Discussion in NinjaTrader

Updated
    1. trending_up 1,307 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 5 posts
    2. attach_file 2 attachments




 
Search this Thread

NinjaTrader methods to compare indicator values

  #1 (permalink)
thesarath
Cochin
 
Posts: 8 since Dec 2014
Thanks Given: 1
Thanks Received: 0

How can I check the condition for =,!=,>= and <= in NinjaTrader.Indicator.Indicator class? I have done > and < with
1. CrossOver(IDataseries,IDataseries,value) // for >
2. CrossBelow(IDataseries,IDataseries,value) // for <

Is there any methods to check in case we need to check with =,!=,>= and <= operators?

Any help would be appreciated.
Thank you.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Quant vue
Trading Reviews and Vendors
What broker to use for trading palladium futures
Commodities
REcommedations for programming help
Sierra Chart
Trade idea based off three indicators.
Traders Hideout
 
  #2 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,426


thesarath View Post
How can I check the condition for =,!=,>= and <= in NinjaTrader.Indicator.Indicator class? I have done > and < with
1. CrossOver(IDataseries,IDataseries,value) // for >
2. CrossBelow(IDataseries,IDataseries,value) // for <

Is there any methods to check in case we need to check with =,!=,>= and <= operators?

Any help would be appreciated.
Thank you.

You can still use the '==', '<=' and '>=' operators on indicator or series results (i.e. with a [bar] suffix) directly, just remember that the tests will not be much extra use unless you use some form of rounding (e.g. TickSize, integer) and/or the value differences are meaningful when tested at that granularity.

Travel Well
Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
thesarath
Cochin
 
Posts: 8 since Dec 2014
Thanks Given: 1
Thanks Received: 0


Could you please provide a simple example? @ratfink

Reply With Quote
  #4 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,426


thesarath View Post
Could you please provide a simple example? @ratfink

e.g.

 
Code
protected override void Initialize()
{
    Add(new Plot(Color.FromKnownColor(KnownColor.DarkOrange), PlotStyle.Line, "Plot0"));
    Overlay = false;
    CalculateOnBarClose = true;
			
    Plots[0].Pen.Width = 2;
}

protected override void OnBarUpdate()
 {
    if (Instrument.MasterInstrument.Round2TickSize(SMA(5)[0]) == Instrument.MasterInstrument.Round2TickSize(SMA(10)[0]))
    {
         Plot0.Set(1);
    }
    else
    {
        Plot0.Set(0);
    }
}
Gives:



So you can see equality testing will not spot all crossovers, in this case we are using rounding but if we don't do that then we would still have floating point representation issues. Different horses for different courses.

Zip file for code attached.

Cheers.

Travel Well
Attached Files
Elite Membership required to download: CompareEggs.zip
Visit my NexusFi Trade Journal Reply With Quote
  #5 (permalink)
thesarath
Cochin
 
Posts: 8 since Dec 2014
Thanks Given: 1
Thanks Received: 0

Thanks a lot @ratfink.
But my problem is that i need to get the SMA(5)[0] through reflection with methodinfo.invoke.

Here is my code :

dataSeries1 = (IDataSeries)ind1_methodInfo.Invoke(obj, ind1_params);
dataSeries2 = (IDataSeries)ind2_methodInfo.Invoke(obj, ind2_params);


The above code calls like SMA(5) which returns Dataseries.
Do you have any idea to invoke a method which have indexer ie, call SMA(5)[0] using reflection so that I can get double value for any indicator and easily compare them with any operator.

Reply With Quote
  #6 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,426


thesarath View Post
Thanks a lot @ratfink.
But my problem is that i need to get the SMA(5)[0] through reflection with methodinfo.invoke.

Here is my code :

dataSeries1 = (IDataSeries)ind1_methodInfo.Invoke(obj, ind1_params);
dataSeries2 = (IDataSeries)ind2_methodInfo.Invoke(obj, ind2_params);


The above code calls like SMA(5) which returns Dataseries.
Do you have any idea to invoke a method which have indexer ie, call SMA(5)[0] using reflection so that I can get double value for any indicator and easily compare them with any operator.

Simple answer - No, I've never used reflection, out of interest why do you need to? Are you programming outside of Ninja? Hopefully someone else can jump in with the torch.

Travel Well
Visit my NexusFi Trade Journal Reply With Quote




Last Updated on December 2, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts