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

Increase position when I get a objetive

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

    Increase position when I get a objetive

    Hi,

    I want to increase a position when I get a objetive.

    For example.

    If I entry in a position, when this increase 2% then I want to increase another position.

    I am trying this but I can't to increase it

    Can you help me?


    Thanks and best regards.

    #2
    Hello,

    Thank you for the question.

    I wanted to ask, when you say
    If I entry in a position, when this increase 2% then I want to increase another position.

    I am trying this but I can't to increase it
    Do you already have code that tries to enter another position but does not?

    If so this could potentially be the Entries Per Direction you have set in the strategies properties.

    Can you please confirm if this is the case?


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post

      If so this could potentially be the Entries Per Direction you have set in the strategies properties.

      Thanks for your reply.

      I think that this is the issue, how and where I can set up this in the code?


      Thanks and regards.

      Comment


        #4
        Hello,

        Entries Per Direction can be set in Code or in the User Interface, from the Interface you would set this in the Strategies Properties before enabling it.

        Using code, you can see this example in the help guide that better explains the usage of EntriesPerDirection: http://ninjatrader.com/support/helpG...esperdirection

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Ok

          Is it possible in NT configure a setTrailStop by each entry?


          Thanks and regards

          Comment


            #6
            Hello,

            Yes you can certainly attach a SetTrailStop to a specific entry, all of the Set methods can do this as well.

            If you take a look in the HelpGuide at the page for SetTrailStop, it lists all of the avalilable ways to use it.



            The one you would need for this would be:

            Code:
            SetTrailStop(string fromEntrySignal, CalculationMode mode, double value, bool simulated)
            The first string is the SignalName you gave to the entry, so if I used:

            Code:
            EnterLong("TestSignal");
            I would need to provide "TestSignal" as the FromEntrySignal.


            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thanks for the reply.

              Is it possible that you give a example in a script?



              Thanks and regards.

              Comment


                #8
                Hello ziquillo,

                Here is an example of using SetTrailStop():

                SetTrailStop ("Entry1", CalculationMode.Ticks, 10, false);

                This would tie the trailing stop to any entry position with the label of "Entry1", using a 10 tick trailing stop and the stop would not be simulated.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks,

                  I have another question.


                  If I add a position with this:

                  EnterLong(1, Position123);


                  For example if this position increase 1%, then I want to set a trail stop with 0.1%

                  How I have to set this TrailStop position?

                  SetTrailStop(Position123, CalculationMode.Percent, 0.1, true);

                  Is this right?


                  Can I to print in log the name position, price and stop If it's definied?




                  Thanks and best regards.
                  Last edited by ziquillo; 09-03-2015, 05:14 PM.

                  Comment


                    #10
                    Hello ziquillo,

                    Thanks for your post.

                    If I understand correctly, I think you want SetTrailStop (Position123, CalculationMode.Percent, 0.001, true); // 1/10th percent trail stop

                    Please keep in mind this note from the helpguide: Should you call this method to dynamically change the trail stop price in the strategy OnBarUpdate() method, you should always reset the trail stop price/offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your trail stop order on your next open position
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      I'm sorry but I don't understand this.

                      Can you explain me a bit?


                      Thanks!

                      Comment


                        #12
                        Hello ziquillo,

                        What is not clear?
                        Paul H.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_Paul View Post
                          Should you call this method to dynamically change the trail stop price in the strategy OnBarUpdate() method


                          I have to call this method with each position all the time?

                          Originally posted by NinjaTrader_Paul View Post
                          you should always reset the trail stop price/offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your trail stop order on your next open position

                          I dont understand "reset the trail stop", can you give a example?



                          Another question, is it possible with NOT DEMO a strategy on bar update = false? I want to say whe when the bar is being generated.



                          Thanks and best regards.

                          Comment


                            #14
                            Hello ziquillo,

                            Thanks for your reply and taking the time to clarify your questions.

                            If you put SetTrailStop() in the initialize method then it will apply uniformly to all entries with the name of Position123.

                            If you were to change the SetTrailStop() method in the OnBarUpdate() section then the HelpGuide comment is that you reset your SetTrailStop to the original SetTrailStop value because the method will retain the last used price, percentage or ticks.

                            If you are not dynamically changing the value of SetTrailStop() then there is nothing to worry about. It is preferred that indeed you do use the SetTrailStop() method in the Initialize() section.

                            An example of resetting may be more confusing if you are not using SetTrailStop() in the OnBarUpdate() method.

                            You should be able to set the strategy to CalculateOnbarClose = false which means it will recalculate its strategy code on each tick instead of only once at the end of the bar.
                            Paul H.NinjaTrader Customer Service

                            Comment


                              #15
                              Hello Paul,

                              Thanks for you reply.

                              Originally posted by NinjaTrader_Paul View Post
                              If you put SetTrailStop() in the initialize method then it will apply uniformly to all entries with the name of Position123.
                              I think that I have not explain correctly.

                              I want to say:

                              I have a position: Position123

                              When I have with Position123 for example 1% of increase since my entry then I set a trail stop with 0.1%, when trail stop is configurated the last entry THEN I make another entry and change the name Position124.

                              When Position124 have a 1% of increase since this entry I want to set up a trail stop 0.1% then I make another entry...


                              I hope explain better of this way.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by bortz, 11-06-2023, 08:04 AM
                              47 responses
                              1,607 views
                              0 likes
                              Last Post aligator  
                              Started by jaybedreamin, Today, 05:56 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post jaybedreamin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              19 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              15 views
                              0 likes
                              Last Post Javierw.ok  
                              Working...
                              X