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

OUTLINE style

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

    OUTLINE style

    hello,
    I got this indicator from ninja ecosystem, and I tried to change its rectangle outline as Dot but it doesn't show any effect when I place it on the chart.
    can anyone help me with that, please.....
    thanks

    if ( CurrentBar >= Bars.Count-2 && CurrentBar > MaxLookBackBars )
    {
    p = Close[0]; p1 = 0; str = "";
    for ( level=1; level <= MaxLevels ; level++)
    {
    p = get_sr_level (p,+1);
    Draw.Rectangle(this, "resZone"+level, false, 0, p-((ZoneTickSize*TickSize)/2), MaxLookBackBars, p+((ZoneTickSize*TickSize)/2), ColorAbove, ColorAbove, 20 );
    //Draw.Line (this, "resLine"+level, false, 0, p-((ZoneTickSize*TickSize)/2), MaxLookBackBars, p-((ZoneTickSize*TickSize)/2), ColorAbove, DashStyleHelper.Dot, 0);
    //str = ( p == p1 ) ? str+" L"+level : "L"+level;
    Draw.Text (this, "resTag"+level, false , "\t "+str , 20 , p , 0, ColorAbove, boldFont, TextAlignment.Right, Brushes.Transparent , Brushes.Transparent , 0 );
    p1 = p; p += (PivotTickDiff*TickSize);
    }

    p = Close[0]; p1 = 0; str = "";
    for ( level = 1; level <= MaxLevels; level++)
    {
    p = get_sr_level (p, -1);
    Draw.Rectangle(this, "supZone"+level, false, 0, p-((ZoneTickSize*TickSize)/2), MaxLookBackBars, p+((ZoneTickSize*TickSize)/2), ColorBelow, ColorBelow, 30 );
    //Draw.Line (this, "supLine"+level, false, 0, p-((ZoneTickSize*TickSize)/2), MaxLookBackBars, p-((ZoneTickSize*TickSize)/2), ColorBelow, DashStyleHelper.Dot, 0);
    //str = ( p == p1 ) ? str+" L"+level : "L"+level;
    Draw.Text (this, "supTag"+level, false , "\t "+str , -5 , p , 0, ColorBelow, boldFont, TextAlignment.Right, Brushes.Transparent , Brushes.Transparent , 0 );
    p1 = p; p -= (PivotTickDiff*TickSize);
    }
    }
    }

    LastBar= CurrentBar;

    }
    Attached Files

    #2
    Hello hir04068,

    Thanks for your post.

    There are a couple of ways to accomplish your goal.

    1) Create a template on a chart of a rectangle and set the display characteristics (Outline width, color, dashstyle, etc) of the rectangle as you wish and save the template with a specific name, you would do this for both the support and resistance. Then in the code section of the indicator change the method overload to the one that uses the named rectangle template. Please see the help guide references:
    https://ninjatrader.com/support/help..._rectangle.htm
    "Understanding Drawing Object templates" in https://ninjatrader.com/support/help..._tools__ob.htm

    2) Change the code of the indicator where you create rectangle object and then change the objects OutLineStroke. Here is one example, using the indicator code, I'll bold the changes:

    Rectangle R1 = Draw.Rectangle(this, "resZone"+level, false, 0, p-((ZoneTickSize*TickSize)/2), MaxLookBackBars, p+((ZoneTickSize*TickSize)/2), ColorAbove, ColorAbove, 20 );
    R1.OutlineStroke.DashStyleHelper = DashStyleHelper.Dash;
    Last edited by NinjaTrader_PaulH; 05-23-2019, 07:30 AM. Reason: Change example code to use italic
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_PaulH View Post
      Hello hir04068,

      Thanks for your post.

      There are a couple of ways to accomplish your goal.

      1) Create a template on a chart of a rectangle and set the display characteristics (Outline width, color, dashstyle, etc) of the rectangle as you wish and save the template with a specific name, you would do this for both the support and resistance. Then in the code section of the indicator change the method overload to the one that uses the named rectangle template. Please see the help guide references:
      https://ninjatrader.com/support/help..._rectangle.htm
      "Understanding Drawing Object templates" in https://ninjatrader.com/support/help..._tools__ob.htm

      2) Change the code of the indicator where you create rectangle object and then change the objects OutLineStroke. Here is one example, using the indicator code, I'll bold the changes:

      Rectangle R1 = Draw.Rectangle(this, "resZone"+level, false, 0, p-((ZoneTickSize*TickSize)/2), MaxLookBackBars, p+((ZoneTickSize*TickSize)/2), ColorAbove, ColorAbove, 20 );
      R1.OutlineStroke.DashStyleHelper = DashStyleHelper.Dash;
      hey,
      I am sorry to bug you again but I am a little week in coding.....
      can you help me with a little bit more stuff...
      I have saved 2 rectangle template with name "support" and "ressistance"
      where I can insert this name in the code so I get a rectangle with this template in the indicator...
      can you please give me the code so that will be a great help.
      thanks in advance

      Comment


        #4
        Hello hir04068,

        Thanks for your reply.

        The method overload for using the template name can be found in the help guide link previously provided. You will want to spend some time reviewing the method overload parameters to what is available.

        Using the code from your post, we have:
        Draw.Rectangle(this, "resZone"+level, false, 0, p-((ZoneTickSize*TickSize)/2), MaxLookBackBars, p+((ZoneTickSize*TickSize)/2), ColorAbove, ColorAbove, 20 );
        Looking at the help guide section for Draw.Rectangle the above code is using the overload of:
        Draw.Rectangle(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush, Brush areaBrush, int areaOpacity)

        Where the parameter required are: actual values from the code
        NinjaScriptBase owner : this
        string tag : resZone"+level
        bool isAutoScale : false
        int startBarsAgo : 0
        double startY : p-((ZoneTickSize*TickSize)/2)
        int endBarsAgo : MaxLookBackBars
        double endY : p+((ZoneTickSize*TickSize)/2)
        Brush brush : ColorAbove
        Brush areaBrush : ColorAbove
        int areaOpacity : 20

        In looking at the many overloads shown in the help guide for Draw.Rectangle() you can see that for each there are two types, one that is using bars ago and the other is using dateTime. As the Current code is using barsago we can ignore the overloads showing references to datetime. So when looking for the overload that uses bars ago and a template the only choice is:
        Draw.Rectangle(NinjaScriptBase owner, string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, bool isGlobal, string templateName)
        With this information of what parameters you already have you should be able to construct what you need.

        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_PaulH View Post
          Hello hir04068,

          Thanks for your reply.

          The method overload for using the template name can be found in the help guide link previously provided. You will want to spend some time reviewing the method overload parameters to what is available.

          Using the code from your post, we have:
          Draw.Rectangle(this, "resZone"+level, false, 0, p-((ZoneTickSize*TickSize)/2), MaxLookBackBars, p+((ZoneTickSize*TickSize)/2), ColorAbove, ColorAbove, 20 );
          Looking at the help guide section for Draw.Rectangle the above code is using the overload of:
          Draw.Rectangle(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush, Brush areaBrush, int areaOpacity)

          Where the parameter required are: actual values from the code
          NinjaScriptBase owner : this
          string tag : resZone"+level
          bool isAutoScale : false
          int startBarsAgo : 0
          double startY : p-((ZoneTickSize*TickSize)/2)
          int endBarsAgo : MaxLookBackBars
          double endY : p+((ZoneTickSize*TickSize)/2)
          Brush brush : ColorAbove
          Brush areaBrush : ColorAbove
          int areaOpacity : 20

          In looking at the many overloads shown in the help guide for Draw.Rectangle() you can see that for each there are two types, one that is using bars ago and the other is using dateTime. As the Current code is using barsago we can ignore the overloads showing references to datetime. So when looking for the overload that uses bars ago and a template the only choice is:
          Draw.Rectangle(NinjaScriptBase owner, string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, bool isGlobal, string templateName)
          With this information of what parameters you already have you should be able to construct what you need.
          hello,
          thanks for your replay....
          i used this code
          Draw.Rectangle(this, resZone"+level, 0, p-((ZoneTickSize*TickSize)/2), MaxLookBackBars, p+((ZoneTickSize*TickSize)/2), 0 , resistance)
          but its giving me error.....
          "the name 'resistance' dose not exist in the current context.

          Comment


            #6
            Hello hir04068,

            Thanks for your reply.

            The method overload is expecting the name to be in the format of a string. You would need to add quotes on either side, "resistance".
            Note: the name must match exactly the name of the template, including any capitalization, otherwise the rectangle will be drawn with the "default" template settings of the rectangle tool.

            In looking closer at the code, just before the parameters called resistance, you have a zero where the overload is expecting the word true or false.

            The beginning of the tag name is missing a "
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_PaulH View Post
              Hello hir04068,

              Thanks for your reply.

              The method overload is expecting the name to be in the format of a string. You would need to add quotes on either side, "resistance".
              Note: the name must match exactly the name of the template, including any capitalization, otherwise the rectangle will be drawn with the "default" template settings of the rectangle tool.

              In looking closer at the code, just before the parameters called resistance, you have a zero where the overload is expecting the word true or false.

              The beginning of the tag name is missing a "
              thanks a ton......................
              it was a great help from you..... its working perfect now

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Aviram Y, Today, 05:29 AM
              0 responses
              2 views
              0 likes
              Last Post Aviram Y  
              Started by quantismo, 04-17-2024, 05:13 PM
              3 responses
              25 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by ScottWalsh, 04-16-2024, 04:29 PM
              7 responses
              34 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by cls71, Today, 04:45 AM
              0 responses
              6 views
              0 likes
              Last Post cls71
              by cls71
               
              Started by mjairg, 07-20-2023, 11:57 PM
              3 responses
              216 views
              1 like
              Last Post PaulMohn  
              Working...
              X