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

need help on nt8 features

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

    need help on nt8 features

    hi ,

    can you please help me to know below ?

    1. can i make strategy to run on 1 min chart at 9 to 11 am est and in remining time strategy should run on 5 min ? is there NT8 Script or feature available for this ?

    2. can create list of instruments MNQ,MYM etc .. and run strategy on those list this avoids adding chart template on each instrument ?

    regards,
    shankar

    #2
    Hello Shakar,

    Thanks for your post.

    1. can i make strategy to run on 1 min chart at 9 to 11 am est and in remining time strategy should run on 5 min ? is there NT8 Script or feature available for this ?
    Yes, you could make a strategy that runs on 1 minute data that switching to using 5 minute data. You would need to make a Multi Time Frame strategy, that adds the 5 minute data series.

    When times are between 9am and 11am, you can process logic from BarsInProgress == 0 (the primary data series, this can be a 1 minute series)

    When outside of these times, you can process logic from BarsInProgres == 1 (the first added data series in the script, this can be 5 minute series)

    Please see the documentation below for working with Multi Time Frame scripts.

    Multi Time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm

    2. can create list of instruments MNQ,MYM etc .. and run strategy on those list this avoids adding chart template on each instrument ?
    Yes, NinjaScript strategies can be run from the Strategies tab of the Control Center, and from there, you can apply the strategy to an Instrument List, and not just 1 instrument.

    Running NinjaScript strategies from the Control Center - https://ninjatrader.com/support/help...t_strateg2.htm

    Please let us know if you have any questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hi Jim,

      Thanks for your quick reply .
      Just need quick clarification .
      1. If default time frame is 5 min (which is is selected from drop down menu )then this will be BarsInProgress == 0 and when time is 9 am to 11 am i will add below code and that will be BarsInProgress index = 1 ?

      protected override void OnStateChange()
      {
      if (State == State.Configure)
      {
      // Add a 1 minute Bars object: BarsInProgress index = 1
      AddDataSeries(BarsPeriodType.Minute, 1);
      }
      }

      Comment


        #4


        Hi ,

        I can select 1 instrument from list in strategies tab but actually i want to run strategy on list 5 instruments paralelly at one click by starting one strategy .
        please let me know where i am missing.

        Attached Files

        Comment


          #5
          Hello ,

          1. If default time frame is 5 min (which is is selected from drop down menu )then this will be BarsInProgress == 0 and when time is 9 am to 11 am i will add below code and that will be BarsInProgress index = 1 ?

          protected override void OnStateChange()
          {
          if (State == State.Configure)
          {
          // Add a 1 minute Bars object: BarsInProgress index = 1
          AddDataSeries(BarsPeriodType.Minute, 1);
          }
          }
          Not quite, OnStateChange will already be present in the script after building the class structure with the New Strategy Wizard. AddDataSeries would be added within the OnStateChange method, under if (State == State.Configure)

          Within OnBarUpdate, you could check:

          Code:
          if ((ToTime(Time[0]) >= 90000 && ToTime(Time[0]) <= 110000) && BarsInProgress == 0)
          {
              // This code runs using the primary data series between 9AM and 11AM
              Print(String.Format("BIP: {0} Time[0]: {1}", BarsInProgress, Time[0]));
          }
          else if (BarsInProgress == 1 && !(ToTime(Time[0]) >= 90000 && ToTime(Time[0]) <= 110000))
          {
              // This code runs using the first added data series. (The 1 minute data series)
              Print(String.Format("BIP: {0} Time[0]: {1}", BarsInProgress, Time[0]));
          }
          I can select 1 instrument from list in strategies tab but actually i want to run strategy on list 5 instruments paralelly at one click by starting one strategy .
          please let me know where i am missing.
          Adding the strategy against a list of instruments, and then using Shift + Click to select a group of strategies, and then right clicking and selecting enable would be my preferred way to quickly enable strategies on several instruments. I've attached a screenshot showing how to apply a strategy to an Instrument List.

          Instrument Lists can be made in the Control Center's Tools > Instrument Lists menu

          https://ninjatrader.com/support/help...ment_lists.htm

          If you want to trade with multiple instruments in one strategy, you can do this too, but it would involve adding many more data series in the script, and additional BarsInProgress logic to have that trading logic work on each instrument. Multi Time Frame and Instruments linked in post #2 would be the documentation to follow to accomplish that.
          Attached Files
          Last edited by NinjaTrader_Jim; 11-19-2021, 02:24 PM.
          JimNinjaTrader Customer Service

          Comment


            #6
            Hi Jim ,
            Thanks for clarifying . i got some other issues today when i am testing today.

            1. I am able to create list with with instruments and start a strategy by select Script list . But the issue is it will add so many no of instruments in list as entry in strategies tab and start manually by selecting Enable checkbox individually . This looks issue for me because if i have more instruments i have enable for each instruments . Is there a feature directly run strategy in single on list.?

            2. even i have written below code always barsInProgress=0 is executing but not barsinProgress=1 .Can u please help me ? even though time is 150000 and 151500 only else part is executing not if condition code . Can u please check?

            if (State == State.Configure)
            {
            instrumentName = Instrument.MasterInstrument.Name;
            // Add a 1 minute Bars object: BarsInProgress index = 1
            AddDataSeries(BarsPeriodType.Minute, 1);
            AddDataSeries(BarsPeriodType.Minute, 15);
            AddDataSeries(BarsPeriodType.Day, 1);
            }


            if ((ToTime(Time[0]) >= 150000 && ToTime(Time[0]) <= 151500) && BarsInProgress == 1)
            { // This code runs using the first added data series. (The 1 minute data series)
            Print(" in time frame i="+i+"BarsInProgress="+BarsInProgress);
            } else if (BarsInProgress == 0)
            {// This code runs using the primary data series between 9AM and 11AM
            Print(" in time frame i="+i+"BarsInProgress="+BarsInProgress);
            }


            Comment


              #7
              Hello ,

              1. I am able to create list with with instruments and start a strategy by select Script list . But the issue is it will add so many no of instruments in list as entry in strategies tab and start manually by selecting Enable checkbox individually . This looks issue for me because if i have more instruments i have enable for each instruments . Is there a feature directly run strategy in single on list.?
              Did you try selecting multiple strategies at once in the Strategies tab with Shift + Click or Ctrl + A? If you select multiple strategies, right click and then click Enable, all of those strategies will be enabled at one.

              2. even i have written below code always barsInProgress=0 is executing but not barsinProgress=1 .Can u please help me ? even though time is 150000 and 151500 only else part is executing not if condition code . Can u please check?
              Are you adding your if(State == State.Configure) code in OnBarUpdate? This should be added in OnStateChange. I made the logic in post #5 more explicit to force BarsInPorgress 0 to process within the time window, and have BarsInProgress 1 process outside the time window. I have attached the script here if you want to test on your end and compare with what you have set up.

              If you want to switch to have the 1 minute added series process within the window, and the 5 minute (primary) series outside the window, you can switch the BarsInProgress == X part of the condition.

              I.E.

              Code:
              if ((ToTime(Time[0]) >= 90000 && ToTime(Time[0]) <= 110000) && [B]BarsInProgress == 0[/B])
              {
                  // This code runs using the primary data series between 9AM and 11AM
                  Print(String.Format("BIP: {0} Time[0]: {1}", BarsInProgress, Time[0]));
              }
              else if ([B]BarsInProgress == 1[/B] && !(ToTime(Time[0]) >= 90000 && ToTime(Time[0]) <= 110000))
              {
                  // This code runs using the first added data series. (The 1 minute data series)
                  Print(String.Format("BIP: {0} Time[0]: {1}", BarsInProgress, Time[0]));
              }
              Attached Files
              JimNinjaTrader Customer Service

              Comment


                #8
                Hi
                "Did you try selecting multiple strategies at once in the Strategies tab with Shift + Click or Ctrl + A? If you select multiple strategies, right click and then click Enable, all of those strategies will be enabled at one."

                yes . i did .the problem here is if have 10 stocks i need to add 10 entry and select . is there any way where i can run one strategy on all scripts list with by enabling in only one line?

                Comment


                  #9
                  Hello Shankar,

                  is there any way where i can run one strategy on all scripts list with by enabling in only one line?
                  Yes, you can write one strategy that trades multiple instruments, but it would involve adding many more data series in the script, and additional BarsInProgress logic to have that trading logic work on each instrument. Multi Time Frame and Instruments linked in post #2 would be the documentation to follow to accomplish that.
                  JimNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Barry Milan, Yesterday, 10:35 PM
                  5 responses
                  16 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by DanielSanMartin, Yesterday, 02:37 PM
                  2 responses
                  13 views
                  0 likes
                  Last Post DanielSanMartin  
                  Started by DJ888, 04-16-2024, 06:09 PM
                  4 responses
                  13 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by terofs, Today, 04:18 PM
                  0 responses
                  12 views
                  0 likes
                  Last Post terofs
                  by terofs
                   
                  Started by nandhumca, Today, 03:41 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post nandhumca  
                  Working...
                  X