Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Creating a "crossover" on changing background color possible?

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

    Creating a "crossover" on changing background color possible?

    Is the following possible:

    I have defined a set of criterias by which the background color of a chart changes from green while in uptrend to red during downtrend and finally stays white during untrending.

    The change of a the color resembles a crossover of moving averages or such but is -rather than the simple crossing- based on a set of multiple criterias.

    Is there any method I could use to call the moment of change of color like a crossing with a lookback period and have it spitting out a numeric value or graphical symbols if a secondary set set of criterias during the lookback period gets fullfilled

    Here is an example:
    1) TrendDirection is defined at the beginning of the script:
    Code:
    enum TrendDirection
    		{
    			Up,
    			Down,
    			Ranging, 	
    		}
    2) Further down the script I use it to set the backround color conditionally:
    Code:
     
    if
                               (
    				LinReg(20)[0]>= SMA(20)[0]	 
    				&& 
    				[COLOR="Red"]background[1][/COLOR]=TrendDirection.Down
    				&&
    				Low[0]<LinReg(20)[0]
    		            )
                                           {			
    							DrawArrowUp("arrow"+CurrentBar, true, 0, low-atr*1, Color.Green);
    							background=TrendDirection.Up;
    							
    					}
    If I try using above kind of code as a method of trying to refer to the previous day [1] status of the background I get the error
    Cannot apply indexing with [] to an expression of type 'NinjaTrader.Indicator.MyIndicatorName.TrendDirect ion'

    So... Any way around you know of?

    Any assistance is well appreciated and I thank you for your attention already in advance

    #2
    Hello,
    You could use a DataSeries to track the state of a bar.

    Here is an example: http://www.ninjatrader.com/support/f...ead.php?t=7299

    This would allow you to store the trend state and access it by giving a bars ago index

    Let me know if I can be of further assistance.
    LanceNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    589 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    342 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    555 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    552 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X