Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

How do you limit Real Code calculation to single trading day only Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
Power9999
Posted : Wednesday, May 6, 2009 7:12:26 PM
Registered User
Joined: 10/7/2004
Posts: 12
I was told that I needed to include the 'Cumulative directive in my Real code so that the numbers reported in the Main watchlist would match the numbers computed and displayed in the chart.  My understanding of the Cumulative indicator is that it computes with respect to all of the bars provided in the data manager.  Because I have Real Code indicators that require 5000 bars of intraday data, I have intraday bars set to 5000.

However, the (other) calculation that requires the 'Cumulative directive only uses the bars since the beginning of the day.  Is there a way to limit the calculation to only those bars since the beginning of the trading day.

The code I use to determine the begining of the day is:
If price.datevalue.dayofyear <> price.datevalue(1).dayof year Then ....

How do I modify this code so that Real code only processes data for the current trading day?
Bruce_L
Posted : Wednesday, May 13, 2009 3:55:06 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
One possibility would be to not use the '# Cumulative line and just not start plotting Values until at least one full day of data has passed so the Watchlist Column knows how much data it needs to use. An example of one type of structure that would do this follows:

Static DayCount As Integer
If isFirstBar Then
    DayCount = 0
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
    DayCount += 1
End If
If DayCount >= 2 Then
    'Your RealCode here
Else
    Plot = Single.NaN
End If

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.