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

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 DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        41 views
        0 likes
        Last Post alifarahani  
        Working...
        X