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

Absolute time based Indicators

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

    Absolute time based Indicators


    i would like to create two indicators based on the hightest high and lowest low during a specified timeframe, say the first 30 minutes after opening. These two indicators would then function as a channel and a breakout of the channel would be a buy signal. Can this be done in the strategy builder? The max and min function only take relative time.

    #2
    Hello Jan Kooistra,

    Thanks for your post and welcome to the NinjaTrader Forums!

    Here is a reference sample from the help guide demonstrating how to calculate the highest high and lowest low for a specified time range:


    This would need to be manually programmed in a NinjaScript Editor window (New > NinjaScript Editor).

    Below is a link to a forum post with helpful information about getting started with NinjaScript.
    https://ninjatrader.com/support/foru...040#post786040
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Awesome, thank you very much.

      Comment


        #4

        I pasted the example code from the helpguide into the script editor. It compiled fine, but i cannot find it as an available indicator in the chart windows. Is there a reason for this?

        Comment


          #5
          Hello Jan Kooistra,

          Thanks for your notes.

          The indicator will appear in the Indicators window based on the 'Name' property defined in the State.SetDefault section of the script. You should open the script in the NinjaScript Editor window, run a compile to check for errors, and note what you have set for the 'Name' property in State.SetDefault.

          Then right-click on the chart, select 'Indicators' to open the Indicators window, and locate the indicator based on the 'Name' property you have set in the script.

          If the indicator is still not displaying in the Indicators window, you may have an issue with the code in the OnStateChange() section of your script. If this is the case, you would need to reduce the code of the script by commenting out sections of code within OnStateChange(), running a compile, and testing to see if the indicator appears in the Indicators window. If you comment out a section of code within OnStateChange() and the indicator appears in the Indicators window, it is likely the last section of commented-out code causing the issue.

          Note that if you downloaded the SampleGetHighLowByTimeRange you could simply import the reference sample onto your platform by going to Tools > Import > NinjaScript AddOn. The name of this indicator in the Indicators window would be "Sample get high low by time range".

          Brandon H.NinjaTrader Customer Service

          Comment


            #6
            Thanks Brandon,
            i was looking for the wrong name, but have found it now. Thanks for your patience, it's working fine now.
            BTW when i try to import the SampleHighLowByTimeRange through the method you described in the bottom of your page i get the following msg; "Selected file was made from an older, incompatible version of NinjaTrader or is not a NinjaScript archive.

            Comment


              #7
              Hello Jan Kooistra,

              Thanks for your notes.

              What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.?.?.?)

              When testing importing the reference sample downloaded from the help guide link from post # 2 on my end using NinjaTrader 8.1.2.1, I am seeing that it successfully imports without any errors.

              Please try re-downloading the reference sample from the help guide page linked in post # 2, then go to Tools > Import > NinjaScript AddOn to import the file you just downloaded.​
              Brandon H.NinjaTrader Customer Service

              Comment


                #8
                I'm using 8.1.1.6

                Comment


                  #9
                  Hello Jan Kooistra,

                  Thanks for your notes.

                  NinjaTrader 8.1.1.6 is an old version of NinjaTrader. Please update NinjaTrader to the latest version (8.1.2.1) by following the steps below.

                  To update NinjaTrader
                  • Shutdown all programs including NinjaTrader *important
                  • Download NinjaTrader from the link below
                  • Double click the downloaded file to execute it
                  • Follow the on screen instructions
                  • Restart NinjaTrader
                  ​You can read about changes to this release in the release notes linked below.
                  https://ninjatrader.com/support/help...ease_notes.htm

                  After updating to NinjaTrader 8.1.2.1, re-download the reference sample from the help guide page linked in post # 2, then go to Tools > Import > NinjaScript AddOn to import the file you just downloaded. Does the behavior persist?

                  When testing importing the reference sample downloaded from the help guide link from post # 2 on my end using NinjaTrader 8.1.2.1, I see that it successfully imports.
                  Brandon H.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi, i've been trying to build a simple strategy using the sampleHighLow indicator that you provided (see history). Essentially i want to enter a long if the price crosses above the High value in the indicator. The conditions i programmed into the strategy builder are giving me really strange results. Can you spot any obvious errors? Click image for larger version

Name:	screenshot.jpg
Views:	38
Size:	118.3 KB
ID:	1290767

                    Comment


                      #11
                      Hello Jan Kooistra,

                      Thanks for your notes.

                      I do not see anything standing out as incorrect in the screenshot you shared.

                      The condition checks if the GetCurrentBid() price crosses above the MinMaxChannel().HighestHigh value and calls EnterLong().

                      To understand why the script is behaving as it is, such as placing orders or not placing orders when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

                      In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar.

                      Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

                      Below is a link to a forum post that demonstrates how to use prints to understand behavior.
                      https://ninjatrader.com/support/foru...121#post791121​​
                      Brandon H.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Balage0922, Today, 07:38 AM
                      0 responses
                      5 views
                      0 likes
                      Last Post Balage0922  
                      Started by JoMoon2024, Today, 06:56 AM
                      0 responses
                      6 views
                      0 likes
                      Last Post JoMoon2024  
                      Started by Haiasi, 04-25-2024, 06:53 PM
                      2 responses
                      19 views
                      0 likes
                      Last Post Massinisa  
                      Started by Creamers, Today, 05:32 AM
                      0 responses
                      6 views
                      0 likes
                      Last Post Creamers  
                      Started by Segwin, 05-07-2018, 02:15 PM
                      12 responses
                      1,786 views
                      0 likes
                      Last Post Leafcutter  
                      Working...
                      X