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 samish18, 04-17-2024, 08:57 AM
        17 responses
        64 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by rocketman7, Today, 02:12 AM
        2 responses
        16 views
        0 likes
        Last Post rocketman7  
        Started by briansaul, Today, 05:31 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by PaulMohn, Today, 03:49 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by frslvr, 04-11-2024, 07:26 AM
        6 responses
        106 views
        1 like
        Last Post NinjaTrader_BrandonH  
        Working...
        X