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 nandhumca, Yesterday, 03:41 PM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by The_Sec, Yesterday, 03:37 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by vecnopus, Today, 06:15 AM
            0 responses
            1 view
            0 likes
            Last Post vecnopus  
            Started by Aviram Y, Today, 05:29 AM
            0 responses
            5 views
            0 likes
            Last Post Aviram Y  
            Started by quantismo, 04-17-2024, 05:13 PM
            3 responses
            27 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X