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 StockTrader88, 03-06-2021, 08:58 AM
        44 responses
        3,966 views
        3 likes
        Last Post jhudas88  
        Started by rbeckmann05, Today, 06:48 PM
        0 responses
        4 views
        0 likes
        Last Post rbeckmann05  
        Started by rhyminkevin, Today, 04:58 PM
        4 responses
        54 views
        0 likes
        Last Post dp8282
        by dp8282
         
        Started by iceman2018, Today, 05:07 PM
        0 responses
        5 views
        0 likes
        Last Post iceman2018  
        Started by lightsun47, Today, 03:51 PM
        0 responses
        8 views
        0 likes
        Last Post lightsun47  
        Working...
        X