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

Combined Weekly/Daily charts

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

    Combined Weekly/Daily charts

    I have a strategy that trades daily bars, I want to add some weekly trend lines so when I am analyzing the strategy I can see the weekly and daily trend lines.

    How do I go about doing this? I can code if I need to.

    Thanks,
    Erik

    #2
    You would need to add the weekly time frame to your strategy and do it as a multi-time framed one. http://www.ninjatrader-support.com/H...ameInstruments
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Can you give me a little more detail on how to do this.

      I am running a strategy (MSFT daily).
      I am looking at RSI for MSFT daily (i.e. I used the Add method in Initialize).
      I would like add this line of code to the Initialize method:
      Add(PeriodType.Day, 3);
      I would like to plot the RSI for the 3 day bars as well.

      How would I code something like this?

      Thanks,
      Erik

      Comment


        #4
        Erik, you would need to work with BarsArray[1] then (the added one) to calculate your RSI based on this series -

        BertrandNinjaTrader Customer Service

        Comment


          #5
          I still do not get it. If I want to plot the RSI for the 3 day bars would I need a new custom indicator or is their a way to add something for the 3 bar RSI to the Initialize method? What would be an example of some code to get the 3 Bar RSI to plot at the bottom of the chart below the one bar RSI?

          Thanks,
          Erik

          Comment


            #6
            You would need to code / calculate the value for the 3 day RSI in a strategy, as indicators for 6.5 don't support the multiseries approach we have in strategies (this is added in NT7 - http://www.ninjatrader.com/webnew/NT7/NinjaTrader7.html).

            To display the calculated RSI value of the added series, you could work with Strategy Plot reference sample -

            When running a strategy on a chart you may find the need to plot values onto a chart. If these values are internal strategy calculations that are difficult to migrate to an indicator, you can use the following technique to achieve a plot. NinjaTrader 8 With NinjaTrader 8 we introduced strategy plots which provide the ability
            BertrandNinjaTrader Customer Service

            Comment


              #7
              I looked at the plot samples; I did not know that indicator and functionality existed.
              From the link:
              Note: This technique has limited functionality. It will NOT work for charts in the Strategy Analyzer during backtesting, but it will work on real-time charts.

              This is exactly what I want to achieve.
              I created an indicator to show multi timeframe simple moving averages:

              The indicator code:

              Code:
               
              [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Initialize() {[/SIZE]
              [SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Plot[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ThePlot = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Plot[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Color[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].FromKnownColor([/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]KnownColor[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].DarkCyan),[/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af] PlotStyle[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Line, [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"TheLine"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
              [SIZE=2]Add(ThePlot);[/SIZE]
              [SIZE=2]CalculateOnBarClose = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
              [SIZE=2]Overlay = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
              [SIZE=2]PriceTypeSupported = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
              [SIZE=2]}[/SIZE]
              [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OnBarUpdate() {[/SIZE]
              [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (CurrentBar < [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].periods) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
              [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] inputSum = 0.0;[/SIZE]
              [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] inputAvg = 0.0;[/SIZE]
              [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Remainder = CurrentBar % [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].periods;[/SIZE]
              [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i = Remainder; i < Remainder + [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].periods; i++) {[/SIZE]
              [SIZE=2]inputSum += Input[i];[/SIZE]
              [SIZE=2]}[/SIZE]
              [SIZE=2]inputAvg = inputSum / [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].periods;[/SIZE]
              [SIZE=2]TheLine.Set(inputAvg);[/SIZE]
              [SIZE=2]}[/SIZE]
              The Strategy Code:

              Code:
              [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Initialize() {[/SIZE]
              [SIZE=2]Add(SMA(Close, 14));[/SIZE]
              [SIZE=2]SMA(Close, 14).Plots[0].Pen.Color = [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Color[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Yellow;[/SIZE]
              [SIZE=2]SMA(Close, 14).Plots[0].Pen.Width = 2;[/SIZE]
              [SIZE=2]Add(MyInd(SMA(Close, 14), 5));[/SIZE]
              [SIZE=2]MyInd(SMA(Close, 14), 5).Plots[0].Pen.Color = [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Color[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Blue;[/SIZE]
              [SIZE=2]MyInd(SMA(Close, 14), 5).Plots[0].Pen.Width = 4;[/SIZE]
              [SIZE=2]Add(MyInd(SMA(Close, 14), 25));[/SIZE]
              [SIZE=2]MyInd(SMA(Close, 14), 25).Plots[0].Pen.Color = [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Color[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Black;[/SIZE]
              [SIZE=2]MyInd(SMA(Close, 14), 25).Plots[0].Pen.Width = 6;[/SIZE]
              [SIZE=2]Add(SMA(Close, 200));[/SIZE]
              [SIZE=2]SMA(Close, 200).Plots[0].Pen.Color = [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Color[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].LightCoral;[/SIZE]
              [SIZE=2]SMA(Close, 200).Plots[0].Pen.Width = 2;[/SIZE]
              [SIZE=2]CalculateOnBarClose = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
              [SIZE=2]}[/SIZE]
              I attached a screen shot from Strategy Analyzer.

              Does this look valid to you for multi time frame sma lines?

              Do you think I could pull something like this off in a similar fashion for RSI?

              Or am I on the wrong track?

              Thanks,
              Erik
              Attached Files

              Comment


                #8
                Hi Erik, looks valid to me - though for this not sure why you need a strategy, you add no second series to to the script, but approximate via longer lenghs, right?

                I'll attach how you could use our Strategy Plot sample for showing the RSI from the added, longer series, here a 10 min chart. Both RSI's on second panel, from there you should be able to tweak to what you need.
                Attached Files
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by RaygunWizzle, Today, 09:30 AM
                2 responses
                9 views
                0 likes
                Last Post bltdavid  
                Started by Ashkam, Today, 09:28 AM
                0 responses
                5 views
                0 likes
                Last Post Ashkam
                by Ashkam
                 
                Started by gbourque, Today, 08:20 AM
                1 response
                9 views
                0 likes
                Last Post gbourque  
                Started by carnitron, 04-27-2024, 08:42 PM
                1 response
                16 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by WHICKED, 04-26-2024, 12:56 PM
                3 responses
                27 views
                0 likes
                Last Post WHICKED
                by WHICKED
                 
                Working...
                X