• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

A Slope Colored Higher Time Frame SMA Ploted on a Smaller Time Frame Chart

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

    A Slope Colored Higher Time Frame SMA Ploted on a Smaller Time Frame Chart

    I want to Plot A Slope dependent Colored Higher Time Frame SMA Ploted on a Smaller Time Frame Chart (Ex. 13 SMA from 8 Range Chart on a 4R Chart).

    The Problem I think I'm having is when the Slope Changes from one to another (Rising or Falling) there is a Gap between the colors (See Picture Attached).

    Following is the Code (In next Post) I used and I'm not sure how to correct the logic to Plot what the Last state of the Slope Color was in the blank Gaps before the Slope Color changes?

    Thank You in Advance...
    Attached Files

    #2
    [CODE]
    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired)
    return;

    //Rising Slope
    if(BarsArray[1][1] < BarsArray[1][0])
    {
    PlotSMA1.Set(LinReg(BarsArray[1],sMA1)[0]);
    }
    //Falling Slope
    if(BarsArray[1][1] > BarsArray[1][0])
    {
    PlotSMA2.Set(LinReg(BarsArray[1],sMA2)[0]);
    }
    //Flat Slope and previous Slope was Rising
    if(BarsArray[1][1] == BarsArray[1][0] && BarsArray[1][2] < BarsArray[1][1])
    {
    PlotSMA1.Set(LinReg(BarsArray[1],sMA1)[0]);
    }
    //Flat Slope and previous Slope was Falling
    if(BarsArray[1][1] == BarsArray[1][0] && BarsArray[1][2] > BarsArray[1][1])
    {
    PlotSMA2.Set(SMA(BarsArray[1],sMA2)[0]);
    }
    [CODE]

    Comment


      #3
      jmca2000,

      Thank you for your post.

      What is occurring here is that there are certain bars that are not hitting the conditions to set the plot dataseries.

      I can changed around the code to have it all one plot and set the values for that bar specifically.

      You can add in the conditions to change the color of the plot per your conditions using PlotColors[]

      Code:
      if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired)
      			return;
      
      			//Rising Slope
      			if(BarsArray[1][1] < BarsArray[1][0])
      			{
      				PlotSMA1.Set(LinReg(BarsArray[1],sMA1)[0]);
      			}
      			//Falling Slope
      			else if(BarsArray[1][1] > BarsArray[1][0])
      			{
      				PlotSMA1.Set(LinReg(BarsArray[1],sMA2)[0]);
      			}
      			//Flat Slope and previous Slope was Rising
      			else if(BarsArray[1][1] == BarsArray[1][0] && BarsArray[1][2] < BarsArray[1][1])
      			{
      				PlotSMA1.Set(LinReg(BarsArray[1],sMA1)[0]);
      			}
      			//Flat Slope and previous Slope was Falling
      			else if(BarsArray[1][1] == BarsArray[1][0] && BarsArray[1][2] > BarsArray[1][1])
      			{
      				PlotSMA1.Set(SMA(BarsArray[1],sMA2)[0]);
      			}
      http://www.ninjatrader.com/support/h...plotcolors.htm
      Cal H.NinjaTrader Customer Service

      Comment


        #4
        Thanks for your help Cal.

        Yes That Fixed It....
        Last edited by jmca2000; 09-05-2014, 04:16 PM.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by aslane, Today, 02:31 PM
        0 responses
        8 views
        0 likes
        Last Post aslane
        by aslane
         
        Started by stoner, 10-16-2019, 01:38 PM
        5 responses
        47 views
        0 likes
        Last Post sledge
        by sledge
         
        Started by music_p13, Today, 12:04 PM
        1 response
        23 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by zaro33, Today, 10:55 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Heath  
        Started by itrader46, Today, 10:16 AM
        5 responses
        11 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X