Low's Average of All Hourly Bars for Each Day -- code help

Questions about MultiCharts and user contributed studies.
nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

Low's Average of All Hourly Bars for Each Day -- code help

Postby nuno-online » 26 Oct 2009

Hi,

in easylanguage, how can i have the low's average of all hourly bars for each day?

With the code below,
i have error "Unknown Function" with Hour(time)

here is the code
If D > D[1] Then Value1 = 1
Else
If Hour( Time ) <> Hour( Time )[1] Then Value1 = Value1 + 1;

Value2 = Average( Low, Value1 );

Plot1( Value2 );
thank you for your help

Nuno

User avatar
piranhaxp
Posts: 241
Joined: 18 Oct 2005
Has thanked: 4 times
Been thanked: 30 times

Postby piranhaxp » 27 Oct 2009

Nuno ... try this. But it's an easy way and it's in 60min intr-day charts only.

Input : P1(High), P2(Low), Show_PrevHALA(1);
Vars : HC(0), LC(0), HA(0), LA(0), PHA(0), PLA(0);
Vars : BarsSinceLastReset(0);



If Bartype < 2 then begin
if IsSess1FirstBar then
BarsSinceLastReset = 0;
HC = 0;
LC = 0;
end;

BarsSinceLastReset = BarsSinceLastReset + 1;

If BarsSinceLastReset = 0 then begin
HC = 0;
LC = 0;
End;

If Date > Date[1] then PHA = HA[1];
If Date > Date[1] then PLA = LA[1];

If Date <> Date[1] then begin
PHA = HA[1];
PLA = LA[1];
End;

If BarsSinceLastReset >= 2 and BarsSinceLastReset > BarsSinceLastReset[1]then begin
HC = HC[1] + P1[1];
LC = LC[1] + P2[1];
HA = HC/BarsSinceLastReset[1];
LA = LC/BarsSinceLastReset[1];
Plot1(HA, "HighAvg", Red);
Plot2(LA, "LowAvg", Blue);
End;

If Show_PrevHALA = 1 then begin
Plot3(PHA, "PrevHA", Magenta);
Plot4(PLA, "PrevLA", Cyan);
End;



Hope this is what you wanted.

Kind regards.

Mike
Attachments
Avg_High_Low_60min.png
Avg_High_Low_60min.png (33.01 KiB) Viewed 539 times

nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

Postby nuno-online » 28 Oct 2009

Mike

thank your for your help

in Multicharts (Version 5.5 Release (Build 2723)) , i have :
------ Compiled with error(s): ------
IsSess1FirstBar is not recognized

User avatar
TJ
Posts: 7158
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 988 times
Been thanked: 2042 times

Postby TJ » 28 Oct 2009

change

IsSess1FirstBar

to

d<>d[1]

User avatar
piranhaxp
Posts: 241
Joined: 18 Oct 2005
Has thanked: 4 times
Been thanked: 30 times

Postby piranhaxp » 28 Oct 2009

Function : IsSess1FirstBar

var:
answer(false),
barStartTime(0);

if BarNumber = 1 then
answer = true
else if Sess2StartTime = Sess2EndTime then
{ no session 2, e.g. stocks }
answer = date <> date[1]
else begin
{ there is a session 2, e.g. E-Mini }
barStartTime = CalcTime(Time,-BarInterval);
if barStartTime = Sess1StartTime then
answer = true
else if barStartTime > Sess1StartTime then
answer = false
else begin
answer = Time > Sess1StartTime;
end;
end;

IsSess1FirstBar = answer;


Sorry. I forgot to post it.

Kind regards.

Mike

nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

Postby nuno-online » 02 Nov 2009

Thank you Mike & TJ for your help

Nuno

User avatar
piranhaxp
Posts: 241
Joined: 18 Oct 2005
Has thanked: 4 times
Been thanked: 30 times

Postby piranhaxp » 02 Nov 2009

No Problem at all ... do you use these two levels as a support/resitance fro the next day ? I thought it could/should be a good idea and coded the levels for the averages for hourly high/low for the previous day. Then I saw that in more then 80% we have HL for the day in this zone from the previous day.

Can you tell me what your idea is/ or was to get this zone in your chart ? Would be interesting . Thx.

Mike

nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

Postby nuno-online » 02 Nov 2009

Mike

i only want to see how available are these support & resistance
It's only an idea !

Nuno


Return to “MultiCharts”