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

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 kujista, Today, 06:23 AM
          4 responses
          13 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by traderqz, Yesterday, 09:06 AM
          2 responses
          15 views
          0 likes
          Last Post traderqz  
          Started by traderqz, Today, 12:06 AM
          3 responses
          6 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by RideMe, 04-07-2024, 04:54 PM
          5 responses
          28 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by f.saeidi, Today, 08:13 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X