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

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 xiinteractive, 04-09-2024, 08:08 AM
    5 responses
    13 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by swestendorf, Today, 11:14 AM
    2 responses
    5 views
    0 likes
    Last Post NinjaTrader_Kimberly  
    Started by Mupulen, Today, 11:26 AM
    0 responses
    2 views
    0 likes
    Last Post Mupulen
    by Mupulen
     
    Started by Sparkyboy, Today, 10:57 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by TheMarlin801, 10-13-2020, 01:40 AM
    21 responses
    3,917 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Working...
    X