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

Order with a StopLoss and ProfitTarget

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

    Order with a StopLoss and ProfitTarget

    Greetings,

    I'm new to NT8, could anybody teach me how to make a simple strategy placing a market order with a StopLoss at the certain price below the buying price and a ProfitTarget at the certain price above the buying price, PLEASE!?

    I'm currently using one made by Strategy Builder and it put

    SetProfitTarget(@"", CalculationMode.Currency, PT);
    SetStopLoss("", CalculationMode.Currency, SL);

    within the State == State.Configure if clause.

    Will that do the trick I wish for or it's something totally different!?

    Thank you very VERY much!!!
    Last edited by YoutingChu; 04-24-2018, 02:11 AM.

    #2
    Hello

    You must to the following :

    1- In OnBarUpdate, check that this.Historical == false

    2- When this.Historical == false then :

    3- Use this.EnterLong() or this.EnterShort() functions with a custom signal name (ex : "MySignalName")

    4- Use this.SetProfitTarget() and this.SetStopLoss() with the previously defined signal name

    I hope that this helps !

    Comment


      #3
      Will that condition stop me from optimizing the strategy!?

      Comment


        #4
        Hello YoutingChu,
        Thanks for your post.

        Is your goal to set the Stop Loss and Profit Target from the strategies parameters before you start the strategy, or is your goal for the Stop Loss and Profit target to be a dynamic value eg. always 5 ticks above/below the close ?

        Will that condition stop me from optimizing the strategy!?
        You are correct. If your strategy is not processing historical data you will not be able to backtest or optimize the strategy.
        Last edited by NinjaTrader_JoshG; 04-25-2018, 09:05 AM.
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          I would like it to be parameters where I can set up before I run the strategy.
          Maybe I should say, I need it to be parameters so I could optimize it!
          And I'm facing a weird problem too.
          No matter how big I set my StopLoss, it ALWAYS exit my order at the same price I enter it!!!
          On the other hand, it NEVER exit my order no matter how small I set my ProfitTarget!
          It was like to whole parameter thing is useless!!!
          PLEASE tell me what should I do!
          Thank you very VERY much!!!
          Last edited by YoutingChu; 04-24-2018, 07:41 PM.

          Comment


            #6
            Hello YoutingChu,
            Because the Strategy Builder will put SetStopLoss and SetProfitTarget inside State.Configure you would need to use one of the other Stop Order methods to optimize those values. Otherwise, you will need to unlock the strategy and put your SetStopLoss and SetProfitTarget methods elsewhere.
            Josh G.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by tkaboris, Today, 08:01 AM
            0 responses
            1 view
            0 likes
            Last Post tkaboris  
            Started by BarzTrading, Today, 07:25 AM
            1 response
            10 views
            1 like
            Last Post NinjaTrader_Clayton  
            Started by EB Worx, 04-04-2023, 02:34 AM
            7 responses
            161 views
            0 likes
            Last Post VFI26
            by VFI26
             
            Started by Mizzouman1, Today, 07:35 AM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by Radano, 06-10-2021, 01:40 AM
            20 responses
            616 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Working...
            X