Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

One trade per day?

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

    One trade per day?

    Ok I am trying to use the strategy wizard to set up conditions to enter and exit a trade. Once the trade is entered and exited, I do not want to trigger another entry until the next day.

    So just one trade a day.

    How would i do this with the wizard?

    #2
    Someone will follow up on this tomorrow.
    RayNinjaTrader Customer Service

    Comment


      #3
      Hi Laserdan,

      What you want to do can be done via the use of a User Variable. Add an entry condition that says Variable0 == 0. When you place a trade you want to then add an action that makes Variable0 = 1. Now when it tries to reevaluate your entry and make another trade it will not be possible because Variable0 is equal to 1 and not 0.

      To reset this the next day you want to make a new set of conditions & actions. In this set you want a condition that checks the indicator CurrentDayOHL(). You want to check the Open plot's value of 1 bar ago versus its value on 0 bars ago. When they are not equal that means they have different open values which would indicate a new day. In your action here you want to set Variable0 = 0 which resets your original condition and allows for trading again.
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        This was very helpful. Thank you!

        For all that use it, be careful, if you have 2 days that open back to back with the same price it will fail.

        Comment


          #5
          Adding additional conditions that check the CurrentDayOHL()'s High and Low should reduce the chances of failure.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Seems like you could use the ToDay() method to determine a change in days. Something like the following should indicate a change to the next day:

            if (ToDay(Time[0]) != ToDay(Time[1])) /* you are on a new day */

            This could easily be inserted into the strategy after unlocking the strategy code. Sometimes manually adding some code is actually easier than using the wizard. The drawback is that you can't then use the wizard for additional strategy modifications.

            Alternatively, if someone wants to use the wizard then it seems like you could detect a change in days by using the wizard's condition builder. Use the Time series Bars ago 0 < Time series Bars ago 1. Since the wizard writes the code using the ToTime method, which appears to be based on a 24 hour clock, then when the wizard's Time series 0 value becomes less than the previous bar's Time series value then it should indicate a new day.
            Last edited by higler; 10-22-2008, 11:39 AM.

            Comment


              #7
              great idea..I will try it.

              Thanks

              Comment


                #8
                Originally posted by NinjaTrader_Josh View Post
                Hi Laserdan,

                What you want to do can be done via the use of a User Variable. Add an entry condition that says Variable0 == 0. When you place a trade you want to then add an action that makes Variable0 = 1. Now when it tries to reevaluate your entry and make another trade it will not be possible because Variable0 is equal to 1 and not 0.
                Im not a thread maker, but still have same troubles with these "variables" and my problem is that on 1min chart, my strategy "spam" entryes in each bar as fast as eiter stop-loss/profit triggers from the previous entry condition.

                Here is my code:


                /// <summary>
                /// This method is used to configure the strategy and is called once before any strategy method is called.
                /// </summary>
                protected override void Initialize()
                {
                SetStopLoss("", CalculationMode.Ticks, 4, false);
                SetProfitTarget("", CalculationMode.Ticks, 2);

                CalculateOnBarClose = true;
                }

                /// <summary>
                /// Called on each bar update event (incoming tick)
                /// </summary>
                protected override void OnBarUpdate()
                {
                // Condition set 1
                if (Close[1] < Open[1]
                && Variable0 == 0)
                {
                EnterShortLimit(DefaultQuantity, Close[1], "");
                Variable0 = 1;
                }

                // Condition set 2
                if (Close[1] > Open[1]
                && Variable0 == 0)
                {
                EnterLongLimit(DefaultQuantity, Close[1], "");
                Variable0 = 1;
                }





                In that variant of code, my strategy just dont do any single entryes at all, but if i change/remove "Variables" from it, it starts to spam trades.

                Even after listing that forum on about 50 different threads with different questions about these "variables" i still cant get the point how to settup them correctly.


                I understand English quite nicely, (its nnot my common language) but still all these replyes about "variables" sounds to me like some pieces of a puzzle.

                Is there any way, that instead of another "a-lot-of-words" explanation, you will just post a code for ANY kind of strategy (even most easyest one with 2 entry rule), where these "variables" is implemented in.


                So i just will take a look at a code and will realize the way to do the same (but in my way). Huh?


                Huge thanks again for great support at all
                Last edited by Imbah; 11-03-2008, 09:43 AM.

                Comment


                  #9
                  Imbah,

                  Please post your complete code as an attachment yourself. We can then help you determine where your flag variable is messing up. The likely reason is that you are resetting Variable0 back to 0 constantly which negates the purpose of setting it to Variable0 = 1 in the first place.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Josh View Post
                    Imbah,

                    Please post your complete code as an attachment yourself. We can then help you determine where your flag variable is messing up. The likely reason is that you are resetting Variable0 back to 0 constantly which negates the purpose of setting it to Variable0 = 1 in the first place.
                    Thanks! Here it is.
                    Attached Files

                    Comment


                      #11
                      Imbah,

                      I ran your code on my end and it works fine. Are you sure you are on NT6.5.1000.7? Only one entry is made and either a stop or a target is hit for that trade. Since you never set Variable0 back to 0 it never trades again.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        I am going to try the following to test for a new day...

                        if the high today equals the low today, it is a new day

                        The high shouldnt equal the low for too long until the first tick tommorow.

                        Comment


                          #13
                          You can also use Bars.FirstBarOfSession to check for a new day/session. http://www.ninjatrader-support.com/H...OfSession.html
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            I don't see that in the Wizard, but any way I only use daily dars, so it will always be the first bar of the day, and the only bar of the day.

                            Comment


                              #15
                              In the wizard you will want to use your approach.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by bortz, 11-06-2023, 08:04 AM
                              47 responses
                              1,609 views
                              0 likes
                              Last Post aligator  
                              Started by jaybedreamin, Today, 05:56 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post jaybedreamin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              19 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              16 views
                              0 likes
                              Last Post Javierw.ok  
                              Working...
                              X