Quarterly Open, High, Low, Close  [SOLVED]

Questions about MultiCharts and user contributed studies.
mickatrade
Posts: 114
Joined: 12 Jul 2015
Has thanked: 20 times
Been thanked: 16 times

Quarterly Open, High, Low, Close

Postby mickatrade » 26 Feb 2018

Hello,

I'm looking for reserved words for Quarterly Open, quarterly high, quarterly low, quarterly close but i can't find them.
Does someone have a custom code for them or can help me to code them ?
I think it would be nice to have those reserved word on future versions of MC.
Regards.
MJ

User avatar
fbertram
Posts: 166
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 36 times
Been thanked: 76 times
Contact:

Re: Quarterly Open, High, Low, Close

Postby fbertram » 26 Feb 2018

Hi MJ,

while I no longer have a PowerLanguage version of MultiCharts available to me (I converted to .NET) and therefore can't test my response, you will need to code something along the lines of this:

Code: Select all

vars:
monthSeries, quarterlyHigh;
monthSeries = Month(DateTime);

if (Floor((monthSeries[0] - 1) / 4) > Floor((monthSeries[1] - 1)/4)) then begin
// a new quarter just began
quarterlyHigh = High[0];
end else begin
// we are somewhere within a quarter
quarterlyHigh = MaxList(quarterlyHigh, High[0]);
end;
I hope this gets you going,
Cheers,

Felix

mickatrade
Posts: 114
Joined: 12 Jul 2015
Has thanked: 20 times
Been thanked: 16 times

Re: Quarterly Open, High, Low, Close

Postby mickatrade » 27 Feb 2018

Hello Felix,
Thank you for your help.
Here the indicator.
I'll have to customise your code to get what i want.
quarterly indicator.png
(54.85 KiB) Downloaded 689 times

mickatrade
Posts: 114
Joined: 12 Jul 2015
Has thanked: 20 times
Been thanked: 16 times

Re: Quarterly Open, High, Low, Close

Postby mickatrade » 27 Feb 2018

This is what i want to do.
The indicator plots the high and the low of the previous month.
I need to do the same but with previous quarterly high and low.
previous month low and high.png
(61.75 KiB) Downloaded 688 times

User avatar
fbertram
Posts: 166
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 36 times
Been thanked: 76 times
Contact:

Re: Quarterly Open, High, Low, Close

Postby fbertram » 27 Feb 2018

Hi MJ,

so looking at your chart it seems that you'd like a function to return the open/high/low/close of the *previous* quarter. That's easy to do, just change the code to this:

Code: Select all

vars:
monthSeries, quarterlyHigh, prevQuarterlyHigh;
monthSeries = Month(DateTime);

if (Floor((monthSeries[0] - 1) / 4) > Floor((monthSeries[1] - 1)/4)) then begin
// a new quarter just began
prevQuarterlyHigh = quarterlyHigh;
quarterlyHigh = High[0];
end else begin
// we are somewhere within a quarter
quarterlyHigh = MaxList(quarterlyHigh, High[0]);
end;
Cheers, Felix

mickatrade
Posts: 114
Joined: 12 Jul 2015
Has thanked: 20 times
Been thanked: 16 times

Re: Quarterly Open, High, Low, Close

Postby mickatrade » 28 Feb 2018

Hi MJ,

so looking at your chart it seems that you'd like a function to return the open/high/low/close of the *previous* quarter. That's easy to do, just change the code to this:

Code: Select all

vars:
monthSeries, quarterlyHigh, prevQuarterlyHigh;
monthSeries = Month(DateTime);

if (Floor((monthSeries[0] - 1) / 4) > Floor((monthSeries[1] - 1)/4)) then begin
// a new quarter just began
prevQuarterlyHigh = quarterlyHigh;
quarterlyHigh = High[0];
end else begin
// we are somewhere within a quarter
quarterlyHigh = MaxList(quarterlyHigh, High[0]);
end;
Cheers, Felix
Hi felix,
Thank you for your updated code, it seems the behavior of the indicator is not good.
see the picture attached.
Regards,
MJ
quarterly2.png
(135.9 KiB) Downloaded 672 times

mickatrade
Posts: 114
Joined: 12 Jul 2015
Has thanked: 20 times
Been thanked: 16 times

Re: Quarterly Open, High, Low, Close  [SOLVED]

Postby mickatrade » 28 Feb 2018

Hello,
I've managed to do it.
I've modified OHLCperiodago to do it.
Finally i've created HighQ and LowQ :)
code.png
(106.79 KiB) Downloaded 669 times
HighQ.png
(24.48 KiB) Downloaded 669 times
quarterlyindicator.png
(11.16 KiB) Downloaded 669 times


Return to “MultiCharts”