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

Indicator based on daily values displayed on minute chart

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

    Indicator based on daily values displayed on minute chart

    how would you create an indicator thats values are based off daily time frame values
    but you would like to display on panel 1 of a minute chart

    #2
    fiddy,

    NinjaScript does supports multi-time frame and instruments in a single script. NinjaTrader does provide two examples of this: SampleMultiInstrument and SampleMultiTimeFrame.

    It would be helpful for you to review those sample strategies.

    Here is also another example to help you get started:

    protected override void Initialize()
    {
    Overlay = true;
    CalculateOnBarClose = false;

    Add(PeriodType.Day, 1); //Add D1 DataSerie
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 1) //For D1 dataseries
    {
    double HighD1 = Highs[1][0];
    double LowD1 = Lows[1][0];
    }

    if (BarInProgress == 0) //For current DataSeries (M1)
    {
    double variable = High[0] - Low[0];
    }
    }

    You can read more about multi-time frame and multi-instruments in the following link: http://ninjatrader.com/support/helpG...nstruments.htm
    Bobby Y.NinjaTrader Customer Service

    Comment


      #3
      Bobby, below is what i have currently - it plots correctly when the time frame is daily
      but doesnt plot anything when the timeframe is minutes. what am i missing?
      i want to use this indicator on minute charts but for the ranges to be based on daily data high/lo/ atr etc


      protected override void Initialize()
      {
      CalculateOnBarClose = false;
      Add(PeriodType.Day, 1);
      Overlay = true ;
      }


      protected override void OnBarUpdate()
      {

      if (CurrentBar < 1) return;



      HighLimit .Set(Highs[1][1] + 1*ADX(14)[0]);
      LowLimit .Set(Lows[1][1] - 1*ADX(14)[0]]);

      }

      Comment


        #4
        fiddy,

        Thanks for the response. After looking into this, I've included an edited version of your code.

        Code:
        protected override void Initialize()
        {
            Add(PeriodType.Day, 1);
            CalculateOnBarClose = false;
            Overlay = true;
        }
        
        protected override void OnBarUpdate()
        {
            if (CurrentBars[1] < 1)
                return;
        
            if (BarsInProgress == 0)
            {
                HighLimit.Set(Highs[1][1] + 1 * ADX(14)[0]);
                LowLimit.Set(Lows[1][1] - 1 * ADX(14)[0]);
            }
        }
        Bobby Y.NinjaTrader Customer Service

        Comment


          #5
          hi Bobby, i have amended my code to reflect your latest update but this seems to have made it worse. now it doesnt show anything on the daily or minute time frames . ive attached the script for your reference
          Attached Files

          Comment


            #6
            i didnt look at ur file bc i dont like downloading stuff from users. so i have to ask. did u include the plots correctly? further: your ADX will be a primary timeframe ADX, is that intentional?
            i included my full code which does plot something on my minute timeframe.

            Code:
                    protected override void Initialize()
                    {
                        Add(PeriodType.Day, 1);
                        CalculateOnBarClose = false;
                        Overlay = true;
                        
                        Add(new Plot(Color.Green, "HighLimit"));
                        Add(new Plot(Color.Orange, "LowLimit"));        
                    }
            
            
                    protected override void OnBarUpdate()
                    {
                        if (CurrentBars[1] < 1)
                            return;
                        
                        if (BarsInProgress == 0)
                        {
                            Value.Set(Highs[1][1] + 1 * ADX(14)[0]);
                            LowLimit.Set(Lows[1][1] - 1 * ADX(14)[0]);
                        }
                    }
            
                    #region Properties
                    [Browsable(false)]
                    [XmlIgnore()]
                    public DataSeries LowLimit
                    {
                        get { return Values[1]; }
                    }
                    [Browsable(false)]
                    [XmlIgnore()]
                    public DataSeries Default
                    {
                        get { return Values[0]; }
                    }
                    #endregion
            Last edited by BigRo; 12-29-2015, 08:40 AM.

            Comment


              #7
              fiddy,

              To make sure we are on the same page, could you provide an screenshot example of what you want the indicator to look like? I've made some changes to what I think you wanted, the file is attached to this response.
              Attached Files
              Bobby Y.NinjaTrader Customer Service

              Comment


                #8
                thanks Bobby / BigRo - i made some amendments to your code to fix up how it should work (ADX bars array 1) but it is still not ploting correctly on minute chart

                i have attached picture of how i expected it to look and how it currently does.
                As you can see it is only plotting the most recent day on the minute chart and the value seems to be incorrect.

                Based on the daily chart values of 107.65 for price and 29.57 for ADX - id expect a flat line across approx 138 on the minute chart for the most recent day but currently it is at 162.and nothing is displayed for previous days

                protected override void Initialize()
                {
                Add(new Plot(Color.Orange, "HighLimit"));
                Add(new Plot(Color.Green, "LowLimit"));

                Add(PeriodType.Day, 1);

                CalculateOnBarClose = false;
                Overlay = true;
                }

                protected override void OnBarUpdate()
                {
                if(CurrentBars[1] < 1) return;

                if(BarsInProgress == 0)
                {
                HighLimit.Set(Highs[1][1] + 1 * ADX(BarsArray[1],14)[0]);
                LowLimit.Set(Lows[1][1] - 1 * ADX(BarsArray[1],14)[0]);
                }
                }
                Attached Files

                Comment


                  #9
                  sure ur on the right dailybar?
                  id suggest
                  Code:
                  HighLimit.Set(Highs[1][0] + 1 * ADX(BarsArray[1],14)[0]);
                  LowLimit.Set(Lows[1][0] - 1 * ADX(BarsArray[1],14)[0]);

                  Comment


                    #10
                    i have corrected it now. this is what i wanted. However i still cannot get plots to work on the minute timeframe

                    HighLimit.Set(Highs[1][1] + 1 * ATR(BarsArray[1],14)[1]);
                    LowLimit.Set(Lows[1][1] - 1 * ATR(BarsArray[1],14)[1]);

                    Comment


                      #11
                      Bobby, i still have not been able to get this to plot correctly
                      the plot for the high and low range should be a straight line across
                      for some reason it is plotting an arc to start of with before settling down to straight line
                      can you see what is causing the arc?
                      Attached Files

                      Comment


                        #12
                        Hello,
                        I am currently testing this and looking into this further.
                        Thank you for your patience.
                        Cody B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Tim-c, Today, 10:58 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post Tim-c
                        by Tim-c
                         
                        Started by traderqz, Yesterday, 09:06 AM
                        3 responses
                        21 views
                        0 likes
                        Last Post NinjaTrader_ThomasC  
                        Started by f.saeidi, Today, 10:19 AM
                        1 response
                        5 views
                        0 likes
                        Last Post NinjaTrader_BrandonH  
                        Started by kujista, Today, 06:23 AM
                        5 responses
                        18 views
                        0 likes
                        Last Post kujista
                        by kujista
                         
                        Started by traderqz, Today, 12:06 AM
                        3 responses
                        6 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Working...
                        X