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

Realcode Optimization Help for Custom Indicators Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
shamilton
Posted : Monday, August 23, 2010 8:41:23 AM
Registered User
Joined: 1/25/2005
Posts: 13

Hello,

I have written a couple of realcode indicators.  Is there someone who can have a look and suggest any optimizations.  They are use with streaming data and have conditions attached to them.
The conditions I use are:

1) TradeRange > 98
2) TradeRange < 02
3) VolumeSurge > 3

I combine the conditions into a combo condition and then sort my watchlist on the combo condition by bars since true.   I really only need to know when the conditions are met on the current bar.  I use this with realtime data so I would like it to be as quick as possible.

Any help with this is greatly appreciated.

Thanks,
Shawn


#1 Volume Surge (Intraday): This indicator calculates volume surge. It's a little different though as it calculates the average volume per bar time.  For example if you use 10 MovAvgDays on a 30 minute chart it will (or should ) add up past ten 10am bars to calculate the volume surge for the 10am bar and so on.   I did it this way because there is usually higher volume in the morning and afternoon and I wanted to normalize this.

'# MovAvgDays = UserInput.integer = 10

Dim BarsPerDay As Integer
Dim Count As Integer
Dim VolumeSurge As Single = 0
Dim VolumeAverage As Single = 0

' Calculate BarsPerDay if Intraday
If Me.BarInterval.Days > 0 Then
 ' Daily or higher
 BarsPerDay = 1
Else
 ' Intraday
 BarsPerDay = System.Math.Round(.4999 + 390 / Me.BarInterval.TotalMinutes)
End If

' Calculate VolumeSurge 
For Count = 1 To (MovAvgDays * BarsPerDay) Step BarsPerDay
 VolumeAverage += Volume.Value(Count - 1)
Next Count
VolumeAverage = VolumeAverage / MovAvgDays
VolumeSurge = Volume.Value / VolumeAverage
 
Plot = VolumeSurge



#2 Trade Range (Intraday): Most of this code is from another post and was written by Bruce L - see post S.F 5.0 scan please .  This indicator can be used on a intraday chart to correctly calculate the percent trade range for the current day.

Static DayLow As Single
Static DayHigh As Single
Static Valid As Boolean
If isFirstBar Then
 DayLow = Single.NaN
 DayHigh = Single.NaN
 Valid = False
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
 DayLow = Price.Low
 DayHigh = Price.High
 Valid = True
End If
DayLow = System.Math.Min(DayLow, Price.Low)
DayHigh = System.Math.Max(DayHigh, Price.High)
If Valid = True Then
 If DayHigh > DayLow Then
  Plot = 100 * (Price.Last - DayLow) / (DayHigh - DayLow)
 End If
Else
 SetIndexInvalid
End If
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.