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 Aviram Y, Today, 05:29 AM
    0 responses
    1 view
    0 likes
    Last Post Aviram Y  
    Started by quantismo, 04-17-2024, 05:13 PM
    3 responses
    25 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by ScottWalsh, 04-16-2024, 04:29 PM
    7 responses
    34 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by cls71, Today, 04:45 AM
    0 responses
    6 views
    0 likes
    Last Post cls71
    by cls71
     
    Started by mjairg, 07-20-2023, 11:57 PM
    3 responses
    216 views
    1 like
    Last Post PaulMohn  
    Working...
    X