Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to move StopLoss to breakeven +1 tick.

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

    How to move StopLoss to breakeven +1 tick.

    Hallo.
    I would like to move stop loss to breakeven +1 tick my strategy compile well but shows error when working because "can not place stop loss over the buying price."
    Are the any place where I can see sample of such script, or anybody can tell me how to change below script ??
    Rgds
    Czarek

    // If a short position is open, allow for stop loss modification to breakeven
    else if (Position.MarketPosition == MarketPosition.Short)
    {
    // Once the price is lower than entry price-breakeven ticks, set stop loss to breakeven + 1 tick
    if (Close[0]+ breakeven * TickSize < Position.AvgPrice)
    {
    SetStopLoss(CalculationMode.Price, Position.AvgPrice - 1 * TickSize);
    }
    // Once the price is lower than entry price-halfbreakeven ticks, set stop loss to breakeven + halfstop
    if (Close[0] + breakevenhalf * TickSize < Position.AvgPrice)
    {
    SetStopLoss(CalculationMode.Price, Position.AvgPrice + halfstop * TickSize);
    }

    #2
    Can you paste in the exact error message?
    RayNinjaTrader Customer Service

    Comment


      #3
      I got 2 error messages at same time:
      Strategy 'NQLimit' submitted na order that generate the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close position and terminated itself.

      Sell stop or selstop limit order can't be placed above the market. Affedted Order: Sell 1 Stop @1816

      Comment


        #4
        That is right. You can't submit stop losses above the current market price. You will need to go back and rework your conditions. I suggest you do the comparison of Close[0] by itself and do all the math adjustments to the Position.AvgPrice end.

        Take a pen and paper and run through your logic by hand to find where the mathematical flaw is located and then make adjustments as needed would probably be the easiest way to fix this.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I'm not programmer and this looks very difficult for me.
          Can you find the sample of breakeven +1 tick for me?
          Czarek

          Comment


            #6
            Czarek,

            Due to bandwidth reasons I cannot do the work for you. If you want you can try contacting one of the NinjaScript Consultants here to program your strategy for you though: http://www.ninjatrader.com/webnew/pa...injaScript.htm
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            26 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, 02-22-2024, 01:11 AM
            5 responses
            32 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, Yesterday, 09:53 PM
            2 responses
            49 views
            0 likes
            Last Post wzgy0920  
            Started by Kensonprib, 04-28-2021, 10:11 AM
            5 responses
            192 views
            0 likes
            Last Post Hasadafa  
            Started by GussJ, 03-04-2020, 03:11 PM
            11 responses
            3,234 views
            0 likes
            Last Post xiinteractive  
            Working...
            X