Display single value as text. |
Post Reply |
Author | |
markos
Newbie Joined: 13 Oct 2012 Posts: 3 |
Post Options
Quote Reply
Topic: Display single value as text. Posted: 15 Oct 2012 at 9:36pm |
Hi all,
I have written a script (we copied bits from here and there and added something of my own). But I am having an issue with the output. Basically the indicator plots two plots on a symbol, but I want the second plot to only display its las value as text. I can get it to display as text, but I get every value. I created the script this way as I wanted the same time frame applied to both plots (I also couldn't work out how to use the timeframe specified in one indicator in another without having to set it each time I applied it) Any assistance would be appreciated Here is my last effort: [target=Price; category=Moving Average] expr := expression("Expression"); method := inputma("Method",SIMPLE); n := input("Time periods",14,1); res := ma(expr,n,method); [linestyle=Solid; color=Red] res; [linestyle=hidden; visible=no] ResNow := Res; Res52W := ref(res,-52); Change := ResNow - Res52w; ROARtxt := 100*(Change/ResNow); ROARtxt; [linestyle=text; visible = yes; colour = blue] lastROAR:= lastvalue(ROARtxt); lastROAR;close |
|
cmacdon
BullCharts Guru Joined: 09 Sep 2012 Location: Brisbane Posts: 236 |
Post Options Quote Reply Posted: 16 Oct 2012 at 9:03pm |
Markos
I looked at a charrt after using your scrip. It shows aa MA line with I think the current value shown as text at every bar. Ther was another line but it seem off the scale? From the gist of your narrative I assume you want to only show a text value at the last bar? I hacked some code previously provided by Maximo on a bullscript post for "Text on Chart" and attach the amendment to uyou code as it only shows the value allocated for the last bar. I coverd up you second line as i did not understand what it was. You can reiinstate by removing THE BRACKETS{} and further amend if you so wish The last bar text is turned on by ticking the text box in the style menu. Regards Charles [target =Price; category=Moving Average;] expr := expression("Expression"); method := inputma("Method",SIMPLE); n := input("Time periods",14,1); res := ma(expr,n,method); [linestyle =Solid; color=Red] res; [linestyle =hidden; visible=no] ResNow := Res; Res52W := ref(res,-52); Change := ResNow - Res52w; ROARtxt := 100*(Change/ResNow); {ROARtxt;} {[linestyle=text; visible = yes; colour = blue] lastROAR:= lastvalue(ROARtxt); lastROAR;close} { This additional bit is just a hacking and slight amendment of the code Maximo supplied in his Bullscript Forum post For Text on Chart } a:= IF(systemdate=Systemdate ,RoarTxt, Undefined); Bars:= datediff("D", Systemdate, systemdate) + 1; [linestyle =Text ; textalign=Above,Left; target=price] if (barnumber=lastvalue(barnumber), Round(a,2) + " ", undefined); High ; |
|
BC User since June 2007
|
|
markos
Newbie Joined: 13 Oct 2012 Posts: 3 |
Post Options Quote Reply Posted: 16 Oct 2012 at 10:31pm |
Charles
Thanks for the pointer. I managed to get it to work with a bit more tweaking. Below is the code: {Moving Average Calculation} [target=Price; category=Moving Average;] expr := expression("Expression"); method := inputma("Method",SIMPLE); n := input("Time periods",14,1); res := ma(expr,n,method); [linestyle=Solid; color=Red] res; {Alan Hull's ROAR calculation for best fit Moving Average} [linestyle=hidden; visible=no] ResNow := Res; Res52W :=ref(res,-52); Change := ResNow - Res52w; ROARtxt := 100*(Change/ResNow); {This part displays the ROAR as a percentage} a:=IF(systemdate=Systemdate ,RoarTxt, Undefined); [linestyle=Text; textalign=Above,Left; target=price;visible=yes] if(barnumber=lastvalue(barnumber), Round(a,2) + "%", undefined);High; |
|
markos
Newbie Joined: 13 Oct 2012 Posts: 3 |
Post Options Quote Reply Posted: 16 Oct 2012 at 10:34pm |
Here is the chart:
|
|
Post Reply |
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |