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 Hwop38, 05-04-2026, 07:02 PM
    0 responses
    161 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    310 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    245 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    349 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    179 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X