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

Multi Instrument and Multi Time Frame Stgy

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

    Multi Instrument and Multi Time Frame Stgy

    Hi everybody i have a doubt about this script i made.
    I want to compare the price of 2 instruments (ES Futures less NQ Futures), And compare 10 second candles vs 15minutes candles
    I add the instruments and the different time frames, and then i create some double vars with the difference of open, close, high and low of that 2 instruments.
    I do not know why i could not enable the strategy, y show below some parts of the script if someone could help me.
    Thanks, Ignacio



    else if (State == State.Configure)
    {
    AddDataSeries("ES 09-18", Data.BarsPeriodType.Minute, 15, Data.MarketDataType.Last);
    AddDataSeries("NQ 09-18", Data.BarsPeriodType.Minute, 15, Data.MarketDataType.Last);

    AddDataSeries("ES 09-18", Data.BarsPeriodType.Second, 10, Data.MarketDataType.Last);
    AddDataSeries("NQ 09-18", Data.BarsPeriodType.Second, 10, Data.MarketDataType.Last);


    }
    else if (State == State.DataLoaded)
    {
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[1] < 1
    || CurrentBars[2] < 1)
    return;

    SClose15[0] = ( Closes[1][0] + Closes[2][0]);//ES 09-18 less NQ 09-18 in 15 min close
    SOpen15[0] = ( Opens[1][0] + Opens[2][0]);//ES 09-18 less NQ 09-18 in 15 min Open
    SHigh15[0] = ( Highs[1][0] + Highs[2][0]);//ES 09-18 less NQ 09-18 in 15 min HIgh
    SLow15[0] = ( Lows[1][0] + Lows[2][0]);//ES 09-18 less NQ 09-18 in 15 min Low

    SSLow15[0] = ( Lows[3][0] + Lows[4][0]);//ES 09-18 less NQ 09-18 in 10 seg low
    SSLow15[1] = ( Lows[3][1] + Lows[4][1]);//ES 09-18 less NQ 09-18 in 10 seg low previous bar
    SSLow15[2] = ( Lows[3][2] + Lows[4][2]);//ES 09-18 less NQ 09-18 in 10 seg low 2 bars ago
    SSLow15[3] = ( Lows[3][3] + Lows[4][3]);//ES 09-18 less NQ 09-18 in 10 seg low 3 bars ago
    SSLow15[4] = ( Lows[3][4] + Lows[4][4]);//ES 09-18 less NQ 09-18 in 10 seg low 4 bars ago
    SSHigh15[0] = ( Highs[3][0] + Highs[4][0]);





    if (
    SSLow15[0] < (SLow15 [0]+((SHigh15[0]-SLow15[0])/4))
    )

    {
    EnterLong(3,1, "long1");
    EnterShort(4,1, "short2");
    }
    ........
    at final i make the properties

    #region Properties
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> SClose15
    {
    get { return Values[0]; }
    }
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> SOpen15
    {
    get { return Values[0]; }
    }
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> SHigh15
    {
    get { return Values[0]; }
    }
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> SLow15
    {
    get { return Values[0]; }
    }
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> SSLow15
    {
    get { return Values[0]; }
    }
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> SSHigh15
    {
    get { return Values[0]; }
    }
    #endregion/*/
    }

    #2
    Hello Spartaco,

    Thank you for your note.

    You have 4 data series added but only 2 current bar checks,

    Code:
    if (CurrentBars[1] < 1
    || CurrentBars[2] < 1)
    return;
    You should add 2 more for the additional series. For CurrentBars[3] and CurrentBars[4].

    See current bar checks,


    You also are referencing the low of 4 bars ago on the 4th series added, so you will need to check that you have at least 4 bars as part of that series. if(CurrentBars[4] < 10) return would do.

    After you make those changes are you able to get the script to run.

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by PhillT, Today, 02:16 PM
    2 responses
    6 views
    0 likes
    Last Post PhillT
    by PhillT
     
    Started by Kaledus, Today, 01:29 PM
    3 responses
    10 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by frankthearm, Yesterday, 09:08 AM
    14 responses
    47 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by gentlebenthebear, Today, 01:30 AM
    2 responses
    14 views
    0 likes
    Last Post gentlebenthebear  
    Started by PaulMohn, Today, 12:36 PM
    2 responses
    17 views
    0 likes
    Last Post PaulMohn  
    Working...
    X