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

Tying to call Draw from within Class

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

    Tying to call Draw from within Class

    Trying to call Draw from within Class but getting:
    "The best overloaded method match for 'NinjaTrader.NinjaScript.DrawingTools.Draw.PathToo l(NinjaTrader.NinjaScript.NinjaScriptBase, string, bool, int, double, int, double, int, double, int, double)' has some invalid arguments​"
    " cannot convert from 'values' to 'NinjaTrader.NinjaScript.NinjaScriptBase​"

    Please point out any mistakes I may have done.

    Code:
            class values
            {
                public int barIndex;
                public string tagname;
                public double priceA;
                public int bAgoA;
                public double priceB;
                public int bAgoB;
                public double priceC;
                public int bAgoC;
                public double priceD;
                public Brush color;
                public DashStyleHelper DH;
                public int LW;
    
                public bool drawBarsAgo()
                {
    
                    PathTool pt = Draw.PathTool(this,
                        this.tagname,
                        false,
                        this.bAgoA,
                        this.priceA,
                        this.bAgoB,
                        this.priceB,
                        this.bAgoC,
                        this.priceC,
                        this.bAgoD,
                        this.priceD);
    
                    pt.OutlineStroke.Brush = this.color;
                    pt.OutlineStroke.DashStyleHelper = this.DH;
                    pt.OutlineStroke.Width = this.LW;
    
                    return true;
                }
            }​

    #2
    Hello PMitchum,

    Use a partial class.
    Explanation: I wrote a base class Indicator class that I'm using to inherit all my other indicators from. So this baseclass is defined as: namespace NinjaTrader.NinjaScript.Indicators.AssistedTrades { public class ATBaseIndicator: Indicator { ... } } And any other indicator is defined as: namespace NinjaTrader.NinjaScr


    Or supply the indicator object to the class method.

    public bool drawBarsAgo(Indicator indy)
    {
    PathTool pt = indy.Draw.PathTool(indy, tagname, bAgoA, priceA, bAgoB, priceB, bAgoC, priceC, bAgoD, priceD);
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you sir, I do however get the error "NinjaScript.Indicators.Indicator' does not contain a definition for 'Draw' and no extension method 'Draw' accepting a first argument of type 'NinjaTrader.NinjaScript.Indicators.Indicator' could be found" from this code below.

      Code:
      partial class values
      {
      public int barIndex;
      public string tagname;
      public double priceA;
      public int bAgoA;
      public double priceB;
      public int bAgoB;
      public double priceC;
      public int bAgoC;
      public double priceD;
      public Brush color;
      public DashStyleHelper DH;
      public int LW;
      }
      
      partial class values
      {
      public bool drawBarsAgo(Indicator i)
      {
      
      PathTool pt = i.Draw.PathTool(i, tagname, false, bAgoA, priceA, bAgoB, priceB, bAgoC, priceC, bAgoD, priceD);
      
      pt.OutlineStroke.Brush = this.color;
      pt.OutlineStroke.DashStyleHelper = this.DH;
      pt.OutlineStroke.Width = this.LW;
      
      return true;
      }
      }​
      Last edited by PMitchum; 01-09-2023, 09:22 AM.

      Comment


        #4
        Hello PMitchum,

        I am suggesting you use a partial class of the indicator.

        Currently you are making a partial class of values. Is your indicator named values?

        Have you looked at the example I provided?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Ah, I misunderstood. I will try with a partial class of the indicator.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by algospoke, Today, 06:40 PM
          0 responses
          9 views
          0 likes
          Last Post algospoke  
          Started by maybeimnotrader, Today, 05:46 PM
          0 responses
          7 views
          0 likes
          Last Post maybeimnotrader  
          Started by quantismo, Today, 05:13 PM
          0 responses
          7 views
          0 likes
          Last Post quantismo  
          Started by AttiM, 02-14-2024, 05:20 PM
          8 responses
          168 views
          0 likes
          Last Post jeronymite  
          Started by cre8able, Today, 04:22 PM
          0 responses
          9 views
          0 likes
          Last Post cre8able  
          Working...
          X