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

Multi instrument

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

    #31
    Hello alexstox,

    You stated your main series is a daily bar, this would be the primary series (0). This would then be the input for Add(CloseWeekPer(MyInstrum1));. And thus be printed from your strategy with the Daily bars as the input.

    Comment


      #32
      Originally posted by NinjaTrader_PatrickH View Post
      Hello alexstox,

      You stated your main series is a daily bar, this would be the primary series (0). This would then be the input for Add(CloseWeekPer(MyInstrum1));. And thus be printed from your strategy with the Daily bars as the input.
      Is there any sample how to add PeriodType for own indicator in strategy?
      I mean how to call that parameter from strategy to use in indicator? Because as I know I can't do this via string PerType=PeriodType.Week; and use it than in indicator code CloseWeekPer(MyInstrum1, PerType));

      Comment


        #33
        Hello alexstox,

        It is not possible to add an indicator to a strategy using a secondary data series.

        When using the Add() method to add an indicator to a strategy, the primary data series (the data series of the chart) will be the data series that is used for the indicator. It is not possible to change this.

        It would be possible, however, to add a secondary data series of 1 week to the indicator and process only during that bars in progress.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #34
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello alexstox,
          It is not possible to add an indicator to a strategy using a secondary data series.
          When using the Add() method to add an indicator to a strategy, the primary data series (the data series of the chart) will be the data series that is used for the indicator. It is not possible to change this.
          It would be possible, however, to add a secondary data series of 1 week to the indicator and process only during that bars in progress.
          I'm confused. I used indicator, that have only Weekly data series. In strategy it take only Symbol of instrument. Than there is adding of weekly data series in indicator code. So, I did everything you wrote to do.

          in strategy Add(CloseWeek("MSFT"));
          in indicator Add("MSFT", PeriodType.Week, 1);
          Last edited by alexstox; 07-24-2014, 02:23 PM.

          Comment


            #35
            Hello alexstox,

            I am not quite sure what you are asking.

            If you strategy is running on a daily chart (or chart that is not one week), you can have the indicator use a 1 week time frame by adding a secondary data series.

            If you are going to have your chart be a weekly time frame then this is not needed.

            At this point, from how I am understanding the correspondence in this thread, you should be adding the strategy to a daily chart, and then the strategy will call an indicator that has a 1 week added data series.

            The data would then be processed in the indicator for the week time frame, and plotted on the chart.

            Is this what you are trying to accomplish?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #36
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello alexstox,

              I am not quite sure what you are asking.

              If you strategy is running on a daily chart (or chart that is not one week), you can have the indicator use a 1 week time frame by adding a secondary data series.

              If you are going to have your chart be a weekly time frame then this is not needed.

              At this point, from how I am understanding the correspondence in this thread, you should be adding the strategy to a daily chart, and then the strategy will call an indicator that has a 1 week added data series.

              The data would then be processed in the indicator for the week time frame, and plotted on the chart.

              Is this what you are trying to accomplish?
              Chelsea, thank you very much for your care. I don't have problem with plot additional chart in Strategy Analyzer. I do have problem with UP and DOWN signals from WeekClose indicator.

              ================================================== ==============
              I use indicator with BoolSeries UP and DOWN (week close up or week close down). So, in strategy script OnBarUpdate() condition CloseWeek.UP[0] is true only on week's end day. That's why days between two weeks' ends are false. How to avoid this?

              Please look at attached Output. So, as you see there on week's end day (date at which week closes) everything is OK. But days betweens weeks' ends are contrary.
              Click image for larger version

