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

Daily Price range

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

    Daily Price range

    Hi

    I'm trying to find a way to receive an alert every time the daily open and close are more than x% of the total price range (min-max of the day).

    1. if I want to apply the same alert to several charts (30-50 charts) what is the best way to do it? creating a Strategy (with the Builder)?

    2. as a start I can't really find a proper syntax to do that. I thought of:
    Open[1]>=(High[1]*0.8)

    open 1 bar ago >= 80% value of the High 1 bar ago

    assuming a 20% range from the max of the day

    But the results (I'm asking the strategy to colour the bars) are not right, since ALL the bars get coloured!

    Many thanks!

    Mp

    #2
    Hello Mp. Thanks for the post.

    The best way to do this would be to make an indicator rather than a strategy. To get 20 percent of the daily range you would take the high minus the low from the CurrentDayOHL indicator, then compare the open price to the high minus that value.

    Ex:

    Code:
    if (CurrentDayOHL().CurrentOpen[0] >= (CurrentDayOHL().CurrentHigh[0] - (.2 * (CurrentDayOHL().CurrentHigh[0] - CurrentDayOHL().CurrentLow[0]))))
    For the close you would do the following:

    Code:
    if (Close[0] >= (CurrentDayOHL().CurrentHigh[0] - (.2 * (CurrentDayOHL().CurrentHigh[0] - CurrentDayOHL().CurrentLow[0]))))
    Please let me know if I may be of any further assistance.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thank you for the reply

      Never done an indicator. Will try to.

      can't see the whole line code you pasted.

      Comment


        #4
        Hello Mp.

        Thanks for the reply.

        The whole line is there, just scroll right in the code block and you will see the rest of it.

        Please let me know if you have any questions on the material.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          ok/ this is my test. all fine (sort of) but there is not plots where I would expect some. the section below is empty.
          Attached Files
          Last edited by percma; 03-08-2018, 03:35 AM.

          Comment


            #6
            Hello.

            Thanks for the reply.

            The examples I provided are only the conditions that would evaluate to true or false. You must add logic inside of the if blocks to tell the script what it should do if those conditions are true. To add plot values, you must fill the Value[] series. Please see the SMA code for an example of how to use plots. You can view the code of any native indicator in NinjaTrader with the NinjaScript editor.

            We have a fully documented help guide which will help you get started with Ninja Script. You will find language references to all of the methods and functions you will be using. You will also see a tutorial section which will help you create your first indicator and get you started with some of these concepts.
            A link to our Help Guide can be found below:*https://ninjatrader.com/support/help...injascript.htm
            *
            I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript:*
            *https://ninjatrader.com/support/help..._resources.htm
            You will find Reference Samples online as well as some Tips and Tricks for both indicators and strategies:
            Click here to see our NinjaScript Reference Samples:*http://www.ninjatrader.com/support/f...splay.php?f=30
            Click here to see our NinjaScript Tips:*http://www.ninjatrader.com/support/f...ead.php?t=3229
            *
            These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

            Please let us know if we may be of any further assistance.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              thank you for the reply. I think I will need to find another solution. Unfortunately I don't have now the time to learn how to do that with Ninja script.

              regards
              M

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Barry Milan, Today, 10:35 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by WeyldFalcon, 12-10-2020, 06:48 PM
              14 responses
              1,428 views
              0 likes
              Last Post Handclap0241  
              Started by DJ888, Yesterday, 06:09 PM
              2 responses
              9 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by jeronymite, 04-12-2024, 04:26 PM
              3 responses
              40 views
              0 likes
              Last Post jeronymite  
              Started by bill2023, Today, 08:51 AM
              2 responses
              16 views
              0 likes
              Last Post bill2023  
              Working...
              X