Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

drawdot on the indicator line

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

    drawdot on the indicator line

    Hi

    I'm trying to draw a 2 dots on the RSI indicator line in the indicator panel.
    I'd like the dots to appear each time the condition is met in my strategy.
    I've found in the forum that I need to set the DrawOnPricePanel = false.
    I did, but error cs0103 kicks in.

    my simplified settings are as follows:

    Code:
            protected override void Initialize()
            {
    Add(RSI(14,3));
    DrawOnPricePanel = false;
            }


    Code:
            protected override void OnBarUpdate()
            {
    
             <...> //strategy conditions
    
             EnterLong(Iqty_A, "Long 1a");
             EnterLong(Iqty_B, "Long 1b");  
    
             DrawDot("tag1", true, 0, RSI(14, 3)[0], Color.Red);
             DrawDot("tag2", true, 9, RSI(14, 3)[9], Color.Red);
            }
    Please advise what am I missing here

    Thank you

    #2
    ionaz, DrawOnPricePanel would be for indicators only, not for a strategy script - as this would not draw / plot anything to a specific panel. I would suggest doing the drawing then in a separate modified RSI indicator you Add() into the strategy for visualization purposes.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks Bertrand!

      I can understand the concept of adding the modified RSI to the chart.
      However I don't know how to draw on the indicator if the dots are based on the pricing data. I wonder if I should "import" the pricing data into the RSI code somehow. How?
      Then I'd identify a patternt there and based on that I would then place 2 dots on th RSI. In other words I only need the price data to return the number of bars ago, as soon as I have this, I can place dots on the RSI. Also, I laready have the pattern recognition programmed in the strategy.

      So my questions really are:
      can I take patern recognition form strategy and just copy/paste it in the indicator? or it is not that straightforward and I need to custom code that specifically in the indicator coding window? If so, what is the method for importing/manipulating pricing data?

      Comment


        #4
        ionaz, sorry for my late reply - so with the pricing data you mean access in the RSI indicator to the OHLCV prices of the underlying? That's directly possible, there would no need to 'import' any data specifically for the indicator, so you can use in your conditions - It's the same syntax as in your NinjaScript strategy.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hi Bertrand

          It works! I copied the code from the strategy onbarupdate into the onbarupdate of indicator, then also added DrawOnPricePanel = false in the indicator's initialize, saved the indicator, added it to the strategy and it does what I want: 2 dots appear on the indicator lines whenever strategy condition is met (a certain price pattern occurs). However, dots appear for the last occurrence of the pattern only. I can see in prallel on the price chart that the pattern occurs multiple times on historic data, but the dots are drawn on the indicator only once - last occassion.

          the added logic to indicator's onbarupdate looks like this:


          Code:
          if (
              pattern conditions
              )
              
          
          {
          DrawDot("tag1", true, 0, RSI(14, 3)[0], Color.Red);
          DrawDot("tag2", true, 9, RSI(14, 3)[9], Color.Red);
          }
          Could you suggest what am I missing here??
          Last edited by ionaz; 03-17-2013, 07:28 AM.

          Comment


            #6
            Originally posted by ionaz View Post
            Hi Bertrand

            It works! I copied the code from the strategy onbarupdate into the onbarupdate of indicator, then also added DrawOnPricePanel = false in the indicator's initialize, saved the indicator, added it to the strategy and it does what I want: 2 dots appear on the indicator lines whenever strategy condition is met (a certain price pattern occurs). However, dots appear for the last occurrence of the pattern only. I can see in prallel on the price chart that the pattern occurs multiple times on historic data, but the dots are drawn on the indicator only once - last occassion.

            the added logic to indicator's onbarupdate looks like this:


            Code:
            if (
                pattern conditions
                )
             
             
            {
            DrawDot("tag1", true, 0, RSI(14, 3)[0], Color.Red);
            DrawDot("tag2", true, 9, RSI(14, 3)[9], Color.Red);
            }
            Could you suggest what am I missing here??
            If you want multiple draw objects to be displayed, they must have unique tags. You are reusing your tags, so only the one current instance will ever show. One easy way to get unigue tags is to add the CurrentBar index to the tag:
            Code:
            DrawDot("tag1" + CurrentBar.ToString(), true, 0, RSI(14, 3)[0], Color.Red);
            DrawDot("tag2"+ CurrentBar.ToString(),  true, 9, RSI(14, 3)[9], Color.Red);

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by hurleydood, 09-12-2019, 10:45 AM
            14 responses
            1,091 views
            0 likes
            Last Post Board game geek  
            Started by cre8able, Yesterday, 04:16 PM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by cre8able, Yesterday, 04:22 PM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by stafe, 04-15-2024, 08:34 PM
            5 responses
            28 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by StrongLikeBull, Yesterday, 04:05 PM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X