Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ignore trade signal after winning trade.

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

    Ignore trade signal after winning trade.

    Hello.
    My strategy place stop loss and profit orders after enter in to position.
    Just regular strategy. But I would like to ignore trading signal after winnig trade.
    Can I have a general idea how to ignore trade singal after winning trade.
    Rgds.
    Czarek.

    #2
    Hello,

    I suggest using this link to track money management information while you trade:


    Then create a bool flag tracking system within your program to track this. This may give you an idea:

    if(...there was a profitable trade last, see link above...)
    {
    turn_off_trading = true;
    }

    if(turn_off_trading == false && ...other conditions to trade here....)
    {
    //code to trade here
    turn_off_trading = false;
    }

    Or something like that.
    DenNinjaTrader Customer Service

    Comment


      #3
      Hello.
      Thanks a lot. I will do this way.
      But I have one more problem. I need to save Exit Position price to variable.
      What is the code for exit price??
      For entry price is Position.AvgPrice or execution.Order.AvgFillPrice but what is for exit price??

      Czarek

      Comment


        #4
        You can check the Trade class for this - http://www.ninjatrader-support.com/H...radeClass.html

        Code:
         
        if (Performance.RealtimeTrades.Count > 0) 
          { 
            Trade lastTrade = Performance.RealtimeTrades[0]; 
         
            double lastExit = lastTrade.Exit.Price; 
         
            Print("The last trade's exit is " + lastExit); 
          }
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I am trying to find out the most efficient way to find out if the last trade was profitable or not. I am sure I am doing something wrong.

          1. I put on a trade with say 10 lots.
          2. I take off half at 30 tick loss.
          3. the remaining 10 I take off with a profit of 20 ticks.

          My "trade" was a loser, but it my last 10 trades will show as a winner.

          I setup an array of trades, and then looped through them. And that is working fine. But from what I can tell, I need to group them by order id or something in order to find out if the "trade" was profitable and not the last 10 lots.

          1. Should I use order id and if so, what is the best way to get that info and use it? (just direction. Don't need free help).

          2. Should I set a variable which counts how many lots are going on and off and then use that value to setup my array? Thus if 10 lots are on board, and my tradecounter variable is 10, then after it reaches zero I loop through the trades and get the cumulative value of the total profit/loss for that "trade".

          My first thought is there is a way to do this easier than to write a method. But I thought I would ask before I over-thought this too much.

          Thanks,

          UPDATE:
          Is this what I use?

          GetTrades() Method
          Definition
          Returns a TradeCollection object representing all trades that make up the specified position.


          Method Return Value
          An TradeCollection object.


          Syntax
          <TradeCollection>.GetTrades(string instrument, string entrySignalName, int instance)

          Originally posted by NinjaTrader_Bertrand View Post
          You can check the Trade class for this - http://www.ninjatrader-support.com/H...radeClass.html

          Code:
           
          if (Performance.RealtimeTrades.Count > 0) 
            { 
              Trade lastTrade = Performance.RealtimeTrades[0]; 
           
              double lastExit = lastTrade.Exit.Price; 
           
              Print("The last trade's exit is " + lastExit); 
            }
          Last edited by r2kTrader; 10-30-2009, 04:53 PM.

          Comment


            #6
            Hello,

            I would get the info from IOrder and compare it to the current price:
            DenNinjaTrader Customer Service

            Comment


              #7
              Ben,

              Thanks for the prompt reply.

              I am not using advanced order handling due to the StopLoss bug and have opted to use Set() with EnterLimits.

              So with that being said, should I then check for:
              Name
              A string representing the name of an order which can be provided by the entry or exit signal name


              in order to see which order is on deck and get its status?


              Thanks,



              Originally posted by NinjaTrader_Ben View Post
              Hello,

              I would get the info from IOrder and compare it to the current price:
              http://www.ninjatrader-support.com/H...V6/IOrder.html

              Comment


                #8
                Hi r2kTrader, I would suggest working with the GetTrades() method to know how many trades your last entry signal was made up of, then use the Trade class to calcuate total Pnl for this - http://www.ninjatrader-support.com/H...radeClass.html
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Bertrand,

                  1. I reported a Help Documentation Error regardingthe following code and it still has not been updated. Just an fyi.:

                  The line should read (GetTrades is missing in the sample line):
                  TradeCollection myTrades = Performance.AllTrades.GetTrade("MSFT", "myEntrySignal", 1);
                  Code:
                  [B]GetTrades() Method[/B]
                  [B][COLOR=#800000]Definition[/COLOR][/B] 
                  Returns a TradeCollection object representing all trades that make up the specified position. 
                   
                   
                  [B][COLOR=#800000]Method Return Value[/COLOR][/B]
                  An TradeCollection object.
                   
                   
                  [B][COLOR=#800000]Syntax[/COLOR][/B] 
                  <TradeCollection>.GetTrades([COLOR=#0000ff]string[/COLOR] [I]instrument[/I], [COLOR=#0000ff]string[/COLOR] [I]entrySignalName[/I], [COLOR=#0000ff]int[/COLOR] [I]instance[/I])
                   
                   
                   
                  [B]Parameters[/B]
                  instrument
                  An instrument name such as "MSFT"
                  entrySignalName
                  The name of your entry signal
                  instance
                  The occurence to check for (1 is the most recent position, 2 is the 2nd most recent position etc...)
                   
                   
                  [B][COLOR=#800000]Examples[/COLOR][/B]
                  [FONT=Courier New][COLOR=#0000ff]TradeCollection[/COLOR] myTrades = Performance.AllTrades("MSFT", "myEntrySignal", 1);[/FONT] 
                  [FONT=Courier New]Print("The last position was comprised of " + myTrades.Count + " trades.");[/FONT]
                  2. What I am looking for is the total profit loss for the entire side of that postion. So if I have 2 entry signals. L1 and L2. I put on L1, it goes against me 10 ticks, I put on L2. I have 2 seperate entryNames, but 1 "position".

                  (By the way, this is where it would be nice to see the source code for GetTrades() and the like, but I suppose I can just overload it as well. I really can't stand Closed Source. It serves the developer but not the community. I can see keeping some thing proprietary when it comes to efficiency, but not for blocking and tackling methods. Boo hoo )

                  Will GetTrades() give me the total for that position. Or will it give me the total for L1 as a "position/trade" and then L2 as well seperately?

                  What I am trying to build is a method that will return to me the total P&L for a given side. So while I am long, and I get in and out (but always with some of the position "on"), it will keep an aggregate total for that position session. So from this perspective, when my strat puts me long, I want to konw if that entire long decision and all trades involved, produced a profit or a loss.

                  One of my thoughts was to create a counter and increment 1 for each trade, and then use LongTrades or whatever to pull the last x number of long trades and then that would represent the entire "trade/position" for that session.

                  So I get in long, I add a lot, then add another, then another, then take one off. I have a total of 3 trade that were long, then I do my loop and get the total result and spit it back.

                  For this purpose, "position" would be the total amount of trades done while on x side of the market.


                  Originally posted by NinjaTrader_Bertrand View Post
                  Hi r2kTrader, I would suggest working with the GetTrades() method to know how many trades your last entry signal was made up of, then use the Trade class to calcuate total Pnl for this - http://www.ninjatrader-support.com/H...radeClass.html

                  Comment


                    #10
                    r2kTrader,

                    1. There will be no documentation changes to 6.5. All documentation efforts are being directed to NT7's docs. Thank you for your vigilance.

                    2. You will get the values on a per trade basis, not as a per position basis. What you want needs to be calculated on your own based off of the individual trade information provided.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Bertrand,

                      How can I be sure that it is specific to the strategy I am running.

                      Example:

                      Same strategy, one on 1m timeframe, another on a 5m time frame.

                      If I use this concept, couldn't it pick up the trades from the other strategy from the main batch of trades using GetTrade?

                      Would I need to create 2 strategies and change the entryNames in each in order to avoid this (not very scalable).

                      Question:

                      To simplify the equation, how do I find out the last trade for the strategy that is making the inquiry? What is the solution.

                      If I have that, then I will just track each trade and do the calc myself, not a biggy. But I would like to know the way to make sure I only get the last trade for the strategy that I am running, independent of the other strats.

                      Thanks again,




                      Originally posted by NinjaTrader_Bertrand View Post
                      Hi r2kTrader, I would suggest working with the GetTrades() method to know how many trades your last entry signal was made up of, then use the Trade class to calcuate total Pnl for this - http://www.ninjatrader-support.com/H...radeClass.html

                      Comment


                        #12
                        r2kTrader, a strategy does not cross communicate to other running strategies, thus the performance / trade class info would retrieve values only relevant to the calling strategy (i.e your 1 min or 5 min instance of it).
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Bertrand,

                          I was very tired yesterday and frustrated.

                          I read the help and meant to come back here and report that it is instantiated at the strategy level and the object information is strategy specific.

                          I'm going with Performance.RealtimeTrades.TradesPerformance.Curre ncy.CumProfit

                          I will store the value upon strategy starting. Then take the current value after my trade and subtract it from the old value and do that for each trade. I will call the method from the onpositionUpdate() dilio upon each instance of getting flat.

                          Sorry for the question. I was tired. It's clearly documented in the help guide.

                          Sincerely,

                          Originally posted by NinjaTrader_Bertrand View Post
                          r2kTrader, a strategy does not cross communicate to other running strategies, thus the performance / trade class info would retrieve values only relevant to the calling strategy (i.e your 1 min or 5 min instance of it).

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by tsantospinto, 04-12-2024, 07:04 PM
                          5 responses
                          67 views
                          0 likes
                          Last Post tsantospinto  
                          Started by cre8able, Today, 03:20 PM
                          0 responses
                          6 views
                          0 likes
                          Last Post cre8able  
                          Started by Fran888, 02-16-2024, 10:48 AM
                          3 responses
                          47 views
                          0 likes
                          Last Post Sam2515
                          by Sam2515
                           
                          Started by martin70, 03-24-2023, 04:58 AM
                          15 responses
                          114 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by The_Sec, Today, 02:29 PM
                          1 response
                          8 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Working...
                          X