Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

can't get the triangle to draw in indicator panel

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

    can't get the triangle to draw in indicator panel

    This is driving me insane. I can't figure out what's wrong. It keeps drawing in the price panel even when I have it set to panel 2. Please help. Thanks.

    public class MyCustomStrategy12 : Strategy
    {
    private RSI RSI1;
    private RSI RSI2;


    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "differencearrosrsi";
    Calculate = Calculate.OnBarClose;
    IsOverlay = false;
    DisplayInDataBox = true;
    DrawOnPricePanel = false;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;

    Difference_Amount =40;
    AddPlot(Brushes.Goldenrod, "Difference");
    }
    else if (State == State.Configure)
    {
    RSI1 = RSI(Close, 8, 3);
    RSI2 = RSI(Close, 14, 3);
    }

    protected override void OnBarUpdate()
    {
    Difference[0] = RSI1[0] - RSI2[0];



    if (Difference[0] < -Difference_Amount && CrossAbove(RSI2,30,1))
    {
    Draw.TriangleDown(this, @"MyCustomStrategy12 Triangle down_1", false, 0, (High[0] /*+ (4 * TickSize)*/) , Brushes.Red);


    else if (Difference[0] > Difference_Amount && CrossBelow(RSI1,-30,1))
    {
    Draw.TriangleUp(this, @"MyCustomStrategy12 Triangle up_1", false, 0, (Low[0] /*+ (-4 * TickSize)*/) , Brushes.DodgerBlue);

    }

    #2
    Hello augustfay,

    This is a strategy and not an indicator.

    What panel is the strategy added to?

    Where you intending to create an indicator that is in its own panel and not a strategy?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I used the create new indicator dialog to make it but used the builder to generate some other code which I altered. It is in panel 2. Yes it was my intention for it to be an indicator, how would I go about that? Thank you.

      Comment


        #4
        Hello augustfay,

        You can copy the code in to the indicator code.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks Chelsea,

          It appears I actually sent you the wrong code above. I have already applied the code as an indicator and that is where it is not working.
          I believe everything is the same except for:


          HTML Code:
          namespace NinjaTrader.NinjaScript.Indicators
          {
          public class differencearros : Indicator
          {

          It looks like I fixed the problem by changing the code from:
          HTML Code:
          Draw.TriangleUp(this, @"MyCustomStrategy12 Triangle up_1", false, 0, (Low[0] + (-4 * TickSize)) , Brushes.DodgerBlue);
          to

          HTML Code:
          Draw.TriangleUp(this, "uparrow"+CurrentBar, true, 0, RSI1[0], Brushes.Gray);
          Yet I'm still not entirely clear on what the issue was. Is it just that I was applying it to the close of the candles instead of the indicator plot? Thanks.

          Comment


            #6
            Hello augustfay,

            I would not expect these two lines of code to change the panel the objects are drawn in. The major difference I see is that the tag name of the second line adds current bar so will create multiple objects while the first line uses a set tag name that doesn't change and would result in the existing object being updated.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            81 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            42 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            64 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            68 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            55 views
            0 likes
            Last Post CarlTrading  
            Working...
            X