Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StopLoss executed immediately!

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

    StopLoss executed immediately!

    Hi,

    I'm having a very simple scalping strategy and on signal I execute the following code:

    Code:
    EnterShort(Lot,"LNG");
    							SetProfitTarget("LNG", CalculationMode.Ticks, TakeProfit*TickSize);
    							SetStopLoss("LNG", CalculationMode.Ticks, StopLoss*TickSize, true);
    But when I try to execute this code in Backtesting basically After order is entered it exits right away, like stoploss is 0.

    Here is the trace:

    7/8/2011 2:29:47 PM Entered internal PlaceOrder() method at 7/8/2011 2:29:47 PM: BarsInProgress=1 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='SHRT' FromEntrySignal=''
    7/8/2011 2:29:47 PM Entered internal SetStopTarget() method: Type=Target FromEntrySignal='SHRT' Mode=Ticks Value=0.0002 Currency=0 Simulated=False
    7/8/2011 2:29:47 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='SHRT' Mode=Ticks Value=0.0004 Currency=0 Simulated=True
    7/8/2011 2:29:47 PM Cancelled pending exit order, since associated position is closed: Order='NT-00002/Backtest' Name='Profit target' State=Working Instrument='6E 09-11' Action=Sell Limit price=1.4219 Stop price=0 Quantity=1 Strategy='Scalper' Type=Limit Tif=Gtc Oco='NT-00000-454' Filled=0 Fill price=0 Token='9a318e0d13624113b97b6b85c9bb479a' Gtd='12/1/2099 12:00:00 AM'
    7/8/2011 2:29:47 PM Cancelled OCO paired order: BarsInProgress=0: Order='NT-00002/Backtest' Name='Profit target' State=Cancelled Instrument='6E 09-11' Action=Sell Limit price=1.4219 Stop price=0 Quantity=1 Strategy='Scalper' Type=Limit Tif=Gtc Oco='NT-00000-454' Filled=0 Fill price=0 Token='9a318e0d13624113b97b6b85c9bb479a' Gtd='12/1/2099 12:00:00 AM'
    7/8/2011 2:30:00 PM Entered internal PlaceOrder() method at 7/8/2011 2:30:00 PM: BarsInProgress=1 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='LNG' FromEntrySignal=''
    7/8/2011 2:30:00 PM Entered internal SetStopTarget() method: Type=Target FromEntrySignal='LNG' Mode=Ticks Value=0.0002 Currency=0 Simulated=False
    7/8/2011 2:30:00 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='LNG' Mode=Ticks Value=0.0004 Currency=0 Simulated=True
    7/8/2011 2:30:00 PM Cancelled pending exit order, since associated position is closed: Order='NT-00005/Backtest' Name='Profit target' State=Working Instrument='6E 09-11' Action=BuyToCover Limit price=1.4229 Stop price=0 Quantity=1 Strategy='Scalper' Type=Limit Tif=Gtc Oco='NT-00002-454' Filled=0 Fill price=0 Token='ce2a098eb5d547728e0037ad1b784226' Gtd='12/1/2099 12:00:00 AM'
    7/8/2011 2:30:00 PM Cancelled OCO paired order: BarsInProgress=0: Order='NT-00005/Backtest' Name='Profit target' State=Cancelled Instrument='6E 09-11' Action=BuyToCover Limit price=1.4229 Stop price=0 Quantity=1 Strategy='Scalper' Type=Limit Tif=Gtc Oco='NT-00002-454' Filled=0 Fill price=0 Token='ce2a098eb5d547728e0037ad1b784226' Gtd='12/1/2099 12:00:00 AM'


    Anyone could help me please?

    #2
    svlad, what values are you using for TakeProfit and StopLoss?
    AustinNinjaTrader Customer Service

    Comment


      #3
      Takeprofit - 2 and stoploss - 4. you can see it from traces.
      but it closes exactly at opening price, so Profit is always 0

      Comment


        #4
        Thanks, svlad. What sort of timeframe are you running this on? If an order is filled in the backtester and the bar is taller than the stop/target, the stop/target will be executed immediately on that bar.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Im running this on 1Tick bars as the main DataSeries, so it shouldnt give this problem.

          do you have any other ideas?

          Comment


            #6
            Do you set those stoplosses and targets from the Initialize() or OnBarUpdate()?

            If OnBarUpdate() please try setting them before executing your entry and then recheck.

            Comment


              #7
              I do set them OnBarUpdate. And I use FromSignal parameter. If I set them before entering the trade will it get attached correctly you think?

              But I will try and report back in any case. Thanks!

              Comment


                #8
                Yes, correct - but for static ones like yours I would just put them in Initialize().

                Comment


                  #9
                  Hi Bertrand,

                  unfortunately setting stoploss in Initialize didnt help my situation. it still exits just after entry.

                  Comment


                    #10
                    Looking at your first post again - why do you multiply the stops and targets to be entered in ticks already by the ticksize itself?

                    Please try just this below and then define the TakeProfit and StopLoss as int numbers:

                    SetProfitTarget("LNG", CalculationMode.Ticks, TakeProfit);
                    SetStopLoss("LNG", CalculationMode.Ticks, StopLoss, true);
                    Last edited by NinjaTrader_Bertrand; 07-18-2011, 09:22 AM.

                    Comment


                      #11
                      Thanks, just sent you an email

                      Comment


                        #12
                        Thanks, please also see my previous edited reply, spotted something about the way you setup your stop / target values.

                        Comment


                          #13
                          You are absolutely right!!! of course multiplication gives value close to zero.

                          Thanks a lot for the help!

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          600 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          347 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          103 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          558 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          558 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X