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

Looking for mechanism to scale down size based on performance

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

    Looking for mechanism to scale down size based on performance

    I am looking for, on a daily basis, a mechanism within a strategy to realize a certain type of trade is failing, and scale down entry size or even abstain from entry until a new session commences.

    ie... a long strategy is failing because markets are selling off aggressively, and every dip buy fails. As the strategy fails perhaps twice or three times in a row, make subsequent entries have less size.

    Any way to do this?

    I see this is a cumprofit variable that I could use, but that won't be very effective if I had one home run in the beginning of the day, and three smaller failures after.

    Basically, I'd like to build damage control into the strategy.

    [ie lets say my strategy is countertrending, and the day is overall a trending day...]


    Also: I've noticed the BarsSinceEntry() and BarsSinceExit() values do not work on the basis of a less than qualifier ie if the running strategy has not yet initiated a position, since by default Barssinceexit = -1 and barssinceentry could equal 0:

    if (BarsSinceEntry())
    EnterLong();

    My thoughts are I could use the BarsSinceExit or Entry statement as a way to exclude reattempting a failed trade within a certain timeframe. The problem is that if I put this qualifer in front of my main logic, I will never trigger an order, since by default they are less than 1 or 0 already. (i figure 10-20 3 min bars could be enough to exclude too soon re-entry).

    Any way to make these variables have defaults of above 100 if the strategy had never been invoked?
    Last edited by scriabinop23; 05-15-2007, 10:11 PM.

    #2
    No this would not be possible. What you could do is skip through the performance object and review actual trades. I apologize in advance, this section is no where near complete in documentation.



    Likely this is not of any help right now but I will provide some sample code in the next few weeks in this area.
    RayNinjaTrader Customer Service

    Comment


      #3
      is (Performance.AllTrades.Performance.MaxConsecLoser) /etc... (and all the other performance #s) indicative of all trades since the strategy started running in the control center (upon hitting start) its session, or complete history in the DB? or just the day's performance?


      Also, any ideas on the BarsSinceEntry() fields? am i stuck and correct in my observation?

      Comment


        #4
        Its all trades since the strategy started running including historical and real-time trades.

        Regarding the BarssinceEntry(), I don't fully comprehend what you want to do there.
        RayNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Ray View Post
          Its all trades since the strategy started running including historical and real-time trades.

          Regarding the BarssinceEntry(), I don't fully comprehend what you want to do there.

          meaning if i started running the strategy on 5/10-5/11, then stopped it and restarted the program and reran at 5/15-5/16, it would show me data all the way from 5/10?

          On barssinceentry the goal is to say

          if barrsinceentry < 10 Do not re enter any new trades. I want to put this qualifier before all of my trade triggers.

          BUT if the strategy is newly commenced, the variable defaults to a value lower than 10 already (since it hasn't entered yet) [like 0], it won't work.

          Comment


            #6
            Thanks for clarification.

            When you run a strategy, it will show you trade history against the amount of historical data you have on your chart. So if your chart has 5 days of data, it will show virtual historical strategy history against those 5 days. Had you run the strategy in real-time during this five day period and stopped it, the real-time history is NOT included as part of the virtual historical calculation when running the strategy again.

            On the second issue, why not do something like this.

            Code:
            if (BarsSinceEntry() > 10 && BarsSinceEntry() != -1)
                // Take the trade
            RayNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Ray View Post
              Thanks for clarification.
              On the second issue, why not do something like this.

              Code:
              if (BarsSinceEntry() > 10 && BarsSinceEntry() != -1)
                  // Take the trade
              actually i need an or statement..

              if (BarsSinceExit() > 10 or BarsSinceExit() = -1)


              whats the or statement for or? thanks (instead of &&)
              Last edited by scriabinop23; 05-16-2007, 11:46 AM.

              Comment


                #8
                Originally posted by scriabinop23 View Post
                actually i need an or statement..

                if (BarsSinceExit() > 10 or BarsSinceExit() = -1)


                whats the or statement for or? thanks (instead of &&)

                Found it.. || looks like it.
                but both that and | result in Operator '|' cannot be applied to operands of type 'bool' and 'int' Strategy\LongHNG.cs ...

                alternative operator?
                Last edited by scriabinop23; 05-16-2007, 12:17 PM.

                Comment


                  #9
                  Please take a look here - http://www.ninjatrader-support.com/H...sicSyntax.html
                  RayNinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Ray View Post

                    Now I can't make sense of why || doesn't work.
                    statement is as follows:

                    If BarsSinceExit() > 3 || BarsSinceExit() = -1
                    {...

                    My intention: if one of the above is true then execute.
                    Says can't apply to bool or int operands.

                    Comment


                      #11
                      Should be

                      Code:
                      if (BarsSinceExit() > 3 || BarsSinceExit() == -1)
                          // Do something
                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Ray View Post
                        Should be

                        Code:
                        if (BarsSinceExit() > 3 || BarsSinceExit() == -1)
                            // Do something

                        thanks a lot!!

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by maybeimnotrader, Yesterday, 05:46 PM
                        4 responses
                        23 views
                        0 likes
                        Last Post maybeimnotrader  
                        Started by frankthearm, Today, 09:08 AM
                        6 responses
                        24 views
                        0 likes
                        Last Post frankthearm  
                        Started by adeelshahzad, Today, 03:54 AM
                        5 responses
                        33 views
                        0 likes
                        Last Post NinjaTrader_BrandonH  
                        Started by stafe, 04-15-2024, 08:34 PM
                        7 responses
                        32 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by merzo, 06-25-2023, 02:19 AM
                        10 responses
                        823 views
                        1 like
                        Last Post NinjaTrader_ChristopherJ  
                        Working...
                        X