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

No overload for method 'DrawDiamond' takes 4 arguments

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

    No overload for method 'DrawDiamond' takes 4 arguments

    Hi there,

    I am trying to write a indicator that would draw a diamond on the last bar if EMA 22 is greater than SMA 89. It seems that I keep getting the error No overload for method 'DrawDiamond' takes 4 arguments. Would appreciate it if someone could advise.

    Thank you in advance.


    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;
    #endregion

    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    [Description("Enter the description of your new custom indicator here")]
    public class MyCustomIndicator : Indicator
    {
    #region Variables
    // Wizard generated variables
    private int myInput0 = 1; // Default setting for MyInput0
    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {
    Overlay = true;

    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    if ((EMA(Close,22)[0]) > (SMA(Close,89)[0])) {
    DrawDiamond(Time[0].ToString(), 0, Low[1] - 3.25 * TickSize, Color.Pink);
    }
    }

    #region Properties
    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries Plot0
    {
    get { return Values[0]; }
    }

    [Description("")]
    [GridCategory("Parameters")]
    public int MyInput0
    {
    get { return myInput0; }
    set { myInput0 = Math.Max(1, value); }
    }
    #endregion
    }
    }

    #region NinjaScript generated code. Neither change nor remove.
    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
    public partial class Indicator : IndicatorBase
    {
    private MyCustomIndicator[] cacheMyCustomIndicator = null;

    private static MyCustomIndicator checkMyCustomIndicator = new MyCustomIndicator();

    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    public MyCustomIndicator MyCustomIndicator(int myInput0)
    {
    return MyCustomIndicator(Input, myInput0);
    }

    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    public MyCustomIndicator MyCustomIndicator(Data.IDataSeries input, int myInput0)
    {
    if (cacheMyCustomIndicator != null)
    for (int idx = 0; idx < cacheMyCustomIndicator.Length; idx++)
    if (cacheMyCustomIndicator[idx].MyInput0 == myInput0 && cacheMyCustomIndicator[idx].EqualsInput(input))
    return cacheMyCustomIndicator[idx];

    lock (checkMyCustomIndicator)
    {
    checkMyCustomIndicator.MyInput0 = myInput0;
    myInput0 = checkMyCustomIndicator.MyInput0;

    if (cacheMyCustomIndicator != null)
    for (int idx = 0; idx < cacheMyCustomIndicator.Length; idx++)
    if (cacheMyCustomIndicator[idx].MyInput0 == myInput0 && cacheMyCustomIndicator[idx].EqualsInput(input))
    return cacheMyCustomIndicator[idx];

    MyCustomIndicator indicator = new MyCustomIndicator();
    indicator.BarsRequired = BarsRequired;
    indicator.CalculateOnBarClose = CalculateOnBarClose;
    #if NT7
    indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
    indicator.MaximumBarsLookBack = MaximumBarsLookBack;
    #endif
    indicator.Input = input;
    indicator.MyInput0 = myInput0;
    Indicators.Add(indicator);
    indicator.SetUp();

    MyCustomIndicator[] tmp = new MyCustomIndicator[cacheMyCustomIndicator == null ? 1 : cacheMyCustomIndicator.Length + 1];
    if (cacheMyCustomIndicator != null)
    cacheMyCustomIndicator.CopyTo(tmp, 0);
    tmp[tmp.Length - 1] = indicator;
    cacheMyCustomIndicator = tmp;
    return indicator;
    }
    }
    }
    }

    // This namespace holds all market analyzer column definitions and is required. Do not change it.
    namespace NinjaTrader.MarketAnalyzer
    {
    public partial class Column : ColumnBase
    {
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.MyCustomIndicator MyCustomIndicator(int myInput0)
    {
    return _indicator.MyCustomIndicator(Input, myInput0);
    }

    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    public Indicator.MyCustomIndicator MyCustomIndicator(Data.IDataSeries input, int myInput0)
    {
    return _indicator.MyCustomIndicator(input, myInput0);
    }
    }
    }

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    public partial class Strategy : StrategyBase
    {
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.MyCustomIndicator MyCustomIndicator(int myInput0)
    {
    return _indicator.MyCustomIndicator(Input, myInput0);
    }

    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    public Indicator.MyCustomIndicator MyCustomIndicator(Data.IDataSeries input, int myInput0)
    {
    if (InInitialize && input == null)
    throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

    return _indicator.MyCustomIndicator(input, myInput0);
    }
    }
    }
    #endregion


    #2
    DrawDiamond takes 5 parameters. You only have 4.


    Code:
    DrawDiamond(Time[0].ToString(), 0, Low[1] - 3.25 * TickSize, Color.Pink);
    From the help

    Definition
    Draws a diamond.


    Method Return Value
    An IDiamond object that represents the draw object.

    Syntax
    DrawDiamond(string tag, bool autoScale, int barsAgo, double y, Color color)
    DrawDiamond(string tag, bool autoScale, DateTime time, double y, Color color)

    Parameters
    tag A user defined unique id used to reference the draw object. For example, if you pass in a value of "myTag", each time this tag is used, the same draw object is modified. If unique tags are used each time, a new draw object will be created each time.
    autoScale Determines if the draw object will be included in the y-axis scale
    barsAgo The bar the object will be drawn at. A value of 10 would be 10 bars ago.
    time The time the object will be drawn at.
    y The y value
    color The draw object color (reference)

    Examples
    // Paints a red diamond on the current bar 1 tick below the low
    Code:
    DrawDiamond("tag1", true, 0, Low[0] -  TickSize, Color.Red);


    Last edited by sledge; 01-08-2012, 07:56 AM. Reason: added the example too

    Comment


      #3
      Thanks Sledge!

      Comment


        #4
        Originally posted by woohooboy View Post
        Thanks Sledge!
        Try : DrawDiamond(CurrentBar.ToString()+"",true, 0, Low[1] - 3.25 * TickSize, Color.Pink);

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ezrollin, Today, 09:01 PM
        1 response
        15 views
        0 likes
        Last Post ezrollin  
        Started by FutTrader9000, Today, 06:20 PM
        0 responses
        29 views
        0 likes
        Last Post FutTrader9000  
        Started by junkone, Today, 05:48 PM
        0 responses
        23 views
        0 likes
        Last Post junkone
        by junkone
         
        Started by Futurestrader00, Today, 05:10 PM
        1 response
        29 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Started by Gerik, 03-08-2021, 01:25 AM
        5 responses
        49 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Working...
        X