Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Using a secondary instrument as a filtering criteria possible?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using a secondary instrument as a filtering criteria possible?

    I would like to use two instruments to trigger a signal.

    Like this:

    If the main instrument short MA is above the main instrument longer MA and secondary instrument short MA is above longer MA create a signal
    Code:
    if
    			(
    				SMA(5)[0] > SMA(10)[0] 
    				[B]&&
    				"SMA(5)[0] > SMA(5)[0]"[/B]
    			)
    			{
    				DrawArrowUp("arrow"+CurrentBar, true, 0, Low[0]-ATR(10)[0]*2, Color.Green);
    
    			}
    where "SMA(5)[0] > SMA(5)[0]" would be based on a secondary instrument like ^DJIA (Dow Jones Industrial Average).

    Is this possible? Tried to look around, but couldn't quite find a post about this kind of a coding. So, any hints appreciated Thank you!

    #2
    MickeyHR, yes that would be possible in a MultiSeries script. You can Add() in another instrument in your script's Initialize() method -



    So lets say you want to add in a 5 minute DJIA index series -

    Add("^DJIA", PeriodType.Minute, 5);

    You can then access this symbol via passing the correct BarsArray to your second SMA statement.

    && SMA(BarsArray[1], 5)[0] > SMA(BarsArray[1], 10)[0]

    You want then to also add in a BarsInProgress check to filter for which bars object OnBarUpdate() call this condition should be evaluated - http://www.ninjatrader.com/support/h...inprogress.htm
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,788 views
    0 likes
    Last Post aligator  
    Started by Jimmyk, 01-26-2018, 05:19 AM
    6 responses
    837 views
    0 likes
    Last Post emuns
    by emuns
     
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,293 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    12 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    11 responses
    62 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X