• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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] 
    				&&
    				"SMA(5)[0] > SMA(5)[0]"
    			)
    			{
    				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 -

    http://www.ninjatrader.com/support/h...s/nt7/add3.htm

    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 faisamtrader, Yesterday, 10:03 PM
    0 responses
    2 views
    0 likes
    Last Post faisamtrader  
    Started by johnnybegoode, Yesterday, 08:11 PM
    0 responses
    2 views
    0 likes
    Last Post johnnybegoode  
    Started by Bionian, Yesterday, 02:47 PM
    2 responses
    19 views
    0 likes
    Last Post Bionian
    by Bionian
     
    Started by RickB60, Yesterday, 01:55 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by filopearson, Yesterday, 01:18 PM
    6 responses
    11 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X