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

how does StopLoss work in Backtest?

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

    how does StopLoss work in Backtest?

    Hi,

    I have aquestion about how does StopLoss work in Backtest. I have a strategy with a 1% StopLoss and 4 ticks of Profit Target (in the same bar, they are range bars).

    The thing is that most of the Stop Loss are realized in the open of the bar, and the rest of the Stop Loss I don't know which criteria are they following.

    I attach a graph (Mini SP-500) with examples. In fact 1% (Stop Loss)of 1300 is 13 points, or 52 ticks, so theoretically in the example the Stop Loss is never reached. That's why I am confused

    Sincerely
    Attached Files

    #2
    dvercher, what double input value did you set for your stoploss in the code to represent the 1% here? 0.01?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I realized I just had in the code: private double stPct=1

      Now, I have 0,01 that means 1%

      private double stPct = 1;
      And then
      double StopLoss= StPct/100 with the same profittarget (4 ticks)

      My question is:

      Look at the trade in the 3rd of June. It is realized in 1306. The stopLoss shoul be in 1293 (1%). But the position in closed in the opne of the bar in 1297,25.

      I attach you the graph.

      Sincerely
      Attached Files

      Comment


        #4
        Hello,

        This is Brett following up here for Bertrand.

        See on your screenshot where the order name is Sell. This means a new order to sell was generated from either EnterShort() code or ExitLong() code for example.

        If the stop loss was hit it would show as Stop Loss with the text note.

        Let me know if I can be of further assistance.

        Comment


          #5
          Yes, you are right, it sells because in the code it says ExitLong at 22:00.

          Now I put my Stop Loss in 0,1%

          And Why if I have my Stop Loss in 0,1%, it says ExitLong at the end of my session instead of showing StopLoss in 1304,7 (that is 0,1% of 1306)

          The code is :

          private double stPct = 0,1;
          And then
          double StopLoss= StPct/100 with the same profittarget (4 ticks)
          Finally:
          SetStopLoss (CalculationMode.Percent,StopLoss)

          Comment


            #6
            Hello,

            You would need to check that the stop loss should have been hit or not. I suspect not as it does not show as hit.

            To do this you need to know the price the stop loss submitted too, since your getting more advanced with this I would recommend you use the following so you can monitor your stop loss.



            Let me know if I can be of further assistance.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by algospoke, 04-17-2024, 06:40 PM
            6 responses
            48 views
            0 likes
            Last Post algospoke  
            Started by arvidvanstaey, Today, 02:19 PM
            4 responses
            11 views
            0 likes
            Last Post arvidvanstaey  
            Started by samish18, 04-17-2024, 08:57 AM
            16 responses
            61 views
            0 likes
            Last Post samish18  
            Started by jordanq2, Today, 03:10 PM
            2 responses
            9 views
            0 likes
            Last Post jordanq2  
            Started by traderqz, Today, 12:06 AM
            10 responses
            21 views
            0 likes
            Last Post traderqz  
            Working...
            X