How to code drawing local high and local low on charts
How to code drawing local high and local low on charts
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 ?
- 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
Hi leety2008,
Here is an example.
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]);
Re: How to code drawing local high and local low on charts
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.
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.
Re: How to code drawing local high and local low on charts
Hello Svetlana,
In addition, please explain the code you used " %price%" . How to format the price without decimal point. Thank you.
In addition, please explain the code you used " %price%" . How to format the price without decimal point. Thank you.
- 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
Please try this
Text_SetString(HTextId, "H: " + NumToStr(H[HNum], 0) + "\n");
Text_SetString(HTextId, "H: " + NumToStr(H[HNum], 0) + "\n");
Re: How to code drawing local high and local low on charts
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.
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.