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

Trading decision based on different period type bars

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

    Trading decision based on different period type bars

    I am working on a multiple instrument strategy. The different instrument bars (period type = minutes) are as expected added in the “configure state”. All is working as expected.

    Now I want to add a check whether I will trade on not each individual instrument in the current day. The simple control that I would like to put in place is basically to check for each instrument if the momentum is above 0. But the period type that I would like to use for the indicator is “day”.

    As the period type is different to the already added bars, I am not sure what I should do. From other posts, I see that I should add “day” period type bars for each instrument to check the momentum. Is this the right approach as I only need to run the test once per day? And then, how can I in the “OnBarUpdate” event avoid treating the added daily bars?

    Thanks in advance for your advice/suggestion,
    Eric

    #2
    Hello Eric,

    Yes, if you want to use 1 Day bars for the input series of an indicator, you would need to add that series with AddDataSeries() along with any other series you may have added.

    The Closes or BarsArray with the index of that added series would be supplied to the indicator.
    The help guide provides sample code.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      To check momentum for each instrument once per day, adding daily bars for each instrument is a good approach. This way, you can calculate momentum based on the daily bars and make your trading decision accordingly.
      In the "OnBarUpdate" event, you can use a simple condition to check if the current bar is a daily bar or a different period type bar. For example, you could use an if statement like this:
      if (BarsInProgress == 0 && Bars.Period.Id == PeriodType.Day)
      {
      // Calculate momentum based on daily bars here
      }
      This way, you can ensure that your momentum calculation is only applied to daily bars and not to other period types. Good luck with your strategy, and if you ever feel indecisive about your trading decisions, you could always toss a coin to help you decide!​
      Last edited by BradleyLeonard; 04-21-2024, 06:39 PM.

      Comment


        #4
        BradleyLeonard,

        Welcome to the NinjaTrader forums!

        Thank you for your suggestion.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by lightsun47, Today, 03:51 PM
        0 responses
        5 views
        0 likes
        Last Post lightsun47  
        Started by 00nevest, Today, 02:27 PM
        1 response
        10 views
        0 likes
        Last Post 00nevest  
        Started by futtrader, 04-21-2024, 01:50 AM
        4 responses
        46 views
        0 likes
        Last Post futtrader  
        Started by Option Whisperer, Today, 09:55 AM
        1 response
        14 views
        0 likes
        Last Post bltdavid  
        Started by port119, Today, 02:43 PM
        0 responses
        10 views
        0 likes
        Last Post port119
        by port119
         
        Working...
        X