Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entry restriction

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

    Entry restriction

    HI guys i would appreciate if get a bit of help ..

    I want to restrict my startegy to have only 1 long and 1 short trade per session . my session is time between 10 and 2 pm.

    can i program this on strat analyzer ?

    #2
    amit_rwd,

    As you place in a long trade, set a bool variable to true that prevents future long trades. Do this for shorts as well. When a new session starts, reset the bool to false.

    Untested pseudo-code to give you an idea.
    Code:
    if (Bars.FirstBarOfSession && FirstTickOfBar)
    {
         longTrade = false;
         shortTrade = false;
    }
    
    if (longTrade == false && some other entry conditions)
    {
         EnterLong();
         longTrade = true;
    }
    
    if (shortTrade == false && some entry conditions)
    {
         EnterShort();
         shortTrade = true;
    }
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      cheers Josh

      seems i have got somethings wrong here is what i wrote
      How do i need to declare longtrade in variable section ? so script can recognise longtrade function

      protected override void OnBarUpdate()
      {

      if (Bars.FirstBarOfSession && FirstTickOfBar)
      {
      longTrade = false;
      shortTrade = false;
      } // Condition set 1
      if (ToTime(Time[0]) == ToTime(10, 0, 0))
      {
      Variable0 = MAX(8)[0];
      Variable1 = MIN(8)[0];
      }

      // Condition set 2
      if (longTrade == false && ToTime(Time[0]) >= ToTime(10, 0, 0)
      && ToTime(Time[0]) <= ToTime(14, 0, 0)
      && Close[0] >= Variable0

      {
      EnterLong(DefaultQuantity, "");
      longTrade = true;
      }

      Comment


        #4
        amit_rwd, you would need to add to your Variables section -

        Code:
         
        private bool longTrade;
        private bool shortTrade;
        BertrandNinjaTrader Customer Service

        Comment


          #5
          thx a mill it is working...

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by MidenThur, Today, 12:52 AM
          0 responses
          3 views
          0 likes
          Last Post MidenThur  
          Started by seseoraf, Today, 12:51 AM
          1 response
          5 views
          0 likes
          Last Post charmingishagarg  
          Started by Rosario, Today, 12:50 AM
          0 responses
          3 views
          0 likes
          Last Post Rosario
          by Rosario
           
          Started by kemoyums, Today, 12:38 AM
          0 responses
          2 views
          0 likes
          Last Post kemoyums  
          Started by MartynBashi, Yesterday, 11:01 PM
          0 responses
          4 views
          0 likes
          Last Post MartynBashi  
          Working...
          X