Name:	WeekClose.PNG
Views:	2
Size:	38.8 KB
ID:	870872
              So, I think this because of BarsInProgress==1 is absent in between weeks's ends days. Indicator works with weekly bars. I use this indicator in strategy, where general instrument uses daily bars.
              Indicator script
              protected override void Initialize()
              {.....................
              Add(MyInstrum1, PeriodType.Week, 1);
              .......................
              uPweek = new BoolSeries(this);
              dOWNweek = new BoolSeries(this);
              }

              protected override void OnBarUpdate()
              {
              if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired /*|| CurrentBars[2] <= 20*/)
              return;
              .................................
              if (BarsInProgress==1) //start BarsInProgress
              {
              if (blalblalllal.........
              dOWNweek.Set(false);
              uPweek.Set(true);
              .................................}


              Strategy script
              protected override void Initialize()
              {
              ...........................
              Add(CloseWeek(MyInstrum2));
              as you can see, I do not specify PeriodType for indicator, because it needs only in Symbol string input
              .........................................
              }

              protected override void OnBarUpdate()
              {
              if (CurrentBars[0] <= ATR_big_per || CurrentBars[1] <= BarsRequired || CurrentBars[2] <= BarsRequired)
              return;
              if (CloseWeek(MyInstrum2).UPweek[0])
              ..........................
              }


              You know what is interesting? After week Up on following days Upweek==false, DOWNweek==true!!!! and vice versa after week DOWN on following days DOWNweek==false, UPweek==true!!! You can see this in Output, that I attached earlier.

              Patrick answer
              You have two input series, a Week and a Day series. The Day bars are not going to have the same value from the ClosePerWeek() indicator as the Week bars on the close of the of the week bar, as the Day bar is only looking at that day where the Week bar encompasses the entire week of data.

              For example, compare the Open, High, Low, and Close of the Day bar on the closing day of the Week bar and you will see the Open, High, Low, Close is not the same as the Week bar.


              My question
              Patrick, please, advise me what to do.
              Maybe I should add
              if (BarsInProgress==2) //start BarsInProgress for weekly instrument only
              {and here is everything with CloseWeekIndictor...
              } this didn't help. I tried.

              Patrick answer
              Well, your indicator works great on it's own using the week bar as it's input. So if this is the only value you need, then don't use the Daily bar as an input for the indicator.

              My question
              Patrick, but I don't use Daily as input. As you see in indicator script
              Add(MyInstrum1, PeriodType.Week, 1);
              Than in strategy I only use string symbol as input for indicator. Main instrument data (not for indicator) still in Daily bars. Please comment.

              Patrick answer
              Originally Posted by alexstox
              Patrick, CloseWeekPer is indicator. I add it in strategy, where main instrument series is Daily.
              This would then be used as the PeriodType for Add(CloseWeekPer(MyInstrum1));
              You stated your main series is a daily bar, this would be the primary series (0). This would then be the input for Add(CloseWeekPer(MyInstrum1));. And thus be printed from your strategy with the Daily bars as the input.


              My question
              Is there any sample how to add PeriodType for own indicator in strategy?
              I mean how to call that parameter from strategy to use in indicator? Because as I know I can't do this via string PerType=PeriodType.Week; and use it than in indicator code CloseWeekPer(MyInstrum1, PerType));

              ChelseaB answer
              It is not possible to add an indicator to a strategy using a secondary data series.

              When using the Add() method to add an indicator to a strategy, the primary data series (the data series of the chart) will be the data series that is used for the indicator. It is not possible to change this.

              It would be possible, however, to add a secondary data series of 1 week to the indicator and process only during that bars in progress.


              My answer
              I'm confused. I used indicator, that have only Weekly data series. In strategy it take only Symbol of instrument. Than there is adding of weekly data series in indicator code. So, I did everything you wrote to do.
              in strategy Add(CloseWeek("MSFT"));
              in indicator Add("MSFT", PeriodType.Week, 1);

              Comment


                #37
                Hi alexstox,

                If you are making calculations on a week size bar, the value is not going to change until that bar closes.

                So I think what you are wanting is not possible.

                From Patrick's explanation:
                You have two input series, a Week and a Day series. The Day bars are not going to have the same value from the ClosePerWeek() indicator as the Week bars on the close of the of the week bar, as the Day bar is only looking at that day where the Week bar encompasses the entire week of data.
                Are you using a week data series in the indicator and expecting the values calculated to be different every day?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #38
                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hi alexstox,

                  If you are making calculations on a week size bar, the value is not going to change until that bar closes.

                  So I think what you are wanting is not possible.

                  From Patrick's explanation:


                  Are you using a week data series in the indicator and expecting the values calculated to be different every day?
                  OMG! Guys, I only need WeekClose=1.050 to be 1.050 on next Mon, Tue, Wed, Thu, and on Fri new WeekClose. As you see from attached Output, on Fri WeekClose=true, but follow days (next after last WeekClose) WeekClose=false. This problem I need to solve

                  Comment


                    #39
                    Hi alexstox,

                    I think the issue is with the bool series and being synced with the primary data series.

                    When a custom data series or bool series is added, it syncs with the primary series which would be the day series. This means the value is set once per week and all the days inbetween are not set. Any value that is not set is null and will probably return false.

                    What I think needs to happen is in BarsInProgress 0 you should set the value of the current bar of the bool series to the value of the previous bar of the bool series.

                    This will cause the new values to continue until the week bar closes and updates the value.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #40
                      Originally posted by NinjaTrader_ChelseaB View Post
                      Hi alexstox,

                      I think the issue is with the bool series and being synced with the primary data series.

                      When a custom data series or bool series is added, it syncs with the primary series which would be the day series. This means the value is set once per week and all the days inbetween are not set. Any value that is not set is null and will probably return false.

                      What I think needs to happen is in BarsInProgress 0 you should set the value of the current bar of the bool series to the value of the previous bar of the bool series.

                      This will cause the new values to continue until the week bar closes and updates the value.
                      THANK YOU VERY MUCH!!! I WILL TRY THIS!!!

                      P.S. I asked before. Is possible smth like this in strategy Add(CloseWeek, "MSFT", PeriodType.Week, 1);
                      I mean how to add this input parameter for indicator? Will this help?

                      Comment


                        #41
                        Hi alexstox,

                        As mentioned in post #33 this is not possible.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #42
                          Originally posted by NinjaTrader_ChelseaB View Post
                          Hi alexstox,

                          I think the issue is with the bool series and being synced with the primary data series.

                          When a custom data series or bool series is added, it syncs with the primary series which would be the day series. This means the value is set once per week and all the days inbetween are not set. Any value that is not set is null and will probably return false.

                          What I think needs to happen is in BarsInProgress 0 you should set the value of the current bar of the bool series to the value of the previous bar of the bool series.

                          This will cause the new values to continue until the week bar closes and updates the value.
                          Something like this after the end of BarsInProgress==1
                          Code:
                          if (BarsInProgress==0) //start BarsInProgress2
                          {
                          if(momUP==1) {dOWNweek.Set(false); uPweek.Set(true);}
                          else if(momDW==1) {dOWNweek.Set(true); uPweek.Set(false);}
                          } //end BarsInProgress2

                          Comment


                            #43
                            Hi alexstox,

                            While adding a condition statement in there may not hurt anything, I do not know the logic of your script to say this is correct.

                            I was thinking something like:

                            if (BarsInProgress == 0)
                            {
                            dOWNweek.Set(dOWNweek[1]);
                            uPweek.Set(uPweek[1]);
                            }

                            This just sets to the old value.
                            When BarsInProgress is 1, then it overwrites the value and you get a new value.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #44
                              Originally posted by NinjaTrader_ChelseaB View Post
                              Hi alexstox,
                              While adding a condition statement in there may not hurt anything, I do not know the logic of your script to say this is correct.
                              I was thinking something like:
                              if (BarsInProgress == 0)
                              {
                              dOWNweek.Set(dOWNweek[1]);
                              uPweek.Set(uPweek[1]);
                              }
                              This just sets to the old value.
                              When BarsInProgress is 1, then it overwrites the value and you get a new value.
                              THANK YOU THANK YOU THANK YOU !!!!
                              I wish good luck, best sales, big bonuses and nice weekends!!!

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by rocketman7, Today, 02:12 AM
                              5 responses
                              22 views
                              0 likes
                              Last Post rocketman7  
                              Started by trilliantrader, 04-18-2024, 08:16 AM
                              7 responses
                              28 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by samish18, 04-17-2024, 08:57 AM
                              17 responses
                              66 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by briansaul, Today, 05:31 AM
                              1 response
                              15 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by PaulMohn, Today, 03:49 AM
                              1 response
                              12 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X