Announcement

Collapse
No announcement yet.

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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    599 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    344 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    558 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    557 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X