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

strategy advise

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

    strategy advise

    Hey Guys.

    I'm a newbie to the trading game and I have created a strategy at least I think. But i'm getting some errors while compiling.

    I want to create the following strategy.

    If:

    Target 1: 100 points, if it does not make 100 points close at target 2
    Target 2: 90 points, if it does not make 90 points close target 3
    Target 3: 80 points, if it does not make 80 points close target 4
    Target 4: 70 points, if it does not make 70 points close target 5
    Target 5: 60 points, if it does not make 60 points close target 6
    Target 6: 50 points, if it does not make 50 points close target 7
    Target 7: 40 points, if it does not make 40 points close target 8
    Target 8: 30 points, if it does not make 30 points close target 9
    Target 9: 20 points, if it does not make 20 points close target 10
    Target 10: 10 points, if it does not make 10 points close target 11
    Target 11: 5 points, if it does not make 5 points close 12
    Target 12: 2 points.

    Now I have created something with this youtube video from big mike. title: Advanced NinjaTrader Strategy How-to

    But I can not compile it let alone know if the code is right.

    Can somebody help me?

    Thnx in advance.

    Gr. a total newbie.

    #2
    Hello mitcheman,

    I will be glad to help you out with getting your strategy to compile.

    Without seeing your actual code it’s hard to say where you are running into problems compiling, with that said I would be happy to help you with your code if you would like to post it so I could see where it may be having trouble.

    Also if you would like you can attach a screenshot of the message you get when trying to compile to better assist you in getting it working.

    First we should address why it is not compiling, a good resource to take a look at would be this link to a post on compile errors.


    If you are still unable to compile please let me know and I can take a look at what you have.

    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hey Jesse,

      Thank you very much. Do I need to post the code here or do I PM you? What is the correct way to do this?

      Here is the screen it is in dutch. Is that a problem?

      link to the screen https://www.dropbox.com/s/m4ec7lfo7w...le%20error.jpg

      Link to my code: https://www.dropbox.com/s/zvv33mumgt...20strategy.txt
      Last edited by mitcheman; 04-24-2014, 02:59 PM.

      Comment


        #4
        Hello mitcheman,
        That is entirely up to you, if you would like to post it here you can otherwise if you do not want it to be a public post could I ask that you email me at [email protected] with ATTN:Jesse in the title and attach it there.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello mitcheman,
          That is entirely up to you, if you would like to post it here you can otherwise if you do not want it to be a public post could I ask that you email me at [email protected] with ATTN:Jesse in the title and attach it there.
          Hey Jesse,

          I just uploaded it to my dropbox account:



          And I want to achive this strategy for short and long:

          Target 1: 100 points, if it does not make 100 points close at target 2
          Target 2: 90 points, if it does not make 90 points close target 3
          Target 3: 80 points, if it does not make 80 points close target 4
          Target 4: 70 points, if it does not make 70 points close target 5
          Target 5: 60 points, if it does not make 60 points close target 6
          Target 6: 50 points, if it does not make 50 points close target 7
          Target 7: 40 points, if it does not make 40 points close target 8
          Target 8: 30 points, if it does not make 30 points close target 9
          Target 9: 20 points, if it does not make 20 points close target 10
          Target 10: 10 points, if it does not make 10 points close target 11
          Target 11: 5 points, if it does not make 5 points close 12
          Target 12: 2 points.

          Comment


            #6
            Hello mitcheman,

            Ok so I found a few errors in the code

            There were a few misspellings in your public definitions smalength, emalength, hmalength
            You also had #region Properties in-between each public definition
            CalculationMode.Price had a lowercase m when it needs to be an uppercase M
            You had private voide ManageOrders () needs to be private void ManageOrders ()

            I will go ahead and attach the code to the post here. I did compile it and it went through fine on my end.

            Let me know if I may be of further assistance.
            Attached Files
            JesseNinjaTrader Customer Service

            Comment


              #7
              Jesse,

              Many thanks!

              So I can use this strategy for my target 1 to 12 plan?

              Comment


                #8
                Hello mitcheman,
                You could certainly modify the edited strategy to your liking now that it compiles.

                It looks like in the strategy you uploaded you already have all your targets set up so it would most likely just require you to plan how you would like to execute what you are trying to do and write logic for that.

                I am unable to directly create the strategy for you but I will help you with coding questions you may have in the process of creating your strategy.

                You may find this useful; this is a link to the Ninjascript reference guide. It contains examples and reference on everything supported in Ninjascript.


                Here is a useful forum post to help with debugging Ninjascript. http://www.ninjatrader.com/support/f...ead.php?t=3418
                You can use the Print() statement to output variables to verify you are getting the correct values.
                I like to use this while creating code so I know that everything I have done up till now is verified and working to make the rest of the process less difficult.


                Also if you have never created your own strategy you may find the following video useful.
                Download NinjaTrader FREE at http://www.ninjatrader.comThis video is a recording of our live "Automated Strategy Development Level 1" webinar covering the to...


                Finally if you do not wish to do the coding yourself you could take a look into our Ninjascript Consultants page where you can have your strategy created for a price.



                Please let me know if I may be of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Jesse,

                  Is is possible to combine our strategy with this?

                  /// </summary>
                  [Description("Enter the description of your strategy here")]
                  public class TWEEpunten : Strategy
                  {
                  #region Variables
                  // Wizard generated variables
                  // User defined variables (add any user defined variables below)
                  #endregion

                  /// <summary>
                  /// This method is used to configure the strategy and is called once before any strategy method is called.
                  /// </summary>
                  protected override void Initialize()
                  {
                  Add(ParabolicSAR(0.02, 0.2, 0.02));
                  Add(ParabolicSAR(0.02, 0.2, 0.02));
                  SetProfitTarget("", CalculationMode.Ticks, 2);

                  CalculateOnBarClose = true;
                  }

                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
                  // Condition set 1
                  if (CrossBelow(ParabolicSAR(0.02, 0.2, 0.02), Low, 1))
                  {
                  EnterLong(DefaultQuantity, "");
                  }

                  // Condition set 2
                  if (CrossAbove(ParabolicSAR(0.02, 0.2, 0.02), High, 1))
                  {
                  EnterShort(DefaultQuantity, "");
                  }


                  }

                  #region Properties
                  #endregion
                  }
                  }


                  My goal is that when the system hits 2 points that it closes with 2 points profit. But if it keeps going up 5, 10, 20 etc. it needs to close higher. Just like if wrote in my 12 target idea.

                  Is is possible to combine the strat. you made with this?

                  Comment


                    #10
                    Hello mitcheman,

                    Have you taken a look at the SetTrailStop() ?


                    You can still set a profit target if you would like but it sounds more like you want a trailing stop. Basically if you leave the script as you have it now and just add in

                    Code:
                    SetTrailStop("EnterLong", CalculationMode.Ticks, 4, true);
                    What this is doing is looking for EnterLong, and then follows the EnterLong signal Price by 4 ticks. The True at the end tells it if it’s in simulation or not

                    Here is the changed OnBarUpdate() from the code you provided

                    Code:
                    protected override void OnBarUpdate()
                    {
                    
                    / Condition set 1
                    if (CrossBelow(ParabolicSAR(0.02, 0.2, 0.02), Low, 1))
                    {
                    EnterLong(DefaultQuantity, "EnterLong"); // I added "EnterLong" signal name so the SetTrailStop knows when to start trailing
                    			
                    }
                    			
                    			
                    // Condition set 2
                    if (CrossAbove(ParabolicSAR(0.02, 0.2, 0.02), High, 1))
                    {
                    EnterShort(DefaultQuantity, "");
                    }
                    SetTrailStop("EnterLong", CalculationMode.Ticks, 5, true); // This looks for the signal name EnterLong to become active, once it is active this chases the price up as long as it goes up.
                    }
                    Notice i added in a Signal name for EnterLong, and then I used this signal name with the SetTrailStop so the SetTrailStop starts following the upward moving price as long as it’s going up, but when the price falls, the stop stays in place securing profit.

                    Please let me know if I may be of additional assistance.
                    JesseNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by nleitman, Yesterday, 11:46 AM
                    16 responses
                    43 views
                    0 likes
                    Last Post nleitman  
                    Started by MSerag, Yesterday, 11:52 PM
                    3 responses
                    23 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by dcriador, Yesterday, 01:43 AM
                    6 responses
                    27 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by James650, Today, 08:25 AM
                    1 response
                    2 views
                    0 likes
                    Last Post NinjaTrader_ChristopherJ  
                    Started by Rogers101, 05-05-2024, 11:30 AM
                    14 responses
                    40 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X