I have 9 efs user input parameters that I would like to be the same in 4 different charts. Is there a way to link those 9 parameters in the charts so I do not have to type them into each chart each morning?
The only way that I can think of that working is to create a file with the associated variables. Then during efs initiation, read these values from the file and use them as the default values for your FunctionParameters. It has been a while since I have worked with this, but I believe this is possible.
Please post an abbreviated sample efs to work from and I will help you put this together.
Thanks Steve.
I have never done user inputs from an external file before.
Very basic code for drawing S and R bars on a chart for AB U6 would be as follows:
// test.efs to test linking chart user inputs using an external file
function preMain() { // pre-Main
setColorPriceBars(true);
setPriceStudy(true);
setStudyTitle("test.efs");
setShowTitleParameters(false);
setDefaultFont("Arial",10, Color.RGB(0,255,255), Text.RIGHT | Text.ONTOP);
var R3 = new FunctionParameter("R3", FunctionParameter.NUMBER);
R3.setDefault(725);
var R2 = new FunctionParameter("R2", FunctionParameter.NUMBER);
R2.setDefault(724);
var R1 = new FunctionParameter("R1", FunctionParameter.NUMBER);
R1.setDefault(723);
var S1 = new Fu722ctionParameter("S1", FunctionParameter.NUMBER);
S1.setDefault(722);
var S2 = new FunctionParameter("S2", FunctionParameter.NUMBER);
S2.setDefault(721);
var S3 = new FunctionParameter("S3", FunctionParameter.NUMBER);
S3.setDefault(720);
}
function main ( R3, R2, R1, S1, S2, S3 )
{ // main
// draw bars
addBand(R1, PS_DASHDOTDOT, 2, Color.yellow, R1);
addBand(R2, PS_DASHDOTDOT, 2, Color.yellow, R2);
addBand(R3, PS_DASHDOTDOT, 2, Color.yellow, R3);
addBand(S1, PS_DASHDOTDOT, 2, Color.yellow, S1);
addBand(S2, PS_DASHDOTDOT, 2, Color.yellow, S2);
addBand(S3, PS_DASHDOTDOT, 2, Color.yellow, S3);
}
I went ahead and posted the changes I made to your code in support the goal. It is a modified copy of an efs I previously had working, but I haven't had a chance to verify the modifications I made did not introduce an error of some kind. If you want to try it out, by all means give it a go. I included a link to another efs in the comments section of this one that may also suit your application as well. You should try that out as when you have a chance.
You are most welcome. Thanks as well for your kind words. There are some things I am still looking at with regards to the FunctionParameter() object behavior. My recommendation is to retrieve the values solely from the file for now. I have tested this methodology extensively and know this is quite reliable.
Ok. I see your point. I just tried to update the parameters in one chart (the first chart I loaded the efs into) using Edit Studies and then reload the efs in a second chart.
Not only did the lines not change in the second chart, I could not get the edit to have effect in the first chart.
It would appear I have misplaced the main chart. LOL.
So I then looked in the FormulaOutput folder, found ABU6_SR_Levels.txt, changed the numbers, reloaded the charts and no problem.
This is a great solution. It is actually easier to type the numbers into the txt file than using Edit Studies. I put a shortcut on my desktop to the txt file and I am set to go.
Comment