• 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

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:
    // Opaque colors (alpha value defaults to 255 -- max value).
    Color red   = Color.FromArgb(0xFF, 0x00, 0x00);
    Color green = Color.FromArgb(0x00, 0xFF, 0x00);
    Color blue  = Color.FromArgb(0x00, 0x00, 0xFF);
    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:
        
        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;
            }
        
            // ...
        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 sgordet, Today, 10:31 PM
          0 responses
          1 view
          0 likes
          Last Post sgordet
          by sgordet
           
          Started by Ilpropio, Today, 09:45 PM
          0 responses
          2 views
          0 likes
          Last Post Ilpropio  
          Started by Revan, Today, 05:44 PM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_Marco  
          Started by superg3, Today, 07:57 PM
          0 responses
          3 views
          0 likes
          Last Post superg3
          by superg3
           
          Started by Longhornmark, Today, 07:06 AM
          5 responses
          35 views
          0 likes
          Last Post nkhoi
          by nkhoi
           
          Working...
          X