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

I can not change the bar color.

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

    I can not change the bar color.

    I tried to change bar color of fishertransform but it didn't take. I can change the background color but the bar color stayed the same. In this code I tried to change the bar color when it was above zero to green.
    Attached Files

    #2
    one more question;
    this line return the current value:

    double temp = FisherTransform( period )[ 0 ];

    but this line make the indicator disappear, should it return the previous value instead?

    //double temp1 = FisherTransform( period )[ 1 ];


    Code:
            protected override void OnBarUpdate()
            {
    			double temp = FisherTransform( period )[ 0 ];
    		//	double temp1 = FisherTransform( period )[ 1 ];
    			if(temp < 0)
    			{		
    				BackColor = Color.LightPink;     // set back ground color
    				HistDown.Set(temp);
    			}
    
    			if(temp > 0)
    			{
    			    BackColor = Color.LightSeaGreen; // set back ground color
    				HistUp.Set(temp);
    			}

    Comment


      #3
      Originally posted by nkhoi View Post
      I tried to change bar color of fishertransform but it didn't take. I can change the background color but the bar color stayed the same. In this code I tried to change the bar color when it was above zero to green.
      Your .cs had code errors. You should try in Initialize()

      Add(new Plot(new Pen(Color.Green, 3), PlotStyle.Bar, "HistTickUp"));
      Add(new Plot(new Pen(Color.Blue, 3), PlotStyle.Bar, "HistTickDn"));
      Plots[0].Min = 0;
      Plots[1].Max = 0;


      and then later just

      HistTickUp.Set(temp);
      HistTickDn.Set(temp);

      Can't answer your other Q cause I don't use the indicator.

      Comment


        #4
        Originally posted by marketmasher View Post
        Your .cs had code errors. You should try in Initialize()

        Add(new Plot(new Pen(Color.Green, 3), PlotStyle.Bar, "HistTickUp"));
        Add(new Plot(new Pen(Color.Blue, 3), PlotStyle.Bar, "HistTickDn"));
        Plots[0].Min = 0;
        Plots[1].Max = 0;


        and then later just

        HistTickUp.Set(temp);
        HistTickDn.Set(temp);

        Can't answer your other Q cause I don't use the indicator.
        thanks MM, now I have 2 colors. For the histogram above zero I also want to color it red if current histogram < prev histogram. This code compiled np but I got only green color.
        Code:
        		    if (fishValue > 0)
        			{
        			  BackColor = Color.LightSeaGreen; // set back ground color
        			  if (fishValue > Value[1])
        				  HistTickUp.Set(fishValue);
        		      if (fishValue < Value[1])         
        				  HistTickDn.Set(fishValue);
        			}
        include is a mock up histogram and cs file.
        Attached Files

        Comment


          #5
          nkhoi, I would suggest adding a third 'neutral' color to activate when both your red / green colors conditions do not hit....
          BertrandNinjaTrader Customer Service

          Comment


            #6
            NT 6.5 requires a different Plot statement for every color change, so you would have to add 2 more plots and then .Set them with conditions in your code.

            Comment


              #7
              add 3 more color plots, still got only 2 color histogram as before.
              Code:
              			Value.Set(fishValue);
              		    if (fishValue > 0)
              			{
              			   BackColor = Color.LightSeaGreen; // set back ground color
              			  if (fishValue > fishPrev)
              				  HistTickUp.Set(fishValue);
              			  else 
              		      if (fishValue < fishPrev)
              				  HistTickUpDn.Set(fishValue);
              			  else 
              				   Neutral.Set(fishValue);
              			}
              Attached Files

              Comment


                #8
                From a quick glance you only set those color options for the Fisher to be > 0, not for the other way round.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  yes, I work on hist bars > 0 condition first, they are all > 0 but are they slope up or slope down?

                  Comment


                    #10
                    I suggest you then check into your fishPrev (print those to the ooutput window) values as they trigger the condition for plotting the histogram color changes.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      For that you need 6 Plots 1)Above 0 and > prev fishvalue 2)Above 0 and < prev 3)Below 0 and > prev 4)Below 0 and < prev 5)Above 0 and = prev 6)Below 0 and = prev. If you get 1 working, copy and edit for the rest.

                      Comment


                        #12
                        Code:
                        ...
                        9/8/2009 10:50:37 AM   fish value:  2.48662304611601  fishPrev:  2.94810260684861
                        9/8/2009 10:54:29 AM   fish value:  2.21509302768946  fishPrev:  2.48662304611601
                        9/8/2009 10:57:19 AM   fish value:  1.95689150455055  fishPrev:  2.21509302768946
                        9/8/2009 11:04:17 AM   fish value:  2.05733592713933  fishPrev:  1.95689150455055
                        9/8/2009 11:09:18 AM   fish value:  1.82711450569109  fishPrev:  2.05733592713933
                        9/8/2009 11:11:59 AM   fish value:  1.2925382122535  fishPrev:  1.82711450569109
                        ...
                        It doesn't like my coding that is all I can tell

                        Code:
                        	    if (fishValue > 0)
                        			{
                        		       Print(Time[0]+"   fish value:  "+ fishValue + "  fishPrev:  " + fishPrev);
                        			   BackColor = Color.LightSeaGreen; // set back ground color
                        			}	
                        			  if (fishValue > 0 && fishValue > fishPrev)
                        				  HistTickUp.Set(fishValue);
                        		
                        		      if (fishValue > 0 && fishValue < fishPrev)
                        				  HistTickUpDn.Set(fishValue);
                        Attached Files

                        Comment


                          #13
                          nkhoi, it might be you can't see the color changes of the plots as the histograms overlap, have you using one bar style and one plot of linestyle in combination?
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by NinjaTrader_Bertrand View Post
                            nkhoi, it might be you can't see the color changes of the plots as the histograms overlap, have you using one bar style and one plot of linestyle in combination?
                            thanks, I see my error now plenty of fish value < 0 but not in negative I just auto assume that if it's < 0 then it's negative.

                            Comment


                              #15
                              I'm not sure I follow your thought, < 0 would be negative
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by aa731, Today, 02:54 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post aa731
                              by aa731
                               
                              Started by thanajo, 05-04-2021, 02:11 AM
                              3 responses
                              470 views
                              0 likes
                              Last Post tradingnasdaqprueba  
                              Started by Christopher_R, Today, 12:29 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post Christopher_R  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              166 responses
                              2,237 views
                              0 likes
                              Last Post sidlercom80  
                              Started by thread, Yesterday, 11:58 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post thread
                              by thread
                               
                              Working...
                              X