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

How do I write an equation to define my variable?

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

    How do I write an equation to define my variable?

    I started NT7 only today and am trying to build a simple code to test using the edit wizard. I want to take entry based on HMA slope (steepness) and other things. I am stuck in writing
    this:

    HMASLOPE= (Close of previous bar-Close of previous of previous bar)/120;

    120 mins being the time frame.

    The formula should give me a slope between the last 2 bars preceding the current bar, say in $/mint.

    Please help writing this in the wizard!!

    Thanks!
    Last edited by [email protected]; 06-09-2017, 02:12 PM.

    #2
    Hello [email protected]

    Thanks for opening the thread and welcome to the forums!

    The Strategy Wizard is limited to only making very simple strategies and does not have the ability for you to apply mathematical offsets. You would not be able to perform any subtraction without unlocking the code first.

    There is some ability to use mathematical offsets in NinjaTrader 8, and you could create this in the Strategy Builder. I've attached some screenshots describing how this can be set up.

    We have recorded webinars on our YouTube page that shows how to use the strategy Wizard and the Strategy Builder.

    Strategy Wizard 301 - https://www.youtube.com/watch?v=FmBiNYsf1e8

    Strategy Builder 301 - https://www.youtube.com/watch?v=HCyt90GAs9k

    Please let me know if I can be of further assistance.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Many thanks, Jim!

      For some reason, I cannot switch to NT8 at this moment. But you said I can unlock the code to write, possibly out of the wizard. Will try your video to know how to do that.

      As a compromise, I can use the "rising" or " falling" function perhaps? Then what is the step to write "When HMA is rising" AND "xxxx" do this?

      Hope I'm not being a bother

      Comment


        #4
        Hello sandip1952,

        Thanks for the additional question, it is certainly not a bother.

        You could use the Rising() and Falling() methods in your strategy, if you wish. Our help guide has some sample code describing how you can check if an SMA with a period of 20 is rising between the previous and current bar.

        Code:
        if (Rising(SMA(20)))
            EnterLong();
        https://ninjatrader.com/support/help...nt7/rising.htm

        If you would like, you can unlock your strategy and write the logic for this NinjaScript. Writing client code and providing programming education falls outside of the scope of services that we offer, so there is a limited amount of help I would be able to provide for writing this code. We do, however, have some resources you can look into to get started with NinjaScript.

        Educational Resources : https://ninjatrader.com/support/help...g_concepts.htm

        Tutorials: https://ninjatrader.com/support/help...strategies.htm

        I would advise however, that if you want to write the code on your own, to use the Strategy Wizard and the View code button to watch how the Strategy Wizard write the code for the strategy so you can do the same.

        Also, since the Rising() and Falling() methods look at the value of the previous bar to the current bar, you could create a condition in the Strategy Wizard as attached.

        If you are looking for services to help write and debug your code, you can write in to platformsupport[at]ninjatrader[dot]com with the thread URL and the text "Attention Jim." I will be able to get you connected with a member of our Business Development team who can then provide a list of NinjaScript Consultants who would be happy to develop and debug your code with/for you.

        Please let me know if I can be of further help.
        Attached Files
        JimNinjaTrader Customer Service

        Comment


          #5
          Great help again Jim! I'll try this right away and get back if I find something worthy to discuss.

          But I believe I wrote a mail to the address you provided for obtaining consultants' services.

          With warm regards!

          Sandip

          Comment


            #6
            Hello Sandip,

            It looks like another colleague of mine received your inquiry. I have notified the Business Development team to reach out to you by email.

            Thanks!
            JimNinjaTrader Customer Service

            Comment


              #7
              Jim

              Will I be contacted for the paid services? I wrote to "platform" but don't seem to have received a response.

              In the meantime I am curious to know if there is a simple answer to my previous querires which were:

              1) If repainting/vanishing signals can be taken care of
              2) if immediate mode of execution is possible.

              Warm regards!

              Sandip

              Comment


                #8
                Hello Sandip,

                Thanks for your reply.

                You should have received an email from me and another from Ryan L. Please check to make sure the emails from platformsupport[at]ninjatrader[dot]com are not going into a spam folder.

                I will ask Ryan if he can to reach out to you again, as well.

                You had also asked:
                1) If repainting/vanishing signals can be taken care of
                2) if immediate mode of execution is possible.
                I'm not quite sure what you are describing for repainting/vanishing signals, could you please elaborate on this? If you could provide a screenshot, it can help.

                To send a screenshot with Windows 7 or newer, we recommend using Window's Snipping Tool.

                Click here for instructions

                Alternatively, please take a screenshot with Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.

                Click here for detailed instruction

                You can enable Immediately Submit so your strategy does not have to wait until it is in a flat position before it begins placing live trades, and you can also configure the Min. Bars Required so your strategy can begin placing trades with less delay.

                Immediately Submit is fully described in the Syncing Account Positions documentation here: https://ninjatrader.com/support/help..._positions.htm

                Please let me know if I can be of further help.
                Last edited by NinjaTrader_Jim; 06-20-2017, 06:59 AM.
                JimNinjaTrader Customer Service

                Comment


                  #9
                  Hi Jim

                  I attach the following screenshots to explain the issue of vanishing signals. It vanishes because the condition is no longer valid and may or may not reappear. Kindly note that trade has been triggered at the first appearance.

                  What is needed is to fix a signal and not let it vanish(blink).

                  We can take this discussion forward once the basic questions get settled.

                  With warm regards!

                  Sandip
                  Attached Files

                  Comment


                    #10
                    Hi Sandip,

                    NinjaScripts are in charge of their own means of placing orders through the conditions written for those orders to be placed. Signals would not "vanish" unless the logic programmed into the NinjaScript allows the strategy to do so.

                    Limit orders placed through a NinjaScript require a certain overload to be able to be submitted as Live Until Cancelled. You can discuss this with your strategy developer and you can also reference our documented Advanced Order Handling rules below.

                    Advanced Order Handling - https://ninjatrader.com/support/help...r_handling.htm

                    Please let me know if you have any additional questions.
                    JimNinjaTrader Customer Service

                    Comment


                      #11
                      Hello gplatis,

                      Thanks for your question.

                      I would recommend to use the Strategy Builder or Strategy Wizard to create the syntax after defining the logic in the Conditions and Actions tab. You can click View Code before you make the condition and then again afterwards to see the generated NinjaScript syntax.

                      For example, you could create the logic in the Strategy Builder that checks if SMA(20) from X bars ago is greater than the price value from Y bars ago and less than the price value from Z bars ago. I've attached some pictures showing how a similar condition group can be made in the Builder. Your logic would need to follow a similar "literal definition" of the strategy.

                      This condition can be placed in a group for If All, and then a similar condition can be created the same way to check for another bars ago. When either of these condition groups (If Any) are met, the Action should take place.

                      Conditions can be grouped together, or you can set user defined variables to control other condition sets. For NinjaTrader 7, the same steps can be taken, however, you must use User Defined Variables and additional condition sets since you cannot make condition groups.

                      There can be an infinite amount of logical configurations and there will be some effort to make sure the conditions are written correctly. When creating the logic, I recommend to create the conditions as simple as possible so you can test them with a Misc > Print() statement and view the results in the NinjaScript Output window. This way you can follow your logic as it executes and you will know of any alterations you may need to make. When you know a part of the condition works, you can safely add additional logic to the condition.

                      Please let me know if I may be of further assistance.
                      Attached Files
                      JimNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by bmartz, 03-12-2024, 06:12 AM
                      4 responses
                      32 views
                      0 likes
                      Last Post bmartz
                      by bmartz
                       
                      Started by Aviram Y, Today, 05:29 AM
                      4 responses
                      12 views
                      0 likes
                      Last Post Aviram Y  
                      Started by algospoke, 04-17-2024, 06:40 PM
                      3 responses
                      28 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Started by gentlebenthebear, Today, 01:30 AM
                      1 response
                      8 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Started by cls71, Today, 04:45 AM
                      1 response
                      7 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Working...
                      X