Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Different instrument issue

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

    Different instrument issue

    I am trying to make a check on a different instrument but having some issues.

    Here is the code snippet where I perform the test on the same instrument but different time frame. It works ok.

    SMA(BarsArray[InstrumentPosition["1-Minute"]], 200)[0] > High[0] + TickSize

    I then try to add the same test for a different instrument.

    SMA(BarsArray[InstrumentPosition["ES"]], 200)[0] > Highs[2][0] + 12.5

    I also tried the following but it didn't work either:
    SMA(BarsArray[2], 200)[0] > Highs[2][0] + 1 * 12.5

    Everything compiles and runs but I get no matches.

    I had to hard code the ES ticksize because I couldn't see anyway to retrieve it.

    #2
    Hi ct,

    You need to first Add() your secondary bar object. In the initialize section you would go
    Code:
    Add("ES 12-07", PeriodType.Minute, 5);
    Then in the OnBarUpdate section you can go
    Code:
    SMA(BarsArray[1], 200)[0] > Highs[1][0] + 1 * 12.5
    The indexing of BarsArray starts at 0. 0=primary bars; 1=secondary bars; etc.

    The way you can get the TickSize of your secondary bar object is to store it in another variable. You can go
    Code:
    if (BarsInProgress == 1)
         secondaryTickSize = TickSize;
    The value of BarsInProgress works the same way the indexing of BarsArray works. Now, because you don't need to set this same variable over and over again every time the bar updates, you can limit it to do it only once.
    Code:
    if (CurrentBar == 1 && FirstTickOfBar && BarsInProgress == 1)
         secondaryTickSize = TickSize;
    After you have the secondary bar object's tick size you can do this instead
    Code:
    SMA(BarsArray[1], 200)[0] > Highs[1][0] + 1 * secondaryTickSize
    Last edited by NinjaTrader_JoshP; 09-15-2007, 08:27 PM.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh

      Thanks. I forgot NT ticked on any instrument added. I had added a 1 minute same instrument and a one minute forced to ES. I thought I had tried that syntax but call me blind. I gave what you provided a try and it worked fine.

      Here is a question good one for ya. Any good solution for changing the contract month (ES 12-07) other than through a parm.


      Cliff

      Comment


        #4
        Sorry only way I know of is through param.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Josh
          Thanks for the reply. At least I know there isn't a better easy way.

          Regards

          Cliff
          New Zealand

          Comment

          Latest Posts

          Collapse

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