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

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.
    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        39 views
        0 likes
        Last Post jeronymite  
        Started by bill2023, Today, 08:51 AM
        2 responses
        15 views
        0 likes
        Last Post bill2023  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        167 responses
        2,260 views
        0 likes
        Last Post jeronymite  
        Started by warreng86, 11-10-2020, 02:04 PM
        7 responses
        1,362 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Perr0Grande, Today, 08:16 PM
        0 responses
        5 views
        0 likes
        Last Post Perr0Grande  
        Working...
        X