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 cmtjoancolmenero, Yesterday, 03:58 PM
        11 responses
        38 views
        0 likes
        Last Post cmtjoancolmenero  
        Started by FrazMann, Today, 11:21 AM
        0 responses
        3 views
        0 likes
        Last Post FrazMann  
        Started by geddyisodin, Yesterday, 05:20 AM
        8 responses
        52 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by DayTradingDEMON, Today, 09:28 AM
        4 responses
        24 views
        0 likes
        Last Post DayTradingDEMON  
        Started by George21, Today, 10:07 AM
        1 response
        22 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Working...
        X