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

ADX in MultiTimeFrame with RGB

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

    ADX in MultiTimeFrame with RGB

    Good morning, I'm trying to show on screen RGB color (in bars as if it were an indicator through a Plot)
    I'm trying to classify the ADX in Journal Weekly and separately and I put the TimeFrame put in Graphic let me see well drawn.

    Code:
     #region Variables
            // Wizard generated variables
                
            // User defined variables (add any user defined variables below)
            #endregion
    
            /// <summary>
            /// This method is used to configure the indicator and is called once before any bar data is loaded.
            /// </summary>
            protected override void Initialize()
            {
    			Add(new Plot(new Pen(Color.FromKnownColor(KnownColor.Black),3), PlotStyle.Bar,"Plot0"));
                Add(new Line(Color.FromKnownColor(KnownColor.Black), 0, "Center0"));
                Overlay				= false;
    			Add(PeriodType.Week, 1); //BarsArray[1]
    			Add(PeriodType.Day, 1); //BarsArray[2]
    			CalculateOnBarClose	= false;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
    			Plot0.Set(1);
    			if(ADX(BarsArray[1],11)[0] > ADX(BarsArray[1],11)[1])
    			{
    				if((DM(BarsArray[1],11).DiPlus[0] > DM(BarsArray[1],11).DiMinus[0])) //ALCISTA
    				{
    					PlotColors[0][0] = Color.Green;
    					if(ADX(BarsArray[2],11)[0] > ADX(BarsArray[2],11)[1])
    					{
    						if((DM(BarsArray[2],11).DiPlus[0] > DM(BarsArray[2],11).DiMinus[0])) //ALCISTA
    						{
    							PlotColors[0][0] = Color.Lime;
    						}
    					}
    				}
    				if((DM(BarsArray[1],11).DiMinus[0] > DM(BarsArray[1],11).DiPlus[0])) //BAJISTA
    				{
    					PlotColors[0][0] = Color.Red;
    					if(ADX(BarsArray[2],11)[0] > ADX(BarsArray[2],11)[1])
    					{
    						if((DM(BarsArray[2],11).DiMinus[0] > DM(BarsArray[2],11).DiPlus[0])) //BAJISTA
    						{
    							PlotColors[0][0] = Color.Fuchsia;
    						}
    						
    					}
    				}
    			}
    			else{PlotColors[0][0] = Color.Gray;} 
    		}
    
            #region Properties
            [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
            [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
            public DataSeries Plot0
            {
                get { return Values[0]; }
            }
            #endregion

    The result when inserted in the graph is an indicator window empty with nothing to show.

    This code is made to only work on a time frame and does work. What if someone wants to associate it as help.

    Code:
    #region Variables
    		private DireccionTendencia direction = DireccionTendencia.HighProbabilityVolum;
    		#endregion
    		
            protected override void Initialize()
            {
    			//PRIMEROS
                Add(new Plot(new Pen(Color.FromKnownColor(KnownColor.Black),3), PlotStyle.Bar, "Plot0"));
                Add(new Line(Color.FromKnownColor(KnownColor.Black), 0, "Center0"));
                Overlay				= false;
    			CalculateOnBarClose	= false;
            }
    Code:
    protected override void OnBarUpdate()
            {
    				Plot0.Set(1*VOL()[0]);
    				if(Stochastics(2,50,2).K[0]>70) //&& ADX(11)[0]>20) 
    				{
    					PlotColors[0][0] = Color.Green;
    					if(Stochastics(3,50,3).K[0] > Stochastics(3,50,3).D[0])
    					{
    						PlotColors[0][0] = Color.Lime;
    					}
    				}
    				else if (Stochastics(2,50,2).K[0]<30)// && ADX(11)[0]>20)
    				{
    					PlotColors[0][0] = Color.Fuchsia;
    					if(Stochastics(3,50,3).K[0] < Stochastics(3,50,3).D[0])
    					{
    						PlotColors[0][0] = Color.DarkRed;
    					}
    				}
    				else
    				{
    					PlotColors[0][0] = Color.Gray;
    				}
    			}
    Code:
    #region Properties
    		[Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
            [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
            public DataSeries Plot0
            {
                get { return Values[0]; }
            }
    #endregion

    #2
    Hello fisagol, and thank you for your question.

    I am providing an excerpt from Microsoft's publicly available documentation on the Color structure. Please let us know if we can be of further assistance.

    Originally posted by https://msdn.microsoft.com/en-us/library/system.drawing.color.aspx
    FromArgb(int32, int32, int32)

    Creates a Color structure from the specified 8-bit color values (red, green, and blue). The alpha value is implicitly 255 (fully opaque). Although this method allows a 32-bit value to be passed for each color component, the value of each component is limited to 8 bits.
    Code:
    [COLOR=Black][FONT=Courier New]// Opaque colors (alpha value defaults to 255 -- max value).
    
    [/COLOR][FONT=Courier New]Color [COLOR=Red]red   [/COLOR]= Color.FromArgb([COLOR=Red]0xFF[/COLOR], [COLOR=SeaGreen]0x00[/COLOR], [COLOR=Blue]0x00[/COLOR]);
    Color [COLOR=SeaGreen]green [/COLOR]= Color.FromArgb([COLOR=Red]0x00[/COLOR], [COLOR=SeaGreen]0xFF[/COLOR], [COLOR=Blue]0x00[/COLOR]);
    Color [COLOR=Blue]blue  [/COLOR]= Color.FromArgb([COLOR=Red]0x00[/COLOR], [COLOR=SeaGreen]0x00[/COLOR], [COLOR=Blue]0xFF[/COLOR]);
    
    [/FONT][/FONT]
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Either you have not finished reading the question or I have explained wrong. My problem is not with colors, my problem is with multiple timeframes. Please do not make me a link to your libraries MultiTimeFrames, I assure you that I have looked. My problem is specific to this indicator.

      Comment


        #4
        Thank you for the added information, fisagol, I misunderstood your request.

        You mentioned that this is a multi-time frame strategy, and that you have seen the sample in the Help Guide, but I noticed that your strategy lacks a BarsInProgress check, as well as a check to ensure that you have enough bars to process your strategy. That looks like this :

        Code:
        [FONT=Courier New]
        protected override void OnBarUpdate()
        {
            // make sure our daily and weekly bars have enough data
            foreach(int CurrentBarI in CurrentBars)
            {
                if (CurrentBarI < 11) // You are checking ADX 11 bars back
                {
                    return;
                }
            }
        
            // make sure we are processing our primary bars
            if (BarsInProgress != 0)
            {
                return;
            }
        
            // ...[/FONT]
        It is very likely your strategy disabled and turned itself off because the above check was not in place. You can verify this in the log tab of the control center. If the above check is not enough to allow your strategy to work, you will also see messages in the log tab which will give you clues as to why.

        If you would like me to explain this code sample in more detail or you have any other questions, please let us know.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Thank you very much, really this was my question and my resolved.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by traderqz, Today, 09:44 AM
          2 responses
          4 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by stafe, 04-15-2024, 08:34 PM
          8 responses
          40 views
          0 likes
          Last Post stafe
          by stafe
           
          Started by rocketman7, Today, 09:41 AM
          2 responses
          5 views
          0 likes
          Last Post rocketman7  
          Started by rocketman7, Today, 02:12 AM
          7 responses
          31 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by guillembm, Yesterday, 11:25 AM
          3 responses
          16 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X