Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trade one time only after the indicator is true in strategy

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

    #16
    I want to store the value of 10 insideBars,
    when any current price was over one of them, then entry, and cancelled that record in the list and add a new one.

    thx
    Last edited by Auntthree30; 09-03-2016, 01:32 AM.

    Comment


      #17
      Hello,
      You can reassign the doubles value at any time. You do not have to have any process to clear it.
      For example, if you have a double myDouble and set it to equal to the value of Close[0] then on every bar update myDouble will be reassigned to the new value of the close of the current bar.

      double myDouble = 0;

      protected override void OnBarUpdate()
      {
      myDouble = Close[0];
      }
      Cody B.NinjaTrader Customer Service

      Comment


        #18
        how can i using current price for entry?
        let say the UpBb as insideBar, i want to entry if the current price is > High or < Low of the insideBar
        where should i add if (BarsInProgress !=2) return; ?
        inside BarsinProgree == 1 or after that?

        thx a lot

        protected override void OnBarUpdate()
        {
        if (CurrentBars[0] < 1 || CurrentBars[1] < 1 )return;
        if (BarsInProgress == 1);
        {
        iHigh = High[0];
        iLow = Low[0];
        iClose = Close[0];
        iOpen = Open [0];
        double iUpper = Bollinger(2,14).Upper[0];
        double iLower = Bollinger(2,14).Lower[0];
        bool UpBb = (iClose >= iUpper && iOpen > iClose);
        bool DwBb = (iClose <= iLower && iOpen < iClose);

        if(UpBb)
        {
        BarColor = Color.DodgerBlue;
        }
        if(DwBb)
        {
        BarColor = Color.Yellow;
        }

        }

        Comment


          #19
          Hello,
          You can get the current price of the data series by using Close[0]. For more information on Close[] please review the following link: http://ninjatrader.com/support/helpGuides/nt7/close.htm

          In regards to your if(BarsInProgress!=2) return check, I can not make recommendations on where to place this code as we are not consultants or educators, we do have partners that are consultants and educators if you would like information on them please let us know.

          Placing if(BarsInProgress!=2) return; inside of if(BarsInProgress ==1) would cause the code to always return because you are checking within a BarsInProgress that is never 2. If this is the goal you could simplify by just putting return within the if(BarsInProgress ==1) check.
          Cody B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          601 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          347 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          559 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          558 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X