How to code drawing local high and local low on charts

Questions about MultiCharts and user contributed studies.
leety2008
Posts: 11
Joined: 26 Oct 2021
Has thanked: 2 times

How to code drawing local high and local low on charts

Postby leety2008 » 26 Oct 2021

I want to have indication and prices on local high and local low on charts, say display on last 40 minutes of 1 minute time frame. How to code it ?

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: How to code drawing local high and local low on charts

Postby Svetlana MultiCharts » 27 Oct 2021

Hi leety2008,

Here is an example.

Code: Select all

var: Num(0), HNum(0), LNum(0), HTextId(-1), LTextId(-1); once begin HTextId = Text_New(d,t,c,"H: %price%\n"); LTextId = Text_New(d,t,c,"\nL: %price%"); end; HNum = 0; LNum = 0; Num = 0; While True Begin if (datetime2eltime(datetime - datetime[Num]) > 40) then break; if (H[HNum] < H[Num]) then HNum = Num; if (L[LNum] > L[Num]) then LNum = Num; Num = Num + 1; End; text_setlocation_bn(HTextId, currentbar - HNum, H[HNum]); text_setlocation_bn(LTextId, currentbar - LNum, L[LNum]); Plot1(H[HNum]); Plot2(L[LNum]);
image example.png
(100.03 KiB) Not downloaded yet
HL_Last40min.pla
(3.02 KiB) Downloaded 74 times

leety2008
Posts: 11
Joined: 26 Oct 2021
Has thanked: 2 times

Re: How to code drawing local high and local low on charts

Postby leety2008 » 27 Oct 2021

Hello Svetlana,
Thank you and appreciated your help. That works for me perfectly. I would like to view the local High Low within the scrolling window view, ie. all the bars appeared within my window view will be taken into account. If I scroll my window view then the local high low will be recalculated accordingly.
Thank you again.

leety2008
Posts: 11
Joined: 26 Oct 2021
Has thanked: 2 times

Re: How to code drawing local high and local low on charts

Postby leety2008 » 28 Oct 2021

Hello Svetlana,
In addition, please explain the code you used " %price%" . How to format the price without decimal point. Thank you.

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: How to code drawing local high and local low on charts

Postby Svetlana MultiCharts » 28 Oct 2021

Please try this
Text_SetString(HTextId, "H: " + NumToStr(H[HNum], 0) + "\n");

leety2008
Posts: 11
Joined: 26 Oct 2021
Has thanked: 2 times

Re: How to code drawing local high and local low on charts

Postby leety2008 » 10 Nov 2021

Hello Svetlana,
Further to the script mentioned above, I would like to label each local high and each local low without the time bracket i.e. 40 minutes in my example. Please help the coding.


Return to “MultiCharts”