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

Multiinstrument for single instrument...

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

    Multiinstrument for single instrument...

    Greetings Ninja Gurus,

    I'm sure I've missed this somewhere but I'm using the multiinstrument code to add a second time frame filter to a strategy. For example;

    protected override void Initialize()
    {
    //adding a range chart filter
    Add("ES 09-09", PeriodType.Range, 4);
    // below is the regular add stuff
    Add //this and that to the chart

    CalculateOnBarClose = true;
    }

    ... and then the code looks at things in a x minute timeframe.

    Where I'm adding ES 09-09 in the code I'd prefer it adds the instrument of the chart I'm using... so if I call up an ES chart it adds the 4 range ES filter, if I call up a CL chart it adds the 4 range CL filter, etc. In the above example the 4-range filter will always be ES 09-09. Can you point me where to look? Thanks.

    Re reading my question it sounds like I'm on drugs but basically I'm trying to add a higher order time/range/volume or whatever filter to an instrument in a strategy.

    #2
    MXASJ, thanks for the post - unfortunately you can't dynamically add bars objects in the Initialize(). You would need to code this out for each instrument you need.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      You can add a bars object in Initialize, and if you simply leave out the symbol it will default to the same symbol as the primary bars object, i.e.:

      protected override void Initialize()
      {
      CalculateOnBarClose = true;
      Add(PeriodType.Day,1); // Add bars object for daily bars

      }

      Then in OnBarUpdate you can have your filtering code run if (BarsInProgress ==1).

      This will add a daily bars object for the same symbol as the primary bars object. I've never tried it with range bars but I would expect it should work the same way.

      Unless I misunderstand your question I think this will do what you want...

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Austiner87, Today, 03:42 PM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by cshox, Today, 11:11 AM
      2 responses
      15 views
      0 likes
      Last Post cshox
      by cshox
       
      Started by algospoke, Today, 06:53 PM
      0 responses
      9 views
      0 likes
      Last Post algospoke  
      Started by mlprice12, 12-21-2021, 04:55 PM
      3 responses
      297 views
      0 likes
      Last Post paypachaysa  
      Started by lorem, 04-25-2024, 09:18 AM
      20 responses
      86 views
      0 likes
      Last Post lorem
      by lorem
       
      Working...
      X