|
Josh McCormick
2020-09-10 12:48:18
|
|
Below is a script that sets the currently active symbol as your reference benchmark symbol. You can then recall your reference benchmark in any of your formulas and use it however you like. The script is designed to be bound to a hotkey. I, myself, use SHIFT-CONTROL-R. (Hotkeys are assigned by going to the bottom of the screen, selecting Divers, and then List of Shortcuts.) It requires you to download the GetVariable Multiple Usage technical indicator so that you can retrieve the benchmark symbol and use it in your formulas.
I personally have a pane that compares the currently active symbol against my benchmark symbol. So if I haven't done so already, I pull up my benchmark symbol in QuantShare. I hit Shift-Control-R to set it as my benchmark. Then I load whatever symbol(s) I want to compare it to, and my formula remembers which symbol I set my benchmark to. So once you've got all of this configured, it is pretty simple to use. But this probably isn't for novice users. If I end up making an enhanced version of this script, it would be to make the benchmark symbol persistent so that it is saved and then automatically recalled each time you restart QuantShare.
EXAMPLE USE IN A FORMULA:
benchmark=GetVariable("Benchmark");
// If the string is blank (which happens each time QuantShare restarts), set "SPY" as the default.
benchmark=iffstr(!StringContains("",benchmark),benchmark,"SPY");
benchclose = iff(IsEod()==0,0,getseries(benchmark,close,LastData));
plot (benchclose,benchmark,colorGreen,ChartLine,StyleOwnScale1|StyleWidth5|StyleHideValues);
SETBENCHMARK SCRIPT v1.0 IS AS FOLLOWS:
string keyword="Benchmark";
string symbol="";
Chart mychart = Charts.GetSelectedChart();
symbol=mychart.SymbolName;
Global.SetVariable(keyword,symbol);
Chart[] charts = Charts.GetAllCharts();
for(int i=0;i < charts.Length;i++) charts[i].Update();
Enjoy. Let me know if you have any questions/comments/issues/improvements.
EDIT: An earlier version of this document recommended using Shift-Control-B. That turned out to be a bad choice because it also brings up the Dividend adjustment screen which is launched with Control-B.
(by Josh McCormick,
uploaded several months ago)
No notes
|
|
|