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

Modifying stop-loss order to breakeven

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

    Modifying stop-loss order to breakeven

    Hello,
    Please, help me.
    I downloaded SampleOnOrderUpdate for change the stop loss order for breakeven and made a long strategy and a short strategy separate (both work well), then I tried to combine them into one strategy (I made several options), but only Long strategy is working correct now and I don't I can understand what I did wrong.

    The OnOrderUpdate() and OnExecution() methods are reserved for experienced programmers. Instead of using Set() methods to submit stop-loss and profit target orders, you can submit and update them manually through the use of IOrder and IExecution objects in the OnOrderUpdate() and OnExecution() methods. The OnOrderUpdate()


    Regards,

    Yury
    Attached Files

    #2
    Hello YuryBr,

    Thank you for your note.

    I'm unable to look at the strategy due to it being exported as a compiled assembly. Would you please export the strategy again without having the Export as compiled assembly checked? (see attachment)

    I look forward to your reply.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hello Alan,
      Thank you for fast reply.
      I send you code of stategy (txt and cs)

      regards,

      Yury
      Attached Files

      Comment


        #4
        Hello YuryBr,

        It looks as though the bracket you have under,
        Code:
        	if (Position.MarketPosition == MarketPosition.Long && Close[0] >= Position.AveragePrice + (39 * (TickSize / 2)))
        Encapsulates the rest of the code within OnBarUpdate which includes your if statement related to EnterShort, which is opposite to your EnterLong condition (highlighted in blue). See screen shot I've attached.

        I would suggest making changes to the placement of closing brackets and adding print statements to check whether your conditions are becoming true. I’ve provided a link to a youtube video which covers an example of using prints to understand behavior:
        Dive into manipulating C# code from within an unlocked NinjaScript strategy using the NinjaScript Editor.NinjaTrader 7 is an award winning end to end online ...


        I’ve provided a link covering debugging which you may find helpful.
        Debugging: http://ninjatrader.com/support/forum...ead.php?t=3418

        Please let us know if you need further assistance.
        Last edited by NinjaTrader_AlanP; 03-15-2017, 01:16 PM.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Allan,
          All good, thank you for help.
          Could you help me else? I need to do a stop order move and at various intervals, for example, every 10 minutes to check: if the price has not grown for 10 minutes, then stop move up on 2 ticks.

          Regards,

          Yury

          Comment


            #6
            Hello Yury,

            I do not have any samples of this and building indicators/Strategies is out of the scope of our support.

            I attached a sample strategy which will modify a limit entry order if it’s not filled in 60 seconds. To accomplish this I save the current time to a DateTime variable at the time the order is submitted, I then add 60 second to that variable and compare the current time to that time varible, if its greater, than the entry limit order is modified.

            You could apply this logic to accomplish what you’re looking to do.

            If you would like someone from business development to reach out with a list of third party developers that would be interested in building your strategy, please let us know.
            Attached Files
            Alan P.NinjaTrader Customer Service

            Comment


              #7
              Hello Alan,
              Thank you very much.

              Regards,

              Yur

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by algospoke, 04-17-2024, 06:40 PM
              3 responses
              26 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by bmartz, 03-12-2024, 06:12 AM
              3 responses
              27 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Started by Aviram Y, Today, 05:29 AM
              2 responses
              8 views
              0 likes
              Last Post Aviram Y  
              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