Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

loop to find specific time bar

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

    #16
    Kate,

    Following post 15 i discovered that you can input index Bars.getClose

    Code:
     if(CurrentBar < 391) return;
    
    
    
    double closePrice16 = Bars.GetClose(389);
    double closePrice9 = Bars.GetClose(390);
    
    double difCP = closePrice16 - closePrice9;
    
    
    double closePrice160 = Bars.GetClose(779);
    double closePrice90 = Bars.GetClose(780);
    
    double difCP0 = closePrice160 - closePrice90;
    
    Print("dif"+difCP);
    Print("difT"+difCP0);
    Print("CP"+closePrice16);
    Print("CP"+closePrice9);
    
    double candle = Close[0] + difCP;
    
    Print("Can"+candle);
    Is there a way to return the result of double difCP0 in candle starting at 781?

    There's always this but you lose the first transformation and its not antomatic.

    Code:
     if(CurrentBar < 391) return;
    
    double closePrice16 = Bars.GetClose(389);
    double closePrice9 = Bars.GetClose(390);
    
    double difCP = closePrice16 - closePrice9;
    
    
    Print("dif"+difCP);
    
    Print("CP"+closePrice16);
    Print("CP"+closePrice9);
    
    double candle = Close[0] + difCP;
    
    Print("Can"+candle);
    
    if(CurrentBar < 781) return;
    
    double closePrice160 = Bars.GetClose(779);
    double closePrice90 = Bars.GetClose(780);
    
    double difCP0 = closePrice160 - closePrice90;
    Print("difT"+difCP0);
    
    double candlex = Close[0] + difCP0;
    
    Print("CDLX"+candlex);
    
    double candleY = Close[0] + candlex;
    
    Value[0] = candlex;

    TY

    Comment


      #17
      Hello frankduc,

      Thank you for your reply.

      Your code keeps changing each time you post and seems to be doing something different than your previous code. Can you please clarify if you're still trying to keep a running total of the differences and offset by whatever the running total is? I am confused as to the goal.

      Thanks in advance; I look forward to assisting you further.

      Comment


        #18
        Hello Kate,

        If you read post 15 its still the same goal, i am just trying to suggest a way to achieve it. But none of my attemps are working.

        Eliminate the gap between the end of the first day and the beginning of the second day, than eliminate the gap between the end of new data of the second day and the beginning of the third day, and it goes on.

        I have done it with the first two days, now i need to do it with the rest of remaining days in the chart.

        TY
        Attached Files
        Last edited by frankduc; 02-03-2021, 07:59 AM.

        Comment


          #19
          Hello frankduc,

          As a heads up, our Script Support staff is not able to assist with custom logic or calculations.

          I'm trying to find your exact current question.

          "How do we use Time by bar without the hours?"

          I'm not certain that I am understanding this question. Are you asking how to get a specific bar without knowing the time of that bar?

          "Is there a way to return the result of double difCP0 in candle starting at 781?"

          A double is a single value. Are you asking how to save values for every bar on the chart?
          This would be a Series<double> object and not a double.

          Below is a link to the help guide on Series<T> objects.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          579 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X