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

PLEASE help me understand SetProfitTarget and SetStopLoss

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

    PLEASE help me understand SetProfitTarget and SetStopLoss

    From what I'm understanding, SetProfitTarget and SetStopLoss set the offset value of the current entry price except the mode Price, right!?
    And it was set in the OnStateChange() under the condition State == State.Configure, right!?
    So all I need in the OnBarUpdate() is EnterLong or EnterShort then it will exit automatically for me once the Profit Target or Stop Loss is hit, right!?
    I don't need to put any ExitLong or ExitShort in my program, right!?
    But NO MATTER what and how I set up my PT and SL, my order was NEVER EXITED!
    Why was that!?!?!? What did I do wrong!? PLEASE help me out!!! Thank you very VERY much! God bless you !!!

    #2
    Hello YoutingChu,
    Thanks for your post.

    SetProfitTarget and SetStopLoss set the offset value of the current entry price except the mode Price, right!?
    Correct. In price mode the 'value' field represents the actual price.
    it was set in the OnStateChange() under the condition State == State.Configure, right!?
    Yes, that would be the correct place to use SetStopLoss() or SetProfitTarget() if your stop loss is a static value.
    So all I need in the OnBarUpdate() is EnterLong or EnterShort then it will exit automatically for me once the Profit Target or Stop Loss is hit, right!?
    Correct.
    I don't need to put any ExitLong or ExitShort in my program, right!?
    Correct. You can use whichever order methods work for your strategy.
    But NO MATTER what and how I set up my PT and SL, my order was NEVER EXITED!
    • What are the parameters for your SL, PT, and entry order?
    • Were the SL and PT submitted at all? If so, does the 'State' column on your 'Orders' tab say the SL/PT was canceled?
    • Are there any errors on the 'Logs' tab of your Control Center?
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Dear JoshG,

      Before I go any further, could you please teach me how could I check if my PT and SL is set and if my order is been exited, please!?
      I had tried to print the OrderAction and OrderState in OnOrderUpdate and OnExecutionUpdate, but it seems to be NOT what I think it is!
      Could you teach me the correct way to do it, please!?

      On another note, could you pleae teach me how can I get the current PT and SL prices please!?
      For example, if I SetProfitTarget(CalculationMode.Ticks,10) and SetStopLoss(CalculationMode.Ticks,10,false) and enter an order at the price of 1.2345.
      Then the PT will be 1.2355 and SL will be 1.2335, right!?
      Could you please teach me how could I get those 2 numbers please!?

      Thank you very much! God bless you!!!
      Last edited by YoutingChu; 05-29-2018, 11:30 PM.

      Comment


        #4
        Here is our help guide documentation on "Using OnOrderUpdate() and OnExecution() methods to submit protective orders". The sample demonstrates one way you could properly monitor OnExecutionUpdate() and OnOrderUpdate().
        Help Guide - Strategy Reference Samples

        Additionally, the two following links demonstrate how to monitor your PT and SL orders.



        You can monitor your Control Centers 'Orders' tab for information on the state of your SL and PT. If you have Chart Trader turned on then the SL and PT will be displayed on the chart as well.

        In regards to the specific values of a tick, that is going to be different for every instrument. You will need to consider that when building your logic. If you want those numbers specifically than you should use CalculationMode.Price and then use the price you want as the other input parameter for the SL or PT. Similar to SetProfitTarget(CalculationMode.Price,1.2355). Otherwise, you may need to do some math in your logic to get the specific stop loss and profit target values that you want.

        Edit: Spelling and formatting
        Josh G.NinjaTrader Customer Service

        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
        16 views
        0 likes
        Last Post Javierw.ok  
        Working...
        X