Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawDot not printing historically

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

    DrawDot not printing historically

    I cannot figure out how to get my DrawDot to show for all historical bars. It only shows a dot for the current bar.

    protected override void Initialize()
    {

    CalculateOnBarClose = false;
    DrawOnPricePanel = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1

    if (EMA(34)[0] > SMA(50)[0]
    && EMA(34)[0] > EMA((int) (EMA(50)[0]))[0]
    && SMA(50)[0] > EMA((int) (EMA(50)[0]))[0])
    {
    DrawDot("tag1", true, 0, 0, Color.Lime);
    }

    #2
    Hello meandthetrio,

    To have this draw on historical bars you would need to use a unique Tag for each new drawing. Here is an example using the CurrentBar to accomplish that:

    Code:
    DrawDot([B]"tag1" + CurrentBar[/B], true, 0, 0, Color.Lime);
    In your sample you are just updating the same object over and over which is why it ends up on the CurrentBar.

    I look forward to being of further assistance.

    Comment


      #3
      Thank you that did the trick. Now however, the dots will not print when my moving averages become much farther apart although they do successfully print after a cross.

      protected override void Initialize()
      {

      CalculateOnBarClose = false;
      DrawOnPricePanel = false;
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      // Condition set 1

      if (EMA(34)[0] > SMA(50)[0]
      && EMA(34)[0] > EMA((int) (EMA(50)[0]))[0]
      && SMA(50)[0] > EMA((int) (EMA(50)[0]))[0])
      {
      DrawDot("tag1" + CurrentBar, true, 0, 0, Color.Lime);
      }

      // Condition set 2

      if (EMA(34)[0] < SMA(50)[0]
      && EMA(34)[0] < EMA((int) (EMA(50)[0]))[0]
      && SMA(50)[0] < EMA((int) (EMA(50)[0]))[0])
      {
      DrawDot("tag1" + CurrentBar, true, 0, 0, Color.Red);
      }
      }

      Comment


        #4
        Hello meandthetrio,

        I believe you are running into the same problem here, you have reused the name "tag1" for the second object. If you mean to have both red and lime colored dots you would need to use unique names:

        Code:
        DrawDot("[B]LimeDot[/B]" + CurrentBar, true, 0, 0, Color.Lime);
        
        DrawDot("[B]RedDot[/B]" + CurrentBar, true, 0, 0, Color.Red);

        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        83 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        45 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        65 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
        57 views
        0 likes
        Last Post CarlTrading  
        Working...
        X