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

SetStoploss

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

    SetStoploss

    I trying to have a breakeven stoploss when my open equity on the trade hits $200. Seems to be at least hitting the code with the indication I draw on the screen, but thestoploss order does not fire at the breakeven point, but waits till another exit in my code later on.. Enclosed is a portion of the trace and a chart with a crude circle where the stopout should of occured.

    if (Position.GetProfitLoss(Close[0], PerformanceUnit.Currency)>= 200 && Position.MarketPosition != MarketPosition.Flat)
    {
    SetStopLoss(entryprice);
    DrawText("BEt"+ CurrentBar,"-s-s",0,entryprice,Color.Red);
    }
    Attached Files

    #2
    Hello,

    It looks like the Stop was placed at the time expected:

    12/10/2012 4:00:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=0 Currency=1412.75 Simulated=False



    12/10/2012 4:48:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=0 Currency=1412.75 Simulated=False

    From your logs, was there any information truncated? Do you cancel these stops for any reason else where in the code/
    MatthewNinjaTrader Product Management

    Comment


      #3
      Originally posted by gg80108 View Post
      I trying to have a breakeven stoploss when my open equity on the trade hits $200. Seems to be at least hitting the code with the indication I draw on the screen, but thestoploss order does not fire at the breakeven point, but waits till another exit in my code later on.. Enclosed is a portion of the trace and a chart with a crude circle where the stopout should of occured.

      if (Position.GetProfitLoss(Close[0], PerformanceUnit.Currency)>= 200 && Position.MarketPosition != MarketPosition.Flat)
      {
      SetStopLoss(entryprice);
      DrawText("BEt"+ CurrentBar,"-s-s",0,entryprice,Color.Red);
      }
      Looks like you have an explicitly coded exit order somewhere?

      Comment


        #4
        Is this the StopLoss being canceled in the trace?: at 12/10/2012 7:42:00 AM Cancelled pending exit order, since associated position is closed: Order='NT-00339/Sim101' Name='Stop loss' State=Working Instrument='ES 12-12' Action=BuyToCover Limit price=0 Stop price=1422.25 Quantity=3 Strategy='ESanaTL' Type=Stop Tif=Gtc Oco='NT-00228-308' Filled=0 Fill price=0 Token='6a82db0bdab34d4f89ae52284b314300' Gtd='12/1/2099 12:00:00 AM'

        I don't cancel anything but just reverse the position with a EnterShort(Qty,"short"),EnterLong(Qty,"long")
        I dont have any Name='Stop loss' in any of my orders.

        Comment


          #5
          the code just is a reversal strategy.. and everything was working as designed, I was just adding a BE stoploss to try and limit loses after some profit. So only the code SetStopLoss was added in an attempt to do this. Whats curious is that u can see on the screen print the -s-s when the SetStopLoss get placed and one would think that a few bars later when the price retraces to breakeven price should have fired an order to go flat, but seems to just doesn't care...

          Comment


            #6
            Hello gg80108,
            Looks like you have coded stop with the the absolute stop value overload.

            Code:
            [COLOR="Red"]SetStopLoss(entryprice);[/COLOR]
            If you try changing the stop order code as below then are you able to make it work.

            Code:
            SetStopLoss(CalculationMode.Price, entryprice);
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              txs works now....

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by haas88, 03-21-2024, 02:22 AM
              18 responses
              205 views
              0 likes
              Last Post haas88
              by haas88
               
              Started by Board game geek, Today, 02:20 AM
              0 responses
              1 view
              0 likes
              Last Post Board game geek  
              Started by knighty6508, Today, 01:20 AM
              2 responses
              12 views
              0 likes
              Last Post knighty6508  
              Started by franatas, Today, 01:53 AM
              0 responses
              2 views
              0 likes
              Last Post franatas  
              Started by knighty6508, Today, 01:17 AM
              0 responses
              9 views
              0 likes
              Last Post knighty6508  
              Working...
              X