Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help With Strategy

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

    #31
    Not sure I follow. You don't actually need to create an array just to be able to inject that into your nom/dem calculations.

    You already have the basis down for all the historical dates for nom/dem. So all you need to do now is before you do any of the historical dates, you want to do the current date first.

    Assuming BarsInProgress == 0 is a 1min series and session closes at 2PM (aka 140000).
    Code:
    if (BarsInProgress == 0)
    {
         if (ToTime(Time[0]) == 135900)
         {
              ArrayList nom = new ArrayList();
              nom.Add(Close[0] - Math.Min(MIN(Lows[dailyBars], k-1)[0], CurrentDayOHL().CurrentLow[0]));
              x=0;
              while (x < d)
              {
                   nom.Add(Closes[dailyBars][x] - MIN(Lows[dailyBars],k)[x]);
                   x++;
              }
    
              // denoms
              ArrayList den = new ArrayList();
              den.Add(Math.Max(MAX(Highs[dailyBars], k-1)[0], CurrentDayOHL().CurrentHigh[0]) - Math.Min(MIN(Lows[dailyBars], k-1)[0], CurrentDayOHL().CurrentLow[0]));
              x=0;
              while (x < d)
              {
                   den.Add(MAX(Highs[dailyBars],k)[x] -  MIN(Lows[dailyBars],k)[x]);
                   x++;
              }
              ...
              ...
         }
    }
    Now you will have to play around with the idea here as I have not tested it, but it should give you a framework as to where to go. Above shows an example of adding the current day's info into the first [0] index and then adding all the historical stuff after it so you can access the ArrayList in proper chronological order.
    Josh P.NinjaTrader Customer Service

    Comment


      #32
      Hi Josh,

      Check out this function (thanks btw, this is much simpler):

      Code:
      double getPercentKUpToMinuteDaily(int d, int k, int smooth)
      		{
      			
      		int x=0;
      
      		ArrayList nom = new ArrayList();
      		nom.Add(Close[0] - Math.Min(MIN(Lows[dailyBars], k-1)[0], CurrentDayOHL().CurrentLow[0]));
      		x=0;
      		while (x < k-1)
      		{
      			nom.Add(Closes[dailyBars][x] - MIN(Lows[dailyBars],k-1)[x]);
      			x++;
      		}
      
      		// denoms
      		ArrayList den = new ArrayList();
      		den.Add(Math.Max(MAX(Highs[dailyBars], k-1)[0], CurrentDayOHL().CurrentHigh[0] - Math.Min(MIN(Lows[dailyBars], k-1)[0], CurrentDayOHL().CurrentLow[0])));
      		x=0;
      		while (x < k-1)
      		{
      			den.Add(MAX(Highs[dailyBars],k-1)[x] -  MIN(Lows[dailyBars],k-1)[x]);
      			x++;
      		}
      
      		// nom sum
      		double nomSum=0;
      		for (int i=0; i<smooth; i++)
      		{
      			nomSum += (double)nom[i];
      		}
      		
      		// den sum
      		double denSum=0;
      		for (int i=0; i<smooth; i++)
      		{
      			denSum += (double)den[i];
      		}
      		
      		nomSum = nomSum.Compare(0, 0.000000000001) == 0 ? 0 : nomSum;
      		denSum = denSum.Compare(0, 0.000000000001) == 0 ? 0 : denSum;
      			
      
      		return (Math.Min(100, 100 * nomSum / denSum));
      							
      		}

      Getting results like this:

      Code:
      2/2/2011 1:59:00 PM      Predicted K: 5.47550432276656
      2/2/2011 2:00:00 PM Actual Close K: 71.2962962962962
       
      2/3/2011 1:59:00 PM      Predicted K: 7.06560922855082
      2/3/2011 2:00:00 PM Actual Close K: 84.4827586206897
       
      2/4/2011 1:59:00 PM      Predicted K: 5.75125808770669
      2/4/2011 2:00:00 PM Actual Close K: 80.8695652173914
       
      2/7/2011 1:59:00 PM      Predicted K: 5.52367288378767
      2/7/2011 2:00:00 PM Actual Close K: 80.5309734513275
       
      2/8/2011 1:59:00 PM      Predicted K: 6.22763063707946
      2/8/2011 2:00:00 PM Actual Close K: 79.2792792792794
       
      2/9/2011 1:59:00 PM      Predicted K: 7.21868365180468
      2/9/2011 2:00:00 PM Actual Close K: 87.2881355932205
       
      2/10/2011 1:59:00 PM      Predicted K: 5.42082738944365
      2/10/2011 2:00:00 PM Actual Close K: 89.7196261682245
       
      2/11/2011 1:59:00 PM      Predicted K: 3.61532899493853
      2/11/2011 2:00:00 PM Actual Close K: 78.4090909090911
       
      2/14/2011 1:59:00 PM      Predicted K: 2.25454545454545
      2/14/2011 2:00:00 PM Actual Close K: 65.5737704918035

      Comment


        #33
        You'll want to recopy my code from earlier. I fixed some typos and issues with parenthesis. Gets confusing with so many of them when just typing into a forum post without using a code editor.

        Please also note that your values will NOT match your "Actual" prints because your actual prints would not be the latest Stochastics value since it has not processed the current day bar yet. The way you want to check the values here is to get your print out for calculated values and compare them versus running the Stochastics indicator separately on a daily chart with CalculateOnBarClose = false. The values should be very close, but not necessarily identical either. Remember, our technique for calculating it is to rely on a value that is not exactly the close of the current day, but a value very close to it. You will get a ballpark value calculated out.
        Josh P.NinjaTrader Customer Service

        Comment


          #34
          Awesome, great work Josh, check it out:

          Code:
          2/2/2011 1:59:00 PM      Predicted K: 70.3703703703703
          2/2/2011 2:00:00 PM Actual Close K: 71.2962962962962
           
          2/3/2011 1:59:00 PM      Predicted K: 85.3448275862069
          2/3/2011 2:00:00 PM Actual Close K: 84.4827586206897
           
          2/4/2011 1:59:00 PM      Predicted K: 81.7391304347827
          2/4/2011 2:00:00 PM Actual Close K: 80.8695652173914
           
          2/7/2011 1:59:00 PM      Predicted K: 80.5309734513275
          2/7/2011 2:00:00 PM Actual Close K: 80.5309734513275
           
          2/8/2011 1:59:00 PM      Predicted K: 79.2792792792794
          2/8/2011 2:00:00 PM Actual Close K: 79.2792792792794
           
          2/9/2011 1:59:00 PM      Predicted K: 86.4406779661018
          2/9/2011 2:00:00 PM Actual Close K: 87.2881355932205
           
          2/10/2011 1:59:00 PM      Predicted K: 88.7850467289722
          2/10/2011 2:00:00 PM Actual Close K: 89.7196261682245
           
          2/11/2011 1:59:00 PM      Predicted K: 78.4090909090911
          2/11/2011 2:00:00 PM Actual Close K: 78.4090909090911
           
          2/14/2011 1:59:00 PM      Predicted K: 63.9344262295084
          2/14/2011 2:00:00 PM Actual Close K: 65.5737704918035
           
          2/15/2011 1:59:00 PM      Predicted K: 70.0000000000001
          2/15/2011 2:00:00 PM Actual Close K: 68.3333333333335
           
          2/16/2011 1:59:00 PM      Predicted K: 76.923076923077
          2/16/2011 2:00:00 PM Actual Close K: 76.923076923077
           
          2/17/2011 1:59:00 PM      Predicted K: 85.1851851851852
          2/17/2011 2:00:00 PM Actual Close K: 86.4197530864198
           
          2/18/2011 1:59:00 PM      Predicted K: 85.7142857142858
          2/18/2011 2:00:00 PM Actual Close K: 85.7142857142858
           
          2/22/2011 1:59:00 PM      Predicted K: 86.1386138613863
          2/22/2011 2:00:00 PM Actual Close K: 84.1584158415843
           
          2/23/2011 1:59:00 PM      Predicted K: 81.3559322033899
          2/23/2011 2:00:00 PM Actual Close K: 81.3559322033899
           
          2/24/2011 1:59:00 PM      Predicted K: 71.7741935483871
          2/24/2011 2:00:00 PM Actual Close K: 72.5806451612903
           
          2/25/2011 1:59:00 PM      Predicted K: 73.3333333333333
          2/25/2011 2:00:00 PM Actual Close K: 73.3333333333333
           
          2/28/2011 1:59:00 PM      Predicted K: 69.0721649484537
          2/28/2011 2:00:00 PM Actual Close K: 68.041237113402
           
          3/1/2011 1:59:00 PM      Predicted K: 86.1386138613861
          3/1/2011 2:00:00 PM Actual Close K: 86.2745098039215

          Thank you again for all the help!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          647 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X