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

Time indicator development

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

    Time indicator development

    Is it possible to create a indicator that will give a alert when a stocks drops for like 5 days?


    So a stocks that see a lower closing prcve for 5 days. Can I get any help?

    Thx

    #2
    Hello Cube1984,

    Thank you for your note.

    To set up an indicator for when you have 5 down days/bars go to Control Center>New>NinjaScript Editor and right click on the indicator folder>New. Then you would add a check to make sure you have more than 5 bars of data and the conditions for lower closes, under OnBarUpdate().

    if (CurrentBars[0] < 5) return;

    if ((Close[0] < Close[1])
    && (Close[1] < Close[2])
    && (Close[2] < Close[3])
    && (Close[3] < Close[4])
    && (Close[4] < Close[5]))
    {
    Draw.ArrowDown(this, @"tStocksDrop5DaysArrow down" + CurrentBar, false, 0, High[0], Brushes.Red);
    }

    You would then have to apply this to a Daily chart and it will draw a Red Down Arrow anytime there was 5 previous down bars.

    I have also attached a screen shot how you could build this using the strategy wizard, then click on view code to grab the code and then paste it into an indicator under OnBarUpdate. (See Screen Shot).

    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Yhx for the code, played around with it looking good. is it possible to draw that arrown under the candle ?

      And is is also possible to add a price range so a minimal drop of 5$ on those bars?

      Comment


        #4
        Hello Cube1984,

        Yes, you would be able to have the arrow drawn under the bar. To accomplish this, you would change the Y input from a value of High at bars index zero to a value of Low at bars index zero.
        Please see syntax of the draw arrow.



        Yes, it would be possible to require a lower close of at least 5 points by adding +5*TickSize to the more recent bar. For example,

        if ((Close[0] +5*TickSize < Close[1])

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by samish18, Today, 11:26 AM
        0 responses
        1 view
        0 likes
        Last Post samish18  
        Started by Trader146, 03-29-2024, 01:22 PM
        2 responses
        14 views
        0 likes
        Last Post Trader146  
        Started by tsantospinto, 04-12-2024, 07:04 PM
        7 responses
        127 views
        0 likes
        Last Post aligator  
        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
         
        Working...
        X