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

Plot 2 CCI on same panel

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

    Plot 2 CCI on same panel

    Hi All

    I am trying to plot 2 CCI in the same panel IE panel 2

    these 2 are part of a strategy and when I use addchartindicator they need to plot in same Panel

    any ideas could help as I searched everywhere and didnt find a solution

    Thank you in advance

    Richard

    #2
    Hello Richard,

    Thanks for your post.

    You would need to set IsOverlay to false, change the Panel property that the indicator plots to in the strategy, and call AddChartIndicator() to add the indicator to the strategy.

    See the attached example script which demonstrates plotting an indicator from a strategy in a panel other than the price panel.

    Also, see the help guide documentation below for more information.
    AddChartIndicator(): https://ninjatrader.com/support/help...tindicator.htm
    Adding Indicators to Strategies: https://ninjatrader.com/support/help..._strategie.htm

    Let us know if we may assist further.
    Attached Files
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thank you Brandon it looks like exactly what i was looking for Will work on it now

      Comment


        #4
        it is perfect thanks again

        Comment


          #5
          Originally posted by NinjaTrader_BrandonH View Post
          Hello Richard,

          Thanks for your post.

          You would need to set IsOverlay to false, change the Panel property that the indicator plots to in the strategy, and call AddChartIndicator() to add the indicator to the strategy.

          See the attached example script which demonstrates plotting an indicator from a strategy in a panel other than the price panel.

          Also, see the help guide documentation below for more information.
          AddChartIndicator(): https://ninjatrader.com/support/help...tindicator.htm
          Adding Indicators to Strategies: https://ninjatrader.com/support/help..._strategie.htm

          Let us know if we may assist further.
          It is working fine but 1 little problem when i restart NT then they go into 2 separate panels

          any ideas why??

          if i remove the strategy and re insert it then it is ok

          Comment


            #6
            Originally posted by richbois View Post

            It is working fine but 1 little problem when i restart NT then they go into 2 separate panels

            any ideas why??

            if i remove the strategy and re insert it then it is ok
            Hi richbois,

            Brandon's example scripts contain SMA/EMA and ADL/MACD pairs. How do you have the CCI/CCI pair (i. e. two CCI) in your scripts. Please, what are your CCI settings ? Meanwhile, is it feasible to implement your strategy with just Indicators instead of Strategy.

            omololu

            Comment


              #7
              Hello richbois,

              Thanks for your note.

              "when i restart NT then they go into 2 separate panels. any ideas why??"

              I am not able to reproduce the behavior you are reporting. Upon enabling the strategy on a chart window, the indicator plots are placed in panel 2 of the chart.

              Occasionally, the indicators may seem to plot on the price panel when the strategy is still calculating. However, when the strategy is done calculating the plots from the indicators are placed in panel 2.

              Let us know if we may assist further.
              Brandon H.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by omololu View Post

                Hi richbois,

                Brandon's example scripts contain SMA/EMA and ADL/MACD pairs. How do you have the CCI/CCI pair (i. e. two CCI) in your scripts. Please, what are your CCI settings ? Meanwhile, is it feasible to implement your strategy with just Indicators instead of Strategy.

                omololu
                I created 2 CCI with the parameters hard coded called I1 I2

                this is the code in the strategy

                else if (State == State.DataLoaded)
                {
                f1 = F1(Close, true,false,1,1);
                i3 = I3();
                i1 = I1();
                i2 = I2();

                i1.Panel = i2.Panel = 1;

                AddChartIndicator(f1);
                AddChartIndicator(i3);
                AddChartIndicator(i1);
                AddChartIndicator(i2);

                the strategy takes trades when the conditions are met

                Comment


                  #9
                  Originally posted by NinjaTrader_BrandonH View Post
                  Hello richbois,

                  Thanks for your note.

                  "when i restart NT then they go into 2 separate panels. any ideas why??"

                  I am not able to reproduce the behavior you are reporting. Upon enabling the strategy on a chart window, the indicator plots are placed in panel 2 of the chart.

                  Occasionally, the indicators may seem to plot on the price panel when the strategy is still calculating. However, when the strategy is done calculating the plots from the indicators are placed in panel 2.

                  Let us know if we may assist further.
                  Sorry i missed you answer. The problem is that I1 and I2 end up in panel 2 and 3 instead of just Panel 2

                  Comment


                    #10
                    Hello richbois and omololu,

                    Thanks for your notes.

                    I am unsure as to why the indicators are appearing in panel 2 and panel 3 of the chart based on the code you shared.

                    That said, see the attached example script which demonstrates plotting 2 CCI indicators in panel 2 on a chart from a strategy.

                    Let us know if we may assist further.

                    Attached Files
                    Brandon H.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by richbois View Post

                      I created 2 CCI with the parameters hard coded called I1 I2

                      this is the code in the strategy

                      else if (State == State.DataLoaded)
                      {
                      f1 = F1(Close, true,false,1,1);
                      i3 = I3();
                      i1 = I1();
                      i2 = I2();

                      i1.Panel = i2.Panel = 1;

                      AddChartIndicator(f1);
                      AddChartIndicator(i3);
                      AddChartIndicator(i1);
                      AddChartIndicator(i2);

                      the strategy takes trades when the conditions are met
                      Hi,

                      I can't seem to see "the conditions" in your above codes. Please what are the conditions ? I want to implement your method using just Indicators ONLY.

                      omololu

                      Comment


                        #12
                        here is the clean up code that does the same issue when i close NT and restart

                        #region Using declarations
                        using System;
                        using System.Collections.Generic;
                        using System.ComponentModel;
                        using System.ComponentModel.DataAnnotations;
                        using System.Linq;
                        using System.Text;
                        using System.Threading.Tasks;
                        using System.Windows;
                        using System.Windows.Input;
                        using System.Windows.Media;
                        using System.Xml.Serialization;
                        using NinjaTrader.Cbi;
                        using NinjaTrader.Gui;
                        using NinjaTrader.Gui.Chart;
                        using NinjaTrader.Gui.SuperDom;
                        using NinjaTrader.Gui.Tools;
                        using NinjaTrader.Data;
                        using NinjaTrader.NinjaScript;
                        using NinjaTrader.Core.FloatingPoint;
                        using NinjaTrader.NinjaScript.Indicators;
                        using NinjaTrader.NinjaScript.DrawingTools;
                        #endregion

                        //This namespace holds Strategies in this folder and is required. Do not change it.
                        namespace NinjaTrader.NinjaScript.Strategies
                        {
                        public class Ninjatest : Strategy
                        {


                        private F1 f1;
                        private I3 i3;
                        private I1 i1;
                        private I2 i2;


                        protected override void OnStateChange()
                        {
                        if (State == State.SetDefaults)
                        {
                        Description = NinjaTrader.Custom.Resource.NinjaScriptStrategyDes criptionSampleATMStrategy;
                        Name = "Ninjatest";


                        // This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations
                        // See the Help Guide for additional information

                        Calculate = Calculate.OnPriceChange;
                        BarsRequiredToTrade = 21 ;
                        EntriesPerDirection = 1;
                        EntryHandling = EntryHandling.AllEntries;
                        IsExitOnSessionCloseStrategy = true;
                        ExitOnSessionCloseSeconds = 30;
                        IsFillLimitOnTouch = false;
                        MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
                        OrderFillResolution = OrderFillResolution.Standard;
                        Slippage = 0;
                        StartBehavior = StartBehavior.WaitUntilFlat;
                        TimeInForce = TimeInForce.Gtc;
                        TraceOrders = false;
                        RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
                        StopTargetHandling = StopTargetHandling.PerEntryExecution;

                        // Disable this property for performance gains in Strategy Analyzer optimizations
                        // See the Help Guide for additional information
                        IsInstantiatedOnEachOptimizationIteration = true;

                        }

                        else if (State == State.Configure)
                        {

                        }

                        else if (State == State.DataLoaded)
                        {
                        f1 = F1(Close, true,false,1,1);
                        i3 = I3();
                        i1 = I1();
                        i2 = I2();

                        i1.IsOverlay = false;
                        i2.IsOverlay = false;

                        i1.Panel = i2.Panel = 1;

                        AddChartIndicator(f1);
                        AddChartIndicator(i3);
                        AddChartIndicator(i1);
                        AddChartIndicator(i2);
                        }


                        }

                        protected override void OnBarUpdate()
                        {

                        }



                        public override string DisplayName
                        {
                        get { return Name ;}
                        }


                        }
                        }

                        Comment


                          #13
                          Originally posted by richbois View Post
                          here is the clean up code that does the same issue when i close NT and restart

                          #region Using declarations
                          using System;
                          using System.Collections.Generic;
                          using System.ComponentModel;
                          using System.ComponentModel.DataAnnotations;
                          using System.Linq;
                          using System.Text;
                          using System.Threading.Tasks;
                          using System.Windows;
                          using System.Windows.Input;
                          using System.Windows.Media;
                          using System.Xml.Serialization;
                          using NinjaTrader.Cbi;
                          using NinjaTrader.Gui;
                          using NinjaTrader.Gui.Chart;
                          using NinjaTrader.Gui.SuperDom;
                          using NinjaTrader.Gui.Tools;
                          using NinjaTrader.Data;
                          using NinjaTrader.NinjaScript;
                          using NinjaTrader.Core.FloatingPoint;
                          using NinjaTrader.NinjaScript.Indicators;
                          using NinjaTrader.NinjaScript.DrawingTools;
                          #endregion

                          //This namespace holds Strategies in this folder and is required. Do not change it.
                          namespace NinjaTrader.NinjaScript.Strategies
                          {
                          public class Ninjatest : Strategy
                          {


                          private F1 f1;
                          private I3 i3;
                          private I1 i1;
                          private I2 i2;


                          protected override void OnStateChange()
                          {
                          if (State == State.SetDefaults)
                          {
                          Description = NinjaTrader.Custom.Resource.NinjaScriptStrategyDes criptionSampleATMStrategy;
                          Name = "Ninjatest";


                          // This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations
                          // See the Help Guide for additional information

                          Calculate = Calculate.OnPriceChange;
                          BarsRequiredToTrade = 21 ;
                          EntriesPerDirection = 1;
                          EntryHandling = EntryHandling.AllEntries;
                          IsExitOnSessionCloseStrategy = true;
                          ExitOnSessionCloseSeconds = 30;
                          IsFillLimitOnTouch = false;
                          MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
                          OrderFillResolution = OrderFillResolution.Standard;
                          Slippage = 0;
                          StartBehavior = StartBehavior.WaitUntilFlat;
                          TimeInForce = TimeInForce.Gtc;
                          TraceOrders = false;
                          RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
                          StopTargetHandling = StopTargetHandling.PerEntryExecution;

                          // Disable this property for performance gains in Strategy Analyzer optimizations
                          // See the Help Guide for additional information
                          IsInstantiatedOnEachOptimizationIteration = true;

                          }

                          else if (State == State.Configure)
                          {

                          }

                          else if (State == State.DataLoaded)
                          {
                          f1 = F1(Close, true,false,1,1);
                          i3 = I3();
                          i1 = I1();
                          i2 = I2();

                          i1.IsOverlay = false;
                          i2.IsOverlay = false;

                          i1.Panel = i2.Panel = 1;

                          AddChartIndicator(f1);
                          AddChartIndicator(i3);
                          AddChartIndicator(i1);
                          AddChartIndicator(i2);
                          }


                          }

                          protected override void OnBarUpdate()
                          {

                          }



                          public override string DisplayName
                          {
                          get { return Name ;}
                          }


                          }
                          }
                          Thanks. I'll test-drive it.

                          omololu

                          Comment


                            #14
                            Brandon i used your script and put it on the chart all was good same as mine but then i close NT and restarted and this is what i get see picture
                            Attached Files

                            Comment


                              #15
                              Had the same experience too ... even with Brandon's first example.

                              omololu

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ageeholdings, Today, 07:43 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post ageeholdings  
                              Started by pibrew, Today, 06:37 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post pibrew
                              by pibrew
                               
                              Started by rbeckmann05, Yesterday, 06:48 PM
                              1 response
                              14 views
                              0 likes
                              Last Post bltdavid  
                              Started by llanqui, Today, 03:53 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post llanqui
                              by llanqui
                               
                              Started by burtoninlondon, Today, 12:38 AM
                              0 responses
                              12 views
                              0 likes
                              Last Post burtoninlondon  
                              Working...
                              X