Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

breakout

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

    breakout

    Hallo,
    I have two defined values: OH and OL
    Now I would like to be the breakout show about these values in the market analyzer
    Somewhere I have an error....

    http://screencast.com/t/Y8xYrjwN

    Can you help me?

    #2
    Originally posted by Blackburn View Post
    Hallo,
    I have two defined values: OH and OL
    Now I would like to be the breakout show about these values in the market analyzer
    Somewhere I have an error....

    http://screencast.com/t/Y8xYrjwN

    Can you help me?
    What is the text of the error?

    Comment


      #3
      Hi koganam,

      no specific error message...
      The code should display a value of "1" if Close> OH and of "2" if Close <OL.
      I need the values für scanning in the market analyzer.
      this does not happen ... i only get the lastprice.

      Comment


        #4
        Originally posted by Blackburn View Post
        Hi koganam,

        no specific error message...
        The code should display a value of "1" if Close> OH and of "2" if Close <OL.
        I need the values für scanning in the market analyzer.
        this does not happen ... i only get the lastprice.
        Kindly show us a picture of your Market Analyzer to demonstrate how it is misbehaving?

        Comment


          #5
          please check the code
          the code can ever show the values 1 and 2?

          Comment


            #6
            Originally posted by Blackburn View Post
            please check the code
            the code can ever show the values 1 and 2?
            The only handler shown is the OnBarUpdate(). That looks correct, but ONLY if the other parts of the code are also correct. A NinjaTrader indicator class inherits from the IndicatorBase class, which has various structures that MUST be overridden. To make a judgement, we would have to see all sections of the code, not just one handler.

            Comment


              #7
              Hello Blackburn,

              Thank you for your post.

              Using your code as you provided in the screenshot I never see an instance where Close is greater than OH or less than OL. I even used a spread of 1 and found no values.

              Here is the code I used to test:
              Code:
                      #region Variables
              		private DataSeries OH;
              		private DataSeries OL;
              		private double spreadtmp = 0;
              		private double spread = 1;
                      #endregion
              
                      protected override void Initialize()
                      {
              			Add(new Plot(Color.Blue, "plot"));
                          OH = new DataSeries(this);
              			OL = new DataSeries(this);
                      }
              
                      protected override void OnBarUpdate()
                      {
              			if(CurrentBar == 1)
              			{
              				OH.Set(0);
              				OL.Set(0);
              			}
              			if(CurrentBar >= 2)
              			{
              				spreadtmp = spread * TickSize;
              				
              				if(Bars.BarsSinceSession == 1
              					|| Close[0] > OH[1]
              					|| Close[0] < OL[1])
              				{
              					OH.Set(High[0]+spreadtmp);
              					OL.Set(Low[0]-spreadtmp);
              				}
              				
              				else
              				{
              					OH.Set(OH[1]);
              					OL.Set(OL[1]);
              				}
              				
              				if(Close[0] > OH[0])
              				{
              					Value.Set(1);
              				}
              				else if(Close[0] < OL[0])
              				{
              					Value.Set(2);
              				}
              				else
              				{
              					Value.Set(0);
              				}
              				
              				if(Value[0] != 0)
              				{
              					Print(" ");
              					Print("-------------------------");
              					Print(Time[0]);
              					Print(OH[0]);
              					Print(OL[0]);
              					Print(Close[0]);
              					Print(Value[0]);
              				}
              			}
                      }

              Comment


                #8
                Hello Patrick,

                I am sending you attached a photo of the chart:

                Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


                and I am sending you attached the code:

                Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


                For the market analyzer ein need value "1" für each blue candle, value "2" for each red candle.

                Thanks for your support!

                Andrew

                Comment


                  #9
                  Hello,

                  Thank you for the reply.

                  I would be happy to take a look into the code if you can provide it as an attachment that I can either import or copy and paste into NinjaTrader.

                  For clarification, is the question here that you are trying to make the Market Analyzer display a 0, otherwise a 1 if blue bar or 2 if red bar?

                  I look forward to being of fuhrer assistance.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    Hello,

                    there is the code:

                    ABInsideBarv4.cs

                    And yes its right, I need a "1" for blue and a "2" for red candle.

                    Comment


                      #11
                      Hello,

                      Thank you for the reply.

                      The only item I see that would be incorrect is the way you have created the plots or lack of plot.

                      You currently have added two plots for the OH and OL, a third plot would be needed for the value the MA will use, so please add one more Add statement like the following:



                      Code:
                       Add(new Plot(Color.FromKnownColor(KnownColor.DimGray), PlotStyle.Hash, "MarketAnalyzerColumn"));
                      You would also need to add the property for this in your properties section:

                      Code:
                      [Browsable(false)]	
                      [XmlIgnore()]		
                      public DataSeries MarketAnalyzerColumn
                      {
                            get { return Values[2]; }
                      }
                      Next the Value.Set would not be correct because Value.Set will set the value for the DataSeries at index 0 but you need index 2, so instead you would want to reference the property that needed created like the following:

                      Code:
                      if (Close[0] > OH[1])
                      {
                               BarColor = Color.FromArgb(0, 181, 220);
                               CandleOutlineColor = Color.FromArgb(0, 181, 220);
                               MarketAnalyzerColumn.Set(1);
                      }
                      else if (Close[0] < OL[1])
                      {
                                BarColor = Color.FromArgb(102, 0, 51);
                                CandleOutlineColor = Color.FromArgb(250, 25, 72);
                                MarketAnalyzerColumn.Set(2);
                      }
                      else
                      {
                                MarketAnalyzerColumn.Set(0);
                      }
                      The only thing I have changed with this would be the property being used instead of Value, I have attached the script so you can see the changes on your existing code as well.

                      I look forward to being of further assistance.
                      Attached Files
                      JesseNinjaTrader Customer Service

                      Comment


                        #12
                        Hallo Jesse,

                        thanks for your support.

                        How can I code it, that only the last/newest breakout bar are coloured?

                        Comment


                          #13
                          Hello,

                          Thank you for the question.

                          Because the historical bars would remain colored after calling BarColor for the most recent bar, you would need to remove the color from the historical bars and then re color the correct bars to accomplish this.

                          One way to do this is to use BarColorSeries and remove the color from the prior bars.

                          I would not recommend doing this during the loading of the indicator or during historical data as this will cause the script load time to increase substantially.

                          To get around this, I wrapped the code in a historical data check so it can be places anywhere you need in OnBarUpdate. This would prevent this section of code from running during historical bars decreasing load times.

                          Code:
                          if(!Historical)
                          {
                          	for(int i = 0; i < Count -1  ; i++)
                          	{
                          		BarColorSeries[i] = Color.Empty;
                          	}
                          }
                          This will loop through all the bars and set them to Color.Empty which just removes custom coloring and restores their original color.

                          I look forward to being of further assistance.
                          JesseNinjaTrader Customer Service

                          Comment


                            #14
                            HI Jesse,

                            thanks for your advice; it works fine :-)

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by algospoke, 04-17-2024, 06:40 PM
                            6 responses
                            48 views
                            0 likes
                            Last Post algospoke  
                            Started by arvidvanstaey, Today, 02:19 PM
                            4 responses
                            11 views
                            0 likes
                            Last Post arvidvanstaey  
                            Started by samish18, 04-17-2024, 08:57 AM
                            16 responses
                            61 views
                            0 likes
                            Last Post samish18  
                            Started by jordanq2, Today, 03:10 PM
                            2 responses
                            9 views
                            0 likes
                            Last Post jordanq2  
                            Started by traderqz, Today, 12:06 AM
                            10 responses
                            21 views
                            0 likes
                            Last Post traderqz  
                            Working...
                            X