Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Place a dot on close that is > than moving average

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

    Place a dot on close that is > than moving average

    Can someone please provide code or sample of how to place a dot on the close of a bar that closes above say a moving average for example.

    That is, conditionally place the dot on the close. Within the one indicator would be the code for average (for example) and the code for highlighting the bar

    Ultimately I will refine the code to highlight closes "near" the indicator but for now I cannot find sample code that conditionally highlights a bar conditionally based on its relationship to an indicator.

    #2
    NinjaScript has code for adding a dot in the help files it is....

    DrawDot(string tag, bool autoScale, int barsAgo, double y, Color color)

    so to draw a dot in the middle of the previous bar the code would look like this

    DrawDot("NameOfYourDot", true, 1, (High[1] +Low[1]) / 2, Color.Blue);

    The (High[1] +Low[1]) / 2 gives your the centre price point of the previous bar for the Dots location.

    Then just put your condition in eg

    if (my condition is met)
    {
    DrawDot("NameYourDot", true, 1, (High[1] +Low[1]) / 2, Color.Blue);
    }

    Comment


      #3
      Hello skiguy,

      Thank you for your post.

      For the condition you can use if(Close[0] > SMA(period)[0]) for greater than. For cross over conditions you can take a look at the SampleMaCrossOver under Tools > Edit NinjaScript > Strategy.

      For DrawDot() use the method as described by marty087 at the following link: http://www.ninjatrader.com/support/h...t7/drawdot.htm

      Please let me know if I may be of further assistance.
      Last edited by NinjaTrader_PatrickH; 04-20-2014, 10:58 PM.

      Comment


        #4
        For the the SampleMaCrossOver:

        I think that you mean Strategy so it would be under Tools > Edit NinjaScript > Strategy

        Posting this clarification in case anyone looks at this thread at a later date and cannot find it under Indicators.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        599 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        344 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        558 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        558 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X