• 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

Colouring indicator derived from secondary time frame

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

    Colouring indicator derived from secondary time frame

    Hi,

    I am plotting a higher time frame SMA on a chart of lower time frame. For example, a 10 period SMA on a 1 min chart (see link and attached plot http://www.ninjatrader.com/support/f...ad.php?t=44451)

    I want to colour the plot of SMA green at times when it is rising. This is a well worn problem but there is an extra step I am missing now that I am plotting from a secondary time frame which is longer than the primary one. The code below does not quite do it. As you can see in the plot, I only get green for the first bar of the primary (shorter) time frame. Can someone see what I am missing here?

    Code:
    if(BarsInProgress ==0)
    			{
                    Plot1.Set(SMA(BarsArray[1], Period)[0]);
    				
    				if(Rising(Plot1))
    					PlotColors[0][0] = Color.LimeGreen;
    Cheers,
    darmbk.
    Attached Files

    #2
    darmbk,

    This is to do with your condition for the color.
    You are testing if the rising is true or not.

    However, since you are plotting on a smaller timeframe the plot will plot for each bar. The first bar for the color is the start of the higher time frame. What you would want to do is create a bool variable that you can change to true or false and use that as a switch for your coloring.

    if(Rising(Plot1))
    {
    PlotColors[0][0] = Color.LimeGreen;
    stillRising = true;
    }

    else if(stillRising)
    {
    PlotColors[0][0] = Color.LimeGreen;
    }
    Cal H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Atilla, Today, 04:05 PM
    0 responses
    6 views
    0 likes
    Last Post Atilla
    by Atilla
     
    Started by Displacer, Today, 02:57 PM
    2 responses
    13 views
    0 likes
    Last Post Displacer  
    Started by SAILIKITY, 05-22-2019, 05:41 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by rmillar, 01-09-2019, 06:02 PM
    6 responses
    71 views
    1 like
    Last Post eDanny
    by eDanny
     
    Started by mlarocco, Today, 11:39 AM
    4 responses
    23 views
    0 likes
    Last Post mlarocco  
    Working...
    X