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

Remove draw object (diamond) after so many bars

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

    Remove draw object (diamond) after so many bars

    trying to have these diamonds to be erased after 10 bars...any ideas?
    [code]
    ///<summary>
    /// Enter the description of your new custom indicator here
    ///</summary>
    [Description("Enter the description of your new custom indicator here")]
    publicclass addkeltner : Indicator
    {
    #region Variables
    privateint period = 20;
    privatedouble offsetMultiplier = 3;
    private DataSeries diff;
    #endregion
    ///<summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    ///</summary>
    protectedoverridevoid Initialize()
    {
    Add(new Plot(Color.Black, "Midline"));
    Add(new Plot(Color.Magenta, "Upper"));
    Add(new Plot(Color.Magenta, "Lower"));
    diff = new DataSeries(this);
    Overlay = true;
    PriceTypeSupported = false;
    }
    ///<summary>
    /// Called on each bar update event (incoming tick).
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    diff.Set(High[0] - Low[0]);
    double middle = EMA(Typical, Period)[0];
    double offset = EMA(diff, Period)[0] * offsetMultiplier;
    double upper = middle + offset;
    double lower = middle - offset;
    Midline.Set(middle);
    Upper.Set(upper);
    Lower.Set(lower);


    if ((High[0] >= KeltnerChannel(3, 20).Upper[0])
    && (High[0] >= SMA (80)[0])

    )
    DrawDiamond(Time[0].ToString(), 0, High[1] + 45.25* TickSize, Color.Lime);

    if ((Low[0] <= KeltnerChannel(3, 20).Lower[0])
    && (Low[0] <= SMA (80)[0])

    )
    DrawDiamond(Time[0].ToString(), 0, Low[1] - 45.25* TickSize, Color.Red);

    }

    #2
    This link might help: http://www.ninjatrader-support.com/H...rawObject.html

    Comment


      #3
      thanks for the link

      can you tell me if there are any indicators that i can look at that would have this "remove draw object"...

      i have no idea where or how to do this and might have a better idea if i can "see" a example...

      thank you

      Comment


        #4
        The forum has a "Search" function. Please paste in "RemoveDrawObject". It should yield some matches.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sidlercom80, 10-28-2023, 08:49 AM
        166 responses
        2,233 views
        0 likes
        Last Post sidlercom80  
        Started by thread, Yesterday, 11:58 PM
        0 responses
        1 view
        0 likes
        Last Post thread
        by thread
         
        Started by jclose, Yesterday, 09:37 PM
        0 responses
        6 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,414 views
        0 likes
        Last Post Traderontheroad  
        Started by firefoxforum12, Yesterday, 08:53 PM
        0 responses
        11 views
        0 likes
        Last Post firefoxforum12  
        Working...
        X