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

intraday high and low code Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
thevinman
Posted : Wednesday, July 7, 2010 6:14:00 AM
Registered User
Joined: 2/22/2010
Posts: 187
Dear Support, 

I have used the code below to plot a horizontal line for the intraday high of today. I got it from the forum (thanks), but I cant find the one for the low of the day. Do I just change the word 'high' for 'low' in the code to get the intraday low? Help is appreciated. 

Thanks thevinman
 
'Current Intraday High
Static High As Single
If isFirstBar Then High = Price.High
If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then High = Price.High
High = System.Math.Max(High, Price.High)
Plot = High
StockGuy
Posted : Wednesday, July 7, 2010 8:16:51 AM

Administration

Joined: 9/30/2004
Posts: 9,187
Yes, try changing "high" to "low" everywhere in the code. 
Bruce_L
Posted : Wednesday, July 7, 2010 8:24:23 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
thevinman,
You'll also need to change System.Math.Max to System.Math.Min.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thevinman
Posted : Wednesday, July 7, 2010 10:39:58 AM
Registered User
Joined: 2/22/2010
Posts: 187
Thanks again guys!

the code for the low of the day is:

'Current Intraday Low
Static Low As Single
If isFirstBar Then Low = Price.Low
If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then Low = Price.Low
Low = System.Math.Min(Low, Price.Low)
Plot = Low

Is it also possible to plot yesterdays low by using this code? By saying price.low(1) instead of price.low?

Kind regards,

thevinman
Bruce_L
Posted : Wednesday, July 7, 2010 10:49:11 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
No, Price.Low(1) is just the Low of the previous Bar. You need to manually calculate and store the Low of the Previous Day if you are using an intraday Bar Interval.

Static Low(1) As Single
If isFirstBar Then
    Low(0) = Single.NaN
    Low(1) = Single.NaN
End If
If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
    Low(1) = Low(0)
    Low(0) = Price.Low
End If
Low(0) = System.Math.Min(Low(0), Price.Low)
Plot = Low(1)

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thevinman
Posted : Wednesday, July 7, 2010 11:22:38 AM
Registered User
Joined: 2/22/2010
Posts: 187
Dear Bruce,

Thank you for the codes. This is awsome.

Yesterdays high and low code is interesting for SF5 to put into there indicator list. Yesterdays high and low are used by traders as intraday support and resitances levels.
 
Again thank you for helping me out.

Cheers thevinman
thevinman
Posted : Wednesday, July 7, 2010 11:24:14 AM
Registered User
Joined: 2/22/2010
Posts: 187
This is the code for yesterdays high:

Static High(1) As Single
If isFirstBar Then
 High(0) = Single.NaN
 High(1) = Single.NaN
End If
If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
 High(1) = High(0)
 High(0) = Price.High
End If
High(0) = System.Math.Max(High(0), Price.High)
Plot = High(1)

Save it as an indicator and overlay it in the intraday price chart.

cheers thevinman
Bruce_L
Posted : Wednesday, July 7, 2010 11:24:23 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thevinman
Posted : Wednesday, July 7, 2010 12:42:41 PM
Registered User
Joined: 2/22/2010
Posts: 187
Dear Bruce,

I have plotted the todays intraday high in the price chart, but the line is touching all the previous bars that set the todays high. I would just like to have one horizontal line that would represent the high of the day. So everytime it makes a new high the horizontal line goes up also. Could I use the code for yesterdays high to create one static horizontal line?

Kind regards,

thevinman
Bruce_L
Posted : Wednesday, July 7, 2010 12:52:38 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
No, you can't use the Code for yesterday's High. It uses exactly the same algorithm except that it takes the current High or Low and stores it as yesterday's High or Low whenever the day changes. If you were to Plot High(0) or Low(0) instead of High(1) or Low(1) it would look exactly the same.

To get the High or Low of the current day to Plot for the entire Day (instead of when that High or Low is hit as you are doing now), you would need to determine the value and then reloop through the day to Plot the value. The Horizontal Pointers topic has examples of this.


-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.