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

Plotting Daily ADX on Tick Chart

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

    Plotting Daily ADX on Tick Chart

    Hi NT,

    Looking for some guidance please for a Strategy Script.
    I have a strategy being applied to a Tick chart.
    I also have indicator's (derived from the tick data) applied to the strategy chart.
    I do so with this code (so far so good):

    Code:
    else if (State == State.DataLoaded)
    {
    ATRplot = ATR(200);
    ATRplot.Plots[0].Brush = Brushes.Green;
    ATRplot.Plots[0].Width = 2;
    AddChartIndicator(ATRplot);
    }
    I am now trying to plot a Daily (ADX) indicator to the same strategy script.
    ..but i think I am missing something.... because it seems like the ADX is only being partially plotted.

    Code:
    else if (State == State.Configure)
    {
    AddDataSeries(BarsPeriodType.Day, 1);
    }
    else if (State == State.DataLoaded)
    {
    
    dailyADX = new Series<double>(BarsArray[1]);
    
    dailyADXplot = ADX(BarsArray[1], 14);
    dailyADXplot.Plots[0].Brush = Brushes.Cyan;
    dailyADXplot.Plots[0].Width = 2;
    dailyADXplot.Panel=3;
    AddChartIndicator(dailyADXplot);
    }
    Am I missing something here? It seems like my ADX is only plotting on the far left on the pane and only for a limited tick bar range, where as my tick based indicator work as a expected for the full length of the pane. I trying to plot a Daily Bar ADX on a Tick chart. I have attached a screenshot for added clarity
    Attached Files

    #2
    Hello akvevo,

    If you are trying to plot an indicator with a larger bar type on to a chart with a smaller bar type, you will have to make sure that a plot exists for each tick. As the daily value would not change, it would only show as a straight line for that daily value, until the daily value gets updated again.

    I have posted a sample script that demonstrates how you can use a "Shell Indicator" to hold the values for a plot so it can align with the tick series.

    Here is where you can find it: http://ninjatrader.com/support/forum...6&postcount=49

    Please let me know if this does not resolve your inquiry.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks Jim,

      I now understand the task at hand, but I fail to see how the test script illustrates how the shell indicator holds the values; SMA values in this example.

      I see you declare the shell private TestDailySMAShell SMA1; in the strategy class.
      Then you add a daily series and then AddChartIndicator, but i dont see the SMA indicator method anywhere in the example.. If I run the strategy, nothing is plotted..

      Code:
      	else if (State == State.Configure)
      			{
      				AddDataSeries(Data.BarsPeriodType.Day, 1);
      			}
      			else if (State == State.DataLoaded)
      			{				
      				SMA1				= TestDailySMAShell();
      				AddChartIndicator(TestDailySMAShell());
      			}
      		}
      
      		protected override void OnBarUpdate()
      		{
      			
      		}
      	}
      Also, even if I try to apply the logic above into my strategy in an attempt to make sense of it, i start by declaring the shell indicator:

      Code:
      private dailyADXplotShell ADX1;
      But this creates an error: "The type or namespace name 'dailyADXplotShell' could not be found (are you missing a using directive or an assembly reference?) CS0246 "

      For these reasons, I have a feeling the example code is lacking additional context
      Last edited by akvevo; 07-24-2017, 04:03 PM.

      Comment


        #4
        Hello akvevo,

        The SMA indicator is added inside of the TestDailySMAShell indicator. This "Shell indicator" adds a daily data series and sets that value for the indicator's plot to be the value calculated by the additional data series.

        As the additional data series takes a full day to update, the Value for the plot will use the previous value until a new value is created by the daily series.

        Code:
        if (CurrentBars[0] < 2 || CurrentBars[1] < 1)
        return;
        
        if (BarsInProgress == 1 || Times[0][0] == Times[1][0])
        Value[0] = SMA1[0];
        else
        Value[0] = Value[1];
        Here is a picture of the daily SMA plotted on a minute chart by enabling the bundled strategy: https://www.screencast.com/t/pI9t4L0DW
        JimNinjaTrader Customer Service

        Comment


          #5
          Thanks Jim,

          I missed the TestDailySMAShell indicator, thanks for pointing out out.
          But where in either the "TestDailySMAShell indicator" or "TestPlotShell" do I refer to BarsArray[1] ? Or do I need do ?

          It now looks like I can see my daily ADX value on my tick chart (which is mostly a flat line), but once again, only for a limited left part of the pane (pink line in the screenshot)
          Attached Files

          Comment


            #6
            Hello akvevo,

            The calling NinjaScript will need to add the data series for the daily data series and add the "Shell Indicator."

            The "Shell Indicator" should add the data series for daily data and add an indicator that references that daily data series. The "Shell Indicator" adds this indicator that references daily data under State == State.DataLoaded in OnStateChange().

            Keep in mind, the tick data series that the chart is based off of will need to have enough days to load to satisfy the period of the daily SMA.

            I would suggest to open the TestPlotShell strategy on a similar chart and if there are any differences in the way the indicator is presented, reference any differences that exist in the code.

            If this does not resolve your inquiry, could you provide more screen shots describing how you are putting the chart and data series together?
            JimNinjaTrader Customer Service

            Comment


              #7
              Thanks Jim,

              the tick data series that the chart is based off of will need to have enough days to load to satisfy the period of the daily SMA.
              I suspect this had something to do with it.
              I was testing this on my laptop with limited tick and daily data.
              I exported the codes to my main PC where my data resides and I am now see the desired outcome.

              Thanks for your help

              AK

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by TheWhiteDragon, 01-21-2019, 12:44 PM
              4 responses
              541 views
              0 likes
              Last Post PaulMohn  
              Started by GLFX005, Today, 03:23 AM
              0 responses
              2 views
              0 likes
              Last Post GLFX005
              by GLFX005
               
              Started by XXtrader, Yesterday, 11:30 PM
              2 responses
              11 views
              0 likes
              Last Post XXtrader  
              Started by Waxavi, Today, 02:10 AM
              0 responses
              7 views
              0 likes
              Last Post Waxavi
              by Waxavi
               
              Started by TradeForge, Today, 02:09 AM
              0 responses
              14 views
              0 likes
              Last Post TradeForge  
              Working...
              X