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

Daily to Intraday

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

    Daily to Intraday

    how do i use indicators which uses the previous day's daily data to be calculated and transpose those calculations to be used in today's trading?

    #2
    kaywai, you could work this out be accessing the values returned by the PriorDayOHLC indicator / method -



    Of course those would be tied to your session begin and end settings on the chart, so please ensure those are adjusted as needed then as you apply the final indicator.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand, Thank you for your prompt reply.

      To be more specific, I am looking for the True High and True Low of the previous day. This is calculated as the higher of the previous day's high and close 2 days ago for the true high and the lower of the previous day's low close 2 days ago for the true low.

      I hope that it can be achieved

      Comment


        #4
        kaywai,

        You would need to use PriorDayOHLC and grab the highs of all the days you are interested in and then running math calculations to determine your true high.

        You can use GetBar() to get the correct [] index value to plug into PriorDayOHLC() to get different days. Running PriorDayOHLC() on a bar index [] of yesterday will give you the high/lows of the day before yesterday.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          ok. what am i doing wrong here?

          #region Variables
          privatedouble truelow = 0;
          privatedouble truehigh = 0;
          #endregion

          protectedoverridevoid Initialize()
          {
          CalculateOnBarClose =
          true;
          Overlay =
          false;
          PriceTypeSupported =
          false;
          }

          protectedoverridevoid OnBarUpdate()
          {
          double value1 = Bars.GetSessionBar(2).Close;
          double value2 = PriorDayOHLC().PriorLow[0];
          double value3 = PriorDayOHLC().PriorHigh[0];
          double truerange = 0;
          {
          if (value3 > value1)
          {truehigh = value3};
          elseif (value3 < value1)
          {truehigh = value1};

          if (value2 > value1)
          {truelow = value1};
          elseif (value2 < value1)
          {truelow = value2};
          truerange -= truehigh - truelow;
          }

          }
          Last edited by kaywai; 01-19-2010, 07:17 AM.

          Comment


            #6
            kaywai, please add Prints to doublecheck all your values return what you would expect them to -

            BertrandNinjaTrader Customer Service

            Comment


              #7
              Bertrand, i've got ";" errors and "else" errors in the script. Can you tell me what is wrong with the "if" statements?

              Comment


                #8
                ok Bertrand, let me give a go at debugging

                Comment


                  #9
                  Never mind
                  Last edited by eDanny; 01-19-2010, 10:04 AM.
                  eDanny
                  NinjaTrader Ecosystem Vendor - Integrity Traders

                  Comment


                    #10
                    Hi Bertrand, No errors in the script now but getting zero output. I tried using Print function but not sure where to find output. The script wouldn't accept TraceOrders = true either. Would you mind taking a look and giving some pointers?

                    I'm using the previous day's true range to determine the possible trading range for today based on today's open. True Range is defined as truehigh - truelow, where true high is the higher of yesterday's high or the close of 2 days ago, while true low is the lower of yesterday's low or the close of 2 days ago.

                    Once those point have been determined, I would like to draw squares at those prices.

                    I've attached the script. Thanks in advance!
                    Attached Files
                    Last edited by kaywai; 01-20-2010, 07:17 AM.

                    Comment


                      #11
                      Please try adding this check at the OnBarUpdate() start -

                      Code:
                      if (CurrentBar < 1) return;
                      It plots the dots you intended then for me on ES 1 min data.


                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        Hi Bertrand, The good news is some of the dots got plotted!

                        The bad news: 1) 4 out 6 dots got plotted
                        2) the dots seem to arbitrarily placed

                        Comment


                          #13
                          The dots would be placed at your designated Y Axis values - please print those to doublecheck if your calcs hit home the way you expect - the output window can be opend via Tools > Output window from the Control Center.
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            Hi Bertrand,

                            For some strange reason (according to the output), lines 56-63 (calculation of truehigh) are not working according to script whereas lines 64-71 (calculation of truelow) are working properly. Would you mind having a look? The lowest 2 squares (rebodownentry & rebodownexit) are not drawn because they are off the chart. Is it possible to have them displayed?
                            The output is attached. I've also attached the script as I had to make some changes.
                            Attached Files

                            Comment


                              #15
                              Try using this if structure in the script, this should give you the correct trueHigh and trueLow values, you can then take it from there -

                              Code:
                               
                              if (value3 > value1)
                              truehigh = value3;
                               
                              else truehigh = value1;
                               
                              if (value2 < value1)
                              truelow = value2;
                               
                              else truelow = value1;
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by samish18, Today, 01:01 PM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Started by WHICKED, Today, 12:56 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by cre8able, Today, 01:16 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post cre8able  
                              Started by chbruno, 04-24-2024, 04:10 PM
                              2 responses
                              47 views
                              0 likes
                              Last Post chbruno
                              by chbruno
                               
                              Started by WHICKED, Today, 12:45 PM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X