how do i add a horizontal line (dotted, orange color) at value 50 for current EFS fomula. (RSI 0f ROC). it already has upper value and lower value. i need a value in the middle(50)
Announcement
Collapse
No announcement yet.
adding a horizontal line to the formula.
Collapse
X
-
tob
Add the following statement in the preMain function
addBand(50, PS_DOT, 1, Color.RGB(255,155,0),"50")
See the article for addBand() in the EFS KnowledgeBase for more information on this function
Alex
Originally posted by tob View Posthow do i add a horizontal line (dotted, orange color) at value 50 for current EFS fomula. (RSI 0f ROC). it already has upper value and lower value. i need a value in the middle(50)
-
Thx ACM. i get error messages when i do that.posted below the original efs formula. where do i add it?
var fpArray = new Array();
var bInit = false;
function preMain() {
setStudyTitle("RSI(ROC)");
setCursorLabelName("RSI(ROC)",0);
setShowTitleParameters(false);
setDefaultBarFgColor(Color.RGB(0x00,0x94,0xFF), 0);
setStudyMax(101);
setStudyMin(-1);
var x = 0;
fpArray[x] = new FunctionParameter("RSILength", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setName("Length of RSI");
setLowerLimit(1);
setDefault(20);
}
fpArray[x] = new FunctionParameter("ROCLength", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setName("Length of ROC");
setLowerLimit(1);
setDefault(20);
}
fpArray[x] = new FunctionParameter("Upper", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setLowerLimit(0);
setDefault(70);
}
fpArray[x] = new FunctionParameter("Lower", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setLowerLimit(0);
setDefault(30);
}
fpArray[x] = new FunctionParameter("Source", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Source of ROC");
addOption("open");
addOption("high");
addOption("low");
addOption("close");
addOption("hl2");
addOption("hlc3");
addOption("ohlc4");
setDefault("close");
}
}
var xRSI = null;
function main(RSILength, ROCLength, Source, Upper, Lower) {
var nBarState = getBarState();
var nRSI = 0;
if (nBarState == BARSTATE_ALLBARS) {
if(RSILength == null) RSILength = 20;
if(ROCLength == null) ROCLength = 20;
if(Source == null) Source = "close";
if(Upper == null) Upper = 70;
if(Lower == null) Lower = 30;
}
if (bInit == false) {
addBand(Upper, PS_DASH, 2, Color.grey, "Upper");
addBand(Lower, PS_DASH, 2, Color.grey, "Lower");
xRSI = rsi(RSILength, roc(ROCLength, eval(Source)()));
bInit = true;
}
nRSI = xRSI.getValue(0);
if (nRSI == null) return;
return nRSI;
}
Comment
-
tob
As I said in my prior reply you can add it to the preMain function (for example after the setStudyMin() statement).
Alternatively you can add it where you already have the other addBand() statements in the bInit routine in your main function
The statement example I provided you will work in either case
Alex
Originally posted by tob View PostThx ACM. i get error messages when i do that.posted below the original efs formula. where do i add it?
var fpArray = new Array();
var bInit = false;
function preMain() {
setStudyTitle("RSI(ROC)");
setCursorLabelName("RSI(ROC)",0);
setShowTitleParameters(false);
setDefaultBarFgColor(Color.RGB(0x00,0x94,0xFF), 0);
setStudyMax(101);
setStudyMin(-1);
var x = 0;
fpArray[x] = new FunctionParameter("RSILength", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setName("Length of RSI");
setLowerLimit(1);
setDefault(20);
}
fpArray[x] = new FunctionParameter("ROCLength", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setName("Length of ROC");
setLowerLimit(1);
setDefault(20);
}
fpArray[x] = new FunctionParameter("Upper", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setLowerLimit(0);
setDefault(70);
}
fpArray[x] = new FunctionParameter("Lower", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setLowerLimit(0);
setDefault(30);
}
fpArray[x] = new FunctionParameter("Source", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Source of ROC");
addOption("open");
addOption("high");
addOption("low");
addOption("close");
addOption("hl2");
addOption("hlc3");
addOption("ohlc4");
setDefault("close");
}
}
var xRSI = null;
function main(RSILength, ROCLength, Source, Upper, Lower) {
var nBarState = getBarState();
var nRSI = 0;
if (nBarState == BARSTATE_ALLBARS) {
if(RSILength == null) RSILength = 20;
if(ROCLength == null) ROCLength = 20;
if(Source == null) Source = "close";
if(Upper == null) Upper = 70;
if(Lower == null) Lower = 30;
}
if (bInit == false) {
addBand(Upper, PS_DASH, 2, Color.grey, "Upper");
addBand(Lower, PS_DASH, 2, Color.grey, "Lower");
xRSI = rsi(RSILength, roc(ROCLength, eval(Source)()));
bInit = true;
}
nRSI = xRSI.getValue(0);
if (nRSI == null) return;
return nRSI;
}
Comment
-
except when plotting over encrypted studies....
Originally posted by ACM View Posttob
As I said in my prior reply you can add it to the preMain function (for example after the setStudyMin() statement).
Alternatively you can add it where you already have the other addBand() statements in the bInit routine in your main function
The statement example I provided you will work in either case
Alex
- Dan
Comment
-
Dan
I fail to see how this is relevant to the topic of this thread where the OP simply asked how to add a horizontal line to an existing formula (which was also provided in a subsequent post) without any reference to overlaid and/or encrypted studies. Either solution I suggested will do what the OP asked.
Having said that, when you overlay two studies - regardless of either one being encrypted or not - you need to assign the study being overlaid to the same scale of the underlying study if you want them to be anchored to the same scale (by default the study being overlaid is not set to that scale for obvious reasons).
Alex
Originally posted by wolfeman View PostWhen attempting to overlay an encrypted study with an unencrypted study, neither way - preMain or init routine - works as the the encrypted studies does not appear to share/use the same scale with the unencrypted study... eg if you change the scale, the encrypted study price level scale changes appropriately, but the unencrypted studies bands and relative lines - which are plotted at specific price points - remain at the same vertical location and no longer map to the correct price point on the update scale... I'd call it a bug.
- Dan
Comment
-
Originally posted by ACM View PostDan
Having said that, when you overlay two studies - regardless of either one being encrypted or not - you need to assign the study being overlaid to the same scale of the underlying study if you want them to be anchored to the same scale (by default the study being overlaid is not set to that scale for obvious reasons).
In spite of the lack of documentation on scaling, I was, due to Alex's hint, able to figure it out. My notes:
1) chart scales are not set in EFS - they are set by the UI in eSignal 12. EFS setStudyMin/setStudyMax are red herrings in this particular case....
2) UI Price scales are set by right clicking on some visible portion of the overlay study. Chart properties dialog/scales section doesn't cover setting the study scales....
3) As Alex says, you need to have the studies share the same scale... The No Scale option simply plots the data according to the chart size. In my case you need to change it to right scale to match the underlying encrypted chart...
Bottom line, better documentation - both EFS and UI regarding scaling would have made me a happier camper...
- Dan
Comment
Comment