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

NT8 Trend Strategy-Indicator

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

    NT8 Trend Strategy-Indicator

    Hello,

    I'm trying to create an indicator (starting from the Strategy Builder), that will give me a signal when the following exists:

    * Current 15 minute price bar is above previous 15 minute price bar ... and/or
    * Current 30 minute price bar is above previous 30 minute price bar... and/or
    * Current 60 minute price bar is above previous 60 minute price bar... and/or
    * Current Daily price bar is above previous Daily price bar... and/or
    * Current Weekly price bar is above previous Weekly price bar... and/or
    * Current Monthly price bar is above previous Monthly price bar... THEN

    Draw a blue upward angling arrow on chart... OR
    If two or more of the above exist, draw two blue arrows

    The inverse setups would draw a brown downward arrow (or two) on the chart


    My question is, is this code in any way correct? A starting point? Completely wrong?

    I know that I don't have the code added to draw the second arrow yet; I'll try to figure that out later.

    Later on, I also plan to have a "current price bar broke out beyond previous price bar" code set that will draw different colored arrows.

    Screenshot of NinjaScript code attached.


    #2
    Hello i2w8am9ii2,

    The issue that I see with this is that Times[1][1] is called but there is no check that CurrentBars[1] has at least 2 bars..
    This could cause an indexing error if on the first primary bar there are not 2 previous months of month bars that have processed. The same is true for all of the added series where the previous bar is being referenced.

    What version of NinjaTrader are you using? (Help > About)


    That said, the code does not reference any price data. You are not comparing the Close[0] of the current bar to be greater than Closes[6][1] to find if the current bars close is greater than the 15 minute series previous close.

    Below is a public link to a forum post with helpful information about getting started with NinjaScript that includes a link to the Strategy Builder 301 course.
    http://ninjatrader.com/support/forum...609#post503609


    As a tip, to export a NinjaTrader 8 NinjaScript so this can be shared do the following:
    1. Click Tools -> Export -> NinjaScript...
    2. Click the 'add' link -> check the box(es) for the script(s) you want to include
    3. Click the 'Export' button
    4. Enter a unique name for the file in the value for 'File name:'
    5. Choose a save location -> click Save
    6. Click OK to clear the export location message
    By default your exported file will be in the following location:
    • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
    Below is a link to the help guide on Exporting NinjaScripts.
    http://ninjatrader.com/support/helpG...-us/export.htm
    Last edited by NinjaTrader_ChelseaB; 10-11-2018, 09:10 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Thanks for the links and for the info.

      I am using Ninjatrader version 8.0.15.1 64-bit

      Attached is a zip file of my exported NT8 Strategy in it's initial stage.
      Attached Files

      Comment


        #4
        Hello i2w8am9ii2,

        I just want to re-iterate that you are comparing the time of day of one series with another series. You are not comparing the close prices.

        In the condition builder this would be in the Price section.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea,

          Okay, I understand now.

          I made the changes.

          Attached is a screenshot of the code and attached also is a new exported zip file (exported from Strategy Builder).
          Attached Files

          Comment


            #6
            Hello i2w8am9ii2,

            Is there an issue with the new code?

            If so what is the issue you are having?

            Are you unable to find the drawing objects on the last bar where the condition has occurred at a y value (price) of 0?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi Chelsea,

              Thanks for checking back.

              I am going to test it out soon, I haven't had a chance to do so yet.

              In the meanwhile, I want to use some custom arrows for the drawing objects.

              Is it possible to import custom graphics (arrows) to use for drawing objects? If so, how would I do so?

              Attached is a screenshot of the custom drawing objects that I want to use.

              Comment


                #8
                Hi Chelsea,

                I turned the code into a NT8 indicator and compiled it. Originally there was one closing brace missing, so I found out where it was needed then added it.

                Then the indicator compiled without errors.

                Attached is the indicator zip file.

                I did not test it out on my charts yet; I will do so soon.

                In the meanwhile, if you find anything wrong with my code or logic, please let me know.

                Thanks,
                Attached Files

                Comment


                  #9
                  Hello i2w8am9ii2,

                  Thank you for your response.

                  The code looks correct at this point. I do want to point out that the current state of the code is that all conditions in each set must be true. Are you still working on breaking the conditions down to draw different items depending on the number of true conditions?

                  Attached is an example of drawing an image through NinjaScript. There are advanced functions in the code, please let me know if you have any questions.
                  Attached Files

                  Comment


                    #10
                    Hi Patrick,

                    Thanks for your reply and for the attached sample .cs file.

                    I could not comprehend the .cs file; it has code that I'm not familiar with. I'm just learning C# and NinjaScript and so I'm creating only very simple indicators at this time.

                    Yes, you are right, the current code was that all conditions in each set must be true, and I changed that to be that either condition can be true.

                    I changed to code to draw a triangle if 'either' condition was met, then tested it again, but still, it has not yet once drawn a triangle on the chart when it was supposed to.

                    Then I tried changing the Drawing Object code and tested it again, but still, it is not drawing a triangle on the chart.

                    Attached are screenshots of the code and the changes that I made.

                    The black arrows that I drew on the chart screenshot show where an arrow should have been drawn.

                    Attached also is a zip file with the new version of the indicator.

                    Please advise on why the drawing object is not drawing the object.

                    Thanks,
                    Attached Files

                    Comment


                      #11
                      Hello i2w8am9ii2,

                      Thank you for your response.

                      Your conditions are set up properly. I would ask you to use the Global Cross Hair on each of the charts that are used in the condition to verify they are in the proper position (all greater than or less than prior bar).

                      You can find details on the Cross Hair at the following link: https://ninjatrader.com/support/help...cross_hair.htm

                      Please let me know if you have any questions.

                      Comment


                        #12
                        Hi Patrick,

                        Thanks for the info and link.

                        I will try it out.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by jeronymite, 04-12-2024, 04:26 PM
                        2 responses
                        29 views
                        0 likes
                        Last Post NinjaTrader_BrandonH  
                        Started by Mindset, 05-06-2023, 09:03 PM
                        10 responses
                        263 views
                        0 likes
                        Last Post NinjaTrader_BrandonH  
                        Started by michi08, 10-05-2018, 09:31 AM
                        5 responses
                        742 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by The_Sec, Today, 02:29 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post The_Sec
                        by The_Sec
                         
                        Started by tsantospinto, 04-12-2024, 07:04 PM
                        4 responses
                        63 views
                        0 likes
                        Last Post aligator  
                        Working...
                        X