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

Custom Methods and Multiple Time Frame

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

    Custom Methods and Multiple Time Frame

    When using an included indicator such as EMA its possible to access to additional bar objects with the index [0] value.

    When using custom methods that are located in the UserDefinedMethods file how can i control what bar object they are working off? Should i just include the method within the file and rewrite it accordingly? Or is there a way to index it directly?

    Thanks!

    Ben

    #2
    neb1998, "bars" objects are only really recognized inside OnBarUpdate(), so you could create your methods in the user methods file and pass in the appropriate information via the arguments of the method inside OnBarUpdate().

    In pseudocode:
    Code:
    // this is the userdefinedmethods file
    private bool isHighGreaterThanLow(double high, double low)
    // could also pass in the data series directly - someMethod(DataSeries ds1, DataSeries ds2)
    {
       // do some stuff here
       return true;
    }
    
    // in strat/indicator
    OnBarUpdate()
    {
       bool check1 = isHighGreaterThanLow(High[1], Low[2]);
    }
    AustinNinjaTrader Customer Service

    Comment


      #3
      Thanks, that is what i am doing now. I am also finding that in order to simulate Look Inside Bar=1minute that you must keep all calculations inside of (onbarupdate) method and not inside of the barsinprogress methods or it will not update the calculations correctly. I am just using indexing to the correct barsarray object, such as highs[1][0] to reference my 2nd data time, etc.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Waxavi, Today, 02:10 AM
      1 response
      16 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by Kaledus, Today, 01:29 PM
      5 responses
      13 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by Waxavi, Today, 02:00 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by alifarahani, Today, 09:40 AM
      5 responses
      23 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by gentlebenthebear, Today, 01:30 AM
      3 responses
      17 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X