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 Lance El Camino, Today, 04:14 PM
          1 response
          13 views
          0 likes
          Last Post s.kinra
          by s.kinra
           
          Started by jtrading82, Today, 04:56 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Started by dmking, Today, 06:00 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_EricB  
          Started by WHICKED, Today, 03:23 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by demarcog, Today, 02:24 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Kate  
          Working...
          X