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 futtrader, 04-21-2024, 01:50 AM
        5 responses
        56 views
        0 likes
        Last Post NinjaTrader_Eduardo  
        Started by PeakTry, Today, 10:49 AM
        0 responses
        2 views
        0 likes
        Last Post PeakTry
        by PeakTry
         
        Started by llanqui, Today, 10:32 AM
        0 responses
        5 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by StockTrader88, 03-06-2021, 08:58 AM
        45 responses
        3,992 views
        3 likes
        Last Post johntraderuser2  
        Started by TAJTrades, Today, 09:46 AM
        0 responses
        8 views
        0 likes
        Last Post TAJTrades  
        Working...
        X