Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Wizard to create a daily PNL stop

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

    Strategy Wizard to create a daily PNL stop

    Hello,
    I have a strategy that I've been using that I've made with the strategy wizard. I was hoping to have the strategy stop after a total pnl of -300. I tried using the realized pnl selection under strategies, then compare it to a variable called pnl. But that doesnt seem to allow any trades at all.

    I am trying to avoid unlocking the code and actually coding it in because #1 I like to modify the strat on a daily basis and its a lot more time consuming to do it via code and #2 I dont know what the heck im doing.

    Any advice on how to accomplish this feat via strategy wizard would be greatly appreciated.

    #2
    gooph, using the realized PnL from the strategy section is what you're looking for. What is the variable you're comparing it to that doesn't let it take any trades?
    AustinNinjaTrader Customer Service

    Comment


      #3
      Sorry, I guess I should explain myself a little bit better. I am using the Realized PnL in the Strategy section. Then I am comparing it to a User Variable called PNL that I set at -299.
      One of the trade criteria is that realized pnl is > than PNL(variable set at -299). My thinking is that when I have no trades I would have $0 pnl so it should technically be greater than -299.

      Does that make sense?

      Comment


        #4
        Originally posted by gooph View Post
        the trade criteria is that realized pnl is > than PNL(variable set at -299).
        gooph, try switching the criteria to realized PnL is < PNL(-299). For example, if your strategy had a realized PnL of -330, -330 is actually less than (further away from from 0) than -299.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Great... I guess my logic was a little messy. One last question... when I backtest the pnl does not reset on a daily basis. so as soon as the strategy racks up a loss it stops. Which is ok i suppose. will this affect live trades moving forward?

          Comment


            #6
            gooph,

            If you would like it to reset you can program the logic to be keep track of the value at the end of each day. Then it is just a matter of simple subtraction to get the current day's PnL only.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              So I found out today. That the consecutive losers stop didnt work correctly. Can someone please guide me in the right direction. I want to try to have the system stop if it takes two losers.

              Comment


                #8
                gooph, you would then need to custom code in the approach presented in this sample - http://www.ninjatrader-support2.com/...ad.php?t=19289
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  This did it for me...
                  Thank you...

                  {

                  // At the start of a new session
                  if (Bars.FirstBarOfSession)
                  {
                  // Store the strategy's prior cumulated realized profit and number of trades
                  priorTradesCount = Performance.RealtimeTrades.Count;
                  priorTradesCumProfit = Performance.RealtimeTrades.TradesPerformance.Curre ncy.CumProfit;

                  /* NOTE: Using .AllTrades will include both historical virtual trades as well as real-time trades.
                  If you want to only count profits from real-time trades please use .RealtimeTrades. */
                  }

                  /* Prevents further trading if the current session's realized profit exceeds $1000 or if realized losses exceed $250.
                  Also prevent trading if 10 trades have already been made in this session. */
                  if (Performance.RealtimeTrades.TradesPerformance.Curr ency.CumProfit - priorTradesCumProfit >= 1000
                  || Performance.RealtimeTrades.TradesPerformance.Curre ncy.CumProfit - priorTradesCumProfit <= -200
                  || Performance.RealtimeTrades.Count - priorTradesCount > 10)
                  {
                  /* TIP FOR EXPERIENCED CODERS: This only prevents trade logic in the context of the OnBarUpdate() method. If you are utilizing
                  other methods like OnOrderUpdate() or OnMarketData() you will need to insert this code segment there as well. */

                  // Returns out of the OnBarUpdate() method. This prevents any further evaluation of trade logic in the OnBarUpdate() method.
                  return;
                  }

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by ScottW, Today, 06:09 PM
                  1 response
                  4 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by ScottWalsh, Today, 06:52 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post ScottWalsh  
                  Started by ftsc2022, 10-25-2022, 12:03 PM
                  5 responses
                  256 views
                  0 likes
                  Last Post KeyonMatthews  
                  Started by Board game geek, 10-29-2023, 12:00 PM
                  14 responses
                  244 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by Waxavi, 04-19-2024, 02:10 AM
                  4 responses
                  56 views
                  0 likes
                  Last Post sonia0101  
                  Working...
                  X