In the scanner you can select 52 week high and low. How can I use this value in a indicator. Which reserved word do I use?
I noticed the high52wk and low52wk in the pl editor but those seem not to work in a indicator.
52 week high and 52 week low [SOLVED]
- Andrew MultiCharts
- Posts: 1587
- Joined: 11 Oct 2011
- Has thanked: 931 times
- Been thanked: 559 times
Re: 52 week high and 52 week low [SOLVED]
Hello Evdl,
The values are provided by data source (not all of the supported ones do this). Unfortunately there is no way you can return the same values in EasyLanguage/PowerLanguage script.
The values are provided by data source (not all of the supported ones do this). Unfortunately there is no way you can return the same values in EasyLanguage/PowerLanguage script.
Re: 52 week high and 52 week low
It should be possible to calculate these values in your code. One way would be to attach a Data2 series for the same instrument, but with weekly bars. You can then get the highest and lowest values for the last 52 weeks through something like the following (not tested):
value1 = Highest(High of Data2, 52);
value2 = Lowest(Low of Data2, 52);
value1 = Highest(High of Data2, 52);
value2 = Lowest(Low of Data2, 52);
-
- Posts: 401
- Joined: 19 Jan 2011
- Location: Netherlands
- Has thanked: 85 times
- Been thanked: 124 times
Re: 52 week high and 52 week low
Thank you Xyzzy,
I made an indicator to calculate the 52 week high and low (you can use this without data2).
I made an indicator to calculate the 52 week high and low (you can use this without data2).
Code: Select all
// INDICATOR 52 Week High/Low:
// This indicator calculates 52 weekly high and low of a symbol.
Array:
High52wk_array[52] (0),
Low52wk_array[52] (0);
var:
Dateformat_week(""),
High52wk_value(0),
Low52wk_value(99999),
High_of_week(0),
Low_of_week(99999);
// End declarations
Dateformat_week = formatdate("dd-MM-yyyy", eldatetodatetime(date));
If DayOfWeek( Date ) = 5 and (sessionlastbar = true) then begin
High_of_week = h; // resets the variable at the end of last bar on every friday
Low_of_week = L; // resets the variable at the end of last bar on every friday
end
else
begin // accumulates high/low data for the week
if h > High_of_week then High_of_week = h;
if L < Low_of_week then Low_of_week = L;
// post data to array
High52wk_array[52] = High_of_week[1];
Low52wk_array[52]= Low_of_week[1];
High52wk_value = high52wk_array[52];
Low52wk_value = low52wk_array[52];
High52wk_value = highest(high52wk_value,52);
Low52wk_value = lowest(low52wk_value,52);
//Print(dateformat_week," high ", high52wk_value," low ", low52wk_value);
plot1(High52wk_value);
plot2(Low52wk_value);
End;
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
Re: 52 week high and 52 week low
re: your codeThank you Xyzzy,
I made an indicator to calculate the 52 week high and low (you can use this without data2).
...
Code: Select all
If DayOfWeek( Date ) = 5 and (sessionlastbar = true) then begin
-
- Posts: 401
- Joined: 19 Jan 2011
- Location: Netherlands
- Has thanked: 85 times
- Been thanked: 124 times
Re: 52 week high and 52 week low
Yes, that could be a problem if the high or low of the 52 weeks is on that particular day. Although the change of that happening exact on that day is small, but nevertheless, you would have wrong values.
Probably better is this
Probably better is this
Code: Select all
If DayOfWeek( Date ) <> dayofweek(date[1]) and (sessionlastbar = true) then begin
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
Re: 52 week high and 52 week low
What if Thursday is a holiday (eg. Thanksgiving)?Yes, that could be a problem if the high or low of the 52 weeks is on that particular day. Although the change of that happening exact on that day is small, but nevertheless, you would have wrong values.
Probably better is thisCode: Select all
If DayOfWeek( Date ) <> dayofweek(date[1]) and (sessionlastbar = true) then begin
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
Re: 52 week high and 52 week low
you can try this:
ps. unless the market closed for more than 5 days.
Code: Select all
If DayOfWeek( Date ) < dayofweek( date[1] ) ...
ps. unless the market closed for more than 5 days.
Re: 52 week high and 52 week low
For what it's worth, there's also a discussion here about how to build a similar indicator -- one that calculates the high/low of a set time period.
http://markplex.com/free-tutorials/tuto ... art-times/
It deals with similar issues, such as what happens if there isn't a bar for the specified "end time."
http://markplex.com/free-tutorials/tuto ... art-times/
It deals with similar issues, such as what happens if there isn't a bar for the specified "end time."
-
- Posts: 401
- Joined: 19 Jan 2011
- Location: Netherlands
- Has thanked: 85 times
- Been thanked: 124 times
Re: 52 week high and 52 week low
That is the best option TJ. I will use that.you can try this:
Code:
If DayOfWeek( Date ) < dayofweek( date[1] ) ...
ps. unless the market closed for more than 5 days.