Hello, my first post - glad to be a TS convert!
I am moving over a function called "avgtrueranged(30)" and it is not outputting properly. The function returns the avg. true range of the daily bar (in this case for the past 30 days). There are 4 parts to the function.
Does anyone have a use-able function that will perform this task?
thanks,
ws
Daily Average True range [SOLVED]
-
- Posts: 223
- Joined: 16 Oct 2011
- Has thanked: 66 times
- Been thanked: 20 times
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Daily Average True range
What do you mean by "it is not outputting properly"?Hello, my first post - glad to be a TS convert!
I am moving over a function called "avgtrueranged(30)" and it is not outputting properly. The function returns the avg. true range of the daily bar (in this case for the past 30 days). There are 4 parts to the function.
Does anyone have a use-able function that will perform this task?
thanks,
ws
Can you describe the error?
What are the 4 parts you are referring to?
-
- Posts: 223
- Joined: 16 Oct 2011
- Has thanked: 66 times
- Been thanked: 20 times
Re: Daily Average True range
Thanks for the reply
The output (to a file using print statements) goes into negative numbers, average true range should always be positive of course.
The function I have calls "truehighd","truelowd",and "trueranged" functions.
The .eld file is attached which contains these.
The output (to a file using print statements) goes into negative numbers, average true range should always be positive of course.
The function I have calls "truehighd","truelowd",and "trueranged" functions.
The .eld file is attached which contains these.
- Attachments
-
- 2003923123516_AvgTrueRangeDaily.eld
- avg true range day
- (4.05 KiB) Downloaded 703 times
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Daily Average True range
I do not understand the question you are asking...Thanks for the reply
The output (to a file using print statements) goes into negative numbers, average true range should always be positive of course.
The function I have calls "truehighd","truelowd",and "trueranged" functions.
The .eld file is attached which contains these.
you are saying a function called "avgtrueranged(30)" is giving you negative numbers?
do you have the code that calls this function?
ps. there is an indicator called "Average True Range" that comes with MultiCharts.
Please apply this indicator and see if the chart shows negative value.
-
- Posts: 223
- Joined: 16 Oct 2011
- Has thanked: 66 times
- Been thanked: 20 times
Re: Daily Average True range
The function should provide the value of the average true range of the past 30 DAYS of a DAILY charts on an intraday chart. The code is in an ELD file attached to my last message.
-
- Posts: 223
- Joined: 16 Oct 2011
- Has thanked: 66 times
- Been thanked: 20 times
Re: Daily Average True range
correct, I am getting negative values.
The avg. true range function within MC applied on an intraday chart would provide the average true range of the bars on that intraday chart - not the daily chart.
The avg. true range function within MC applied on an intraday chart would provide the average true range of the bars on that intraday chart - not the daily chart.
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Daily Average True range
You have to check with the original author on how this function works.correct, I am getting negative values.
The avg. true range function within MC applied on an intraday chart would provide the average true range of the bars on that intraday chart - not the daily chart.
-
- Posts: 223
- Joined: 16 Oct 2011
- Has thanked: 66 times
- Been thanked: 20 times
Re: Daily Average True range
Thanks for trying to help, the issue is not the function - which works fine in TS, and I know how it works already.
There is a problem with the conversion into Multicharts.
There is a problem with the conversion into Multicharts.
Re: Daily Average True range
Alternative 1: AvgRangeD(30) range might work for you. If you can live without having gaps included.
Alternative 2: see if this works. within the Function code document AvgTrueRangeD, at the bottom of the code below the last semicolon put:
Edit: I thought I had AvgTrueRangeD working by using Alternative 2 but now it appears not. AvgRangeD does work for me. If you need the function code for AvgRangeD, then let me know.
Alternative 2: see if this works. within the Function code document AvgTrueRangeD, at the bottom of the code below the last semicolon put:
Code: Select all
AvgTrueRangeD = Value1 ;
Last edited by escamillo on 19 Oct 2011, edited 1 time in total.
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Daily Average True range
make a back up copy of your AvgTrueRangeD function,
then give this a try and see if the result matches what you have in TS:
then give this a try and see if the result matches what you have in TS:
Code: Select all
[LegacyColorValue = TRUE];
// Ffunction: AvgTrueRangeD
// Version: beta 0.1 for MultiCharts
inputs:
Length(numericsimple);
var:
dayHi(0),
dayLo(0);
if Length = 0 or Length = 1 then
AvgTrueRangeD = TrueRangeD(Length)
else
begin
if date <> date[1]
then { new day }
{ throw away the first day, and add today }
AvgTrueRangeD = (AvgTrueRangeD[1]
- TrueRangeD(Length)/Length
+ TrueRangeD(0) )/Length
else
begin { same day as last bar }
dayHi = HighD(0);
dayLo = LowD(0);
if dayHi = dayHi[1] and dayLo = dayLo[1] then
{ same day, same day low & day high }
{ reuse whatever was in last bar }
AvgTrueRangeD = AvgTrueRangeD[1]
else
{ same day, but different day low or different day high }
{ throw away today and add today using new data }
AvgTrueRangeD = (AvgTrueRangeD[1]
- TrueRangeD(0)[1]/Length
+ TrueRangeD(0) )/Length
;
end;
end;
-
- Posts: 742
- Joined: 09 Apr 2010
- Location: Texas
- Has thanked: 483 times
- Been thanked: 274 times
- Contact:
Re: Daily Average True range
TJ - in the code above(previous post) you call the "TrueRangeD" function, could you please post that function ?
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Daily Average True range
It is in post #3.TJ - in the code above(previous post) you call the "TrueRangeD" function, could you please post that function ?
Re: Daily Average True range
waveslider, that is what i use for calculation, maybe it works for you too:
Code: Select all
Input:
Modus ( 1 ),
//Modus = 1 : Calculate the ATR including the current date, the ATR drops on the start of the trading
//day. Same calculation as on a daily chart using the standard
//Average True Range function with "Update on every tick" checked
//Modus = 2 : Calculate the ATR over the last ATRLength days excluding today.
//Same calculation as on a daily chart using the standard
//Average True Range function with "Update on every tick" unchecked
ATRLength( 30 );
Variables:
x (0),
AvDailyAtr (0),
Initialized (0);
Array : MyATR [50] (0); //Limit to 50 as OHLCPeriodsAgo used by TrueRangeD /HighD... is
//limited to arr0[ 4, 50 ]( -1 )
once begin
if ATRLength >49 then raiseruntimeerror (" ATRLength needs to be <50 !!!!");
end;
If date <> date[1] then
begin
Initialized = Initialized + 1;
If Bartype < 2 and initialized > ATRLength then
begin
for x = 1 to ATRLength-1
begin
MyATR [x] = TrueRangeD ( x);
end;
end;
end;
if Modus = (1) then MyATR [0] = TrueRangeD ( 0 );
if Modus = (2) then MyATR [0] = TrueRangeD ( ATRLength );
AvDailyAtr = array_sum ( MyATR ,0,ATRLength-1 )/ATRLength;
If initialized > ATRLength then
Plot1(AvDailyAtr ,"Daily ATR");
-
- Posts: 742
- Joined: 09 Apr 2010
- Location: Texas
- Has thanked: 483 times
- Been thanked: 274 times
- Contact:
Re: Daily Average True range
**********************************It is in post #3.TJ - in the code above(previous post) you call the "TrueRangeD" function, could you please post that function ?
** Thanks TJ, I missed that..
-
- Posts: 223
- Joined: 16 Oct 2011
- Has thanked: 66 times
- Been thanked: 20 times
Re: Daily Average True range
Thanks to all of you for your help, I'll update you with my findings. Glad to be away from TS!
-
- Posts: 223
- Joined: 16 Oct 2011
- Has thanked: 66 times
- Been thanked: 20 times
Re: Daily Average True range
SP,
your version works great for me, also like how you can drop out the current day - very convenient.
Thanks to all of you.
your version works great for me, also like how you can drop out the current day - very convenient.
Thanks to all of you.
Re: Daily Average True range
Hi, I've read your discussion on calculating average daily range and have tried getting using the "average" function as follows for the last 10, 20, etc. days:
Average(HighD(1), 30) - Average(LowD(1), 30)
As it turns out, when I print the ouput of the above code, I just get yesterday's daily range, NOT the average range of the last 30 days. Basically the code above gives me the same thing as this: HighD(1) - LowD(1).
Would you please offer a suggestion on the use of a function or strategy for simply getting the average (high minus low) of the last 30 days? I can't imagine that Multicharts doesn't have such a function. You guys had mentioned TrueRangeD and a few others, but the PowerLanguage editor doesn't highlite or recognize those as functions.
Thank you,
Carey
Average(HighD(1), 30) - Average(LowD(1), 30)
As it turns out, when I print the ouput of the above code, I just get yesterday's daily range, NOT the average range of the last 30 days. Basically the code above gives me the same thing as this: HighD(1) - LowD(1).
Would you please offer a suggestion on the use of a function or strategy for simply getting the average (high minus low) of the last 30 days? I can't imagine that Multicharts doesn't have such a function. You guys had mentioned TrueRangeD and a few others, but the PowerLanguage editor doesn't highlite or recognize those as functions.
Thank you,
Carey
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Daily Average True range
instead of using HighD(1) in an intraday chart,Hi, I've read your discussion on calculating average daily range and have tried getting using the "average" function as follows for the last 10, 20, etc. days:
Average(HighD(1), 30) - Average(LowD(1), 30)
As it turns out, when I print the ouput of the above code, I just get yesterday's daily range, NOT the average range of the last 30 days. Basically the code above gives me the same thing as this: HighD(1) - LowD(1).
Would you please offer a suggestion on the use of a function or strategy for simply getting the average (high minus low) of the last 30 days? I can't imagine that Multicharts doesn't have such a function. You guys had mentioned TrueRangeD and a few others, but the PowerLanguage editor doesn't highlite or recognize those as functions.
Thank you,
Carey
you should add a daily chart as data2 and apply average to the high of data2.
Re: Daily Average True range
Hello,
In response to your statement:
"Instead of using HighD(1) in an intraday chart,
you should add a daily chart as data2 and apply average to the high of data2."
Would you please explain what you mean, and how this may be done on MC? A brief example would be super helpful. It seems like MC would be advanced enough to understand daily functions when using an intraday system, no?
Thanks so much for your input.
Carey
In response to your statement:
"Instead of using HighD(1) in an intraday chart,
you should add a daily chart as data2 and apply average to the high of data2."
Would you please explain what you mean, and how this may be done on MC? A brief example would be super helpful. It seems like MC would be advanced enough to understand daily functions when using an intraday system, no?
Thanks so much for your input.
Carey
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Daily Average True range
see post #4Hello,
In response to your statement:
"Instead of using HighD(1) in an intraday chart,
you should add a daily chart as data2 and apply average to the high of data2."
Would you please explain what you mean, and how this may be done on MC? A brief example would be super helpful.... [snip]
Thanks so much for your input.
Carey
viewtopic.php?f=16&t=6929
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Daily Average True range [SOLVED]
MultiCharts analyzes the chart bar-by-bar.Hello,
... It seems like MC would be advanced enough to understand daily functions when using an intraday system, no?
Thanks so much for your input.
Carey
If the chart is a one minute chart, it will analyze the chart one minute at a time.
If the chart is a daily chart, it will analyze the chart one day at a time.
Re: Daily Average True range
Try this:
var0=HighD(1);
var1=LowD(1);
Average(var0,30) - Average(var1,30)
In fact, Average function will use HighD(1)[1], but in MC HighD(1)=HighD(1)[1]=HighD(1)[2]
var0=HighD(1);
var1=LowD(1);
Average(var0,30) - Average(var1,30)
In fact, Average function will use HighD(1)[1], but in MC HighD(1)=HighD(1)[1]=HighD(1)[2]
instead of using HighD(1) in an intraday chart,Hi, I've read your discussion on calculating average daily range and have tried getting using the "average" function as follows for the last 10, 20, etc. days:
Average(HighD(1), 30) - Average(LowD(1), 30)
As it turns out, when I print the ouput of the above code, I just get yesterday's daily range, NOT the average range of the last 30 days. Basically the code above gives me the same thing as this: HighD(1) - LowD(1).
Would you please offer a suggestion on the use of a function or strategy for simply getting the average (high minus low) of the last 30 days? I can't imagine that Multicharts doesn't have such a function. You guys had mentioned TrueRangeD and a few others, but the PowerLanguage editor doesn't highlite or recognize those as functions.
Thank you,
Carey
you should add a daily chart as data2 and apply average to the high of data2.