Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to tell the strategy if the trade was a win or loss?

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

    How to tell the strategy if the trade was a win or loss?

    The strategy takes up to 2 trades a day because if the 1st trade is a loser I want it to take a 2nd trade. If the 1st trade is a winner I do not want it to take the 2nd trade so I watch it trade and after the targets have been filled stop the strategy.

    I know I can use a bool flag to set it to true/false based on certain criteria.

    So how can I tell if the trade is a winner? My definition of a winner is either a target being filled or one of the stop strategies being activated. There are 2 targets so 2 stop strategies. Once a particular price is hit stop strat 1 will auto break even and stop strat 2 will auto trail.

    Either I need to know when a target is filled or stop is moved to set the bool flag. What is the best way to do that?

    #2
    seeing if targets or stops filled can be done via IOrder and just managing your orders through that...

    Comment


      #3
      Hi m3power, I have a couple of reference samples that I think can help you out.

      Here is a sample for using trade performance statistics for money management.
      Next is the reference page for TradeCollection.
      Lastly, this is the Trade Class--useful for getting individual trade information.

      Let us know if you have any more questions.
      AustinNinjaTrader Customer Service

      Comment


        #4
        I'm trying to integrate it with the sampleatmstrat:

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {

        // At the start of a new session
        if (Bars.FirstBarOfSession)
        {
        // Store the strategy's prior cumulated realized profit and number of trades
        priorTradesCumProfit = Performance.AllTrades.TradesPerformance.Currency.C umProfit;

        /* 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 $1*/
        if (Performance.AllTrades.TradesPerformance.Currency. CumProfit - priorTradesCumProfit >= 1)
        {
        // Returns out of the OnBarUpdate() method. This prevents any further evaluation of trade logic in the OnBarUpdate() method.
        return;
        }

        // Make sure this strategy does not execute against historical data
        if (Historical)
        return;

        Not sure if having 2 places where it says return; will be an issue? I did a market replay and it still took a second trade.
        Last edited by m3power222; 07-07-2009, 11:12 AM.

        Comment


          #5
          M3power, if you're trying to use performance metrics with an ATM strategy, take a look at the ATM profit/loss reference page. Here is another link for if you're interested in unrealized ATM profit/loss.
          AustinNinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Austin View Post
            M3power, if you're trying to use performance metrics with an ATM strategy, take a look at the ATM profit/loss reference page. Here is another link for if you're interested in unrealized ATM profit/loss.
            Would it be easier just to find out if a target is filled or stop moved?

            Comment


              #7
              Originally posted by m3power222 View Post
              Would it be easier just to find out if a target is filled or stop moved?
              It is certainly a possiblity that what you're suggesting here is easier. Reference for getting ATM stop and target orders.
              AustinNinjaTrader Customer Service

              Comment


                #8
                I ended up using this and it appears to work:

                // Prevents a second trade if first trade was profitable
                if (GetAtmStrategyRealizedProfitLoss(atmStrategyId) > 0)
                {
                entrylong = false;
                entryshort = false;

                The question I have is every new day does GetAtmStrategyRealizedProfitLoss look at the current day?

                If not then it won't take the next days trade if it includes the previous days win.

                Comment


                  #9
                  m3power222, I believe this is a daytrading strategy without overnight positions, so it should only reflect the current day in this case.

                  Comment


                    #10
                    Originally posted by NinjaTrader_Bertrand View Post
                    m3power222, I believe this is a daytrading strategy without overnight positions, so it should only reflect the current day in this case.
                    Is there anyone that can verify this as my goal is to leave the strategy on 24x7.

                    There is no way to test on market replays as ver 6.5 can't string the mutiple replay days together.

                    Comment


                      #11
                      M3, GetAtmStrategyRealizedProfitLoss only returns the profit/loss for that particular strategy ID, and each strategy ID holds only one trade. The concept of current day/previous day doesn't really apply.
                      AustinNinjaTrader Customer Service

                      Comment


                        #12
                        Thank you guys.

                        Comment

                        Latest Posts

                        Collapse

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