Hi,
In this efs I’d like to select the symbol and interval so that it plots the “high(0), low(0), high(-1), low(-1)” on a chart. The issue is that I get null values when I add the “capability” to select a different symbol and interval than that displayed on the chart. In other words, I’d like to display say, above values from a 3 min chart onto a 55T chart.
The attached efs is my original modification using the charts own symbol and interval and it works fine. The following code returns the null values.
Any help is greatly appreciated.
Wayne.
In this efs I’d like to select the symbol and interval so that it plots the “high(0), low(0), high(-1), low(-1)” on a chart. The issue is that I get null values when I add the “capability” to select a different symbol and interval than that displayed on the chart. In other words, I’d like to display say, above values from a 3 min chart onto a 55T chart.
The attached efs is my original modification using the charts own symbol and interval and it works fine. The following code returns the null values.
PHP Code:
/******************************************************************************************
Copyright © eSignal, a division of Interactive Data Corporation. 2005. All rights reserved.
This sample eSignal Formula Script (EFS) may be modified and saved under a new filename;
however, eSignal is no longer responsible for the functionality once modified.
eSignal reserves the right to modify and overwrite this EFS file with each new release.
@version 3.0 by Alexis Montenegro for eSignal
*******************************************************************************************/
//20080810, ADDED MENU ITEMS AND OTHER FORMULAS
debugClear();
var aFPArray = new Array();
function preMain() {
setPriceStudy(true);
setStudyTitle("High-Low(-1) or High-Low(0) Text1-mgn.efs");
setCursorLabelName("TO");
setShowCursorLabel(false);
setShowTitleParameters( false );
var x=0;
aFPArray[x] = new FunctionParameter("vSymbol", FunctionParameter.STRING);
with(aFPArray[x++]){
setDefault();
}
aFPArray[x] = new FunctionParameter( "Interval0", FunctionParameter.String);
with( aFPArray[x++] ) {
setName( "MA1 Interval" );
addOption( "55T" );
addOption( "233T" );
addOption( "512T" );
addOption( "1" );
addOption( "3" );
addOption( "10" );
addOption( "15" );
addOption( "30" );
addOption( "60" );
addOption( "120" );
addOption( "240" );
addOption( "D" );
addOption( "W" );
addOption( "M" );
addOption( "Default" );
setDefault( "Default" );
}
aFPArray[x] = new FunctionParameter( "vDisplay", FunctionParameter.STRING);
with( aFPArray[x++] ) {
setName( "Bars to Display" );
addOption( "High(0)/low(0)" );
addOption( "High(-1)/low(-1)" );
addOption( "Both" );
setDefault( "Both" );
}
aFPArray[x] = new FunctionParameter( "vDispWhere", FunctionParameter.STRING);
with( aFPArray[x++] ) {
setName( "Text Placement" );
addOption( "Top Margin" );
addOption( "By Price" );
addOption( "Both" );
setDefault( "Both" );
}
aFPArray[x] = new FunctionParameter( "vOffset", FunctionParameter.NUMBER);
with( aFPArray[x++] ) {
setName( "Text Offset" );
setLowerLimit( 1 );
setUpperLimit( 20 );
addOption( 1 );
addOption( 2 );
addOption( 3 );
addOption( 4 );
addOption( 5 );
addOption( 6 );
addOption( 7 );
addOption( 8 );
setDefault( 1 );
}
aFPArray[x] = new FunctionParameter( "vFontSize", FunctionParameter.NUMBER);
with( aFPArray[x++] ) {
setName( "Font Size" );
addOption( 8 );
addOption( 9 );
addOption( 10 );
addOption( 11 );
addOption( 12 );
setDefault( 10 );
}
aFPArray[x] = new FunctionParameter( "vFontColor1", FunctionParameter.COLOR);
with( aFPArray[x++] ) {
setName( "Text Color High" );
setDefault( Color.blue );
}
aFPArray[x] = new FunctionParameter( "vFontColor2", FunctionParameter.COLOR);
with( aFPArray[x++] ) {
setName( "Text Color Low" );
setDefault( Color.red );
}
aFPArray[x] = new FunctionParameter( "DisplayDarkLabel", FunctionParameter.BOOLEAN);
with( aFPArray[x++] ) {
setName( "Display Dark Price" );
setDefault( false );
}
aFPArray[x] = new FunctionParameter( "vRndTo25", FunctionParameter.BOOLEAN);
with( aFPArray[x++] ) {
setName( "Round to 0,25" );
setDefault( true );
}
}
var bInit = false;
var vAvgBar6 = null;
var vIntHigh = null;
var vIntLow = null;
var vHigh1 = 0;
var vLow1 =0;
function main(vSymbol,Interval0,vDisplay,vDispWhere,vOffset,vFontSize,vFontColor1,
vFontColor2,DisplayDarkLabel,vRndTo25) {
// if(isMonthly() || isWeekly() || isDaily())
// return;
if(bInit == false){
var vSymbol = getSymbol();
if(Interval0 == "Default" || Interval0 == null) Interval0 = getInterval();
var xSymbol = "\""+vSymbol+","+Interval0+"\"";
vIntHigh = high(sym(xSymbol));
vIntLow = low(sym(xSymbol));
bInit = true;
//debugPrintln(xSymbol);
debugPrintln(vIntHigh);
}
var vHigh = vIntHigh.getValue(0);// getValue("High", 0,1, xSymbol);
var vLow = vIntLow.getValue(0);// getValue("Low", 0, 1,xSymbol);
//debugPrintln(vHigh);
if (!vRndTo25){
vHighTxt = rnd(vHigh,2);
vLowTxt = rnd(vLow,2);
vHigh1Txt = rnd(vHigh1,2);
vLow1Txt = rnd(vLow1,2);
}else if (vRndTo25){
vHighTxt = rnd25(vHigh);
vLowTxt = rnd25(vLow);
vHigh1Txt = rnd25(vHigh1);
vLow1Txt = rnd25(vLow1);
}
if (getBarState() == BARSTATE_NEWBAR){
vHigh1 = vHigh;
vLow1 = vLow ;
}
var h = vHigh1Txt+" High (0)";
var vLen1High = h.length;
var l = vLow1Txt+" High (0)";
var vLen1Low = l.length;
var vDistance = Math.max(vLen1High,vLen1Low);
if(DisplayDarkLabel){
var vx1 = Color.black;
var vx2 = Color.black;
var vx3 = Color.RGB(192,192,192);
var rd1 = 5;
var rd2 = 21
}else{
var vx1 = vFontColor1;
var vx2 = vFontColor2;
var vx3 = "null"
var rd1 = 5;
var rd2 = 18
}
if(vDisplay == "High(0)/low(0)"){
if(vDispWhere == "By Price" || vDispWhere == "Both"){
drawTextAbsolute(vOffset, high(0), "-- "+vHighTxt+" High (0)", eval(vx1), eval(vx3), Text.LEFT|Text.VCENTER, "Arial", vFontSize, "textH0");
drawTextAbsolute(vOffset, high(0)-.5, "-- "+vLowTxt+" Low (0)", eval(vx2), eval(vx3), Text.LEFT|Text.VCENTER, "Arial", vFontSize, "textL0");
}if(vDispWhere == "Top Margin" || vDispWhere == "Both"){
drawTextRelative( -1, rd1, vHighTxt+" High (0)", eval(vx1), eval(vx3), Text.VCENTER | Text.RELATIVETOTOP, null, vFontSize, "textH0a" );
drawTextRelative( -1, rd2, vLowTxt+" Low (0)", eval(vx2), eval(vx3), Text.VCENTER | Text.RELATIVETOTOP, null, vFontSize, "textL0a" );
}
}else if(vDisplay == "High(-1)/low(-1)"){
if(vDispWhere == "By Price" || vDispWhere == "Both"){
drawTextAbsolute(vOffset, high(-1), "-- "+vHigh1Txt+" High (-1)", eval(vx1), eval(vx3), Text.LEFT|Text.VCENTER, "Arial", vFontSize, "textH1");
drawTextAbsolute(vOffset, high(-1)-.5, "-- "+vLow1Txt+" Low (-1)", eval(vx2), eval(vx3), Text.LEFT|Text.VCENTER, "Arial", vFontSize, "textL1");
}if(vDispWhere == "Top Margin" || vDispWhere == "Both"){
drawTextRelative( -1, rd1, vHigh1Txt+" High (-1)", eval(vx1), eval(vx3), Text.VCENTER | Text.RELATIVETOTOP, null, vFontSize, "textH1a" );
drawTextRelative( -1, rd2, vLow1Txt+" Low (-1)", eval(vx2), eval(vx3), Text.VCENTER | Text.RELATIVETOTOP, null, vFontSize, "textL1a" );
}
}else if(vDisplay == "Both"){
if(vDispWhere == "By Price" || vDispWhere == "Both"){
drawTextAbsolute(vDistance, high(0), "-- "+vHighTxt+" High (0)", eval(vx1), eval(vx3), Text.LEFT|Text.VCENTER, "Arial", vFontSize, "textH2");
drawTextAbsolute(vDistance, high(0)-.5, "-- "+vLowTxt+" Low (0)", eval(vx2), eval(vx3), Text.LEFT|Text.VCENTER, "Arial", vFontSize, "textL2");
drawTextAbsolute(vOffset, high(0), "-- "+vHigh1Txt+" High (-1)", eval(vx1), eval(vx3), Text.LEFT|Text.VCENTER, "Arial", vFontSize, "textH3");
drawTextAbsolute(vOffset, high(0)-.5,"-- "+vLow1Txt+" Low (-1)", eval(vx2), eval(vx3), Text.LEFT|Text.VCENTER, "Arial", vFontSize, "textL3");
}if(vDispWhere == "Top Margin" || vDispWhere == "Both"){
drawTextRelative( vDistance-3, rd1, vHighTxt+" High (0)", eval(vx1), eval(vx3), Text.VCENTER | Text.RELATIVETOTOP, null, vFontSize, "textH4" );
drawTextRelative( vDistance-3, rd2, vLowTxt+" Low (0)", eval(vx2), eval(vx3), Text.VCENTER | Text.RELATIVETOTOP, null, vFontSize, "textL4" );
drawTextRelative( -1, rd1, vHigh1Txt+" High (-1)", eval(vx1), eval(vx3), Text.VCENTER | Text.RELATIVETOTOP, null, vFontSize, "textH4a" );
drawTextRelative( -1, rd2, vLow1Txt+" Low (-1)", eval(vx2), eval(vx3), Text.VCENTER | Text.RELATIVETOTOP, null, vFontSize, "textL4a" );
}
}
else return;
return;
}
//ROUNDING FUNCTION
function rnd(value, N) { //N = round to N # of digits
var n;
var mult=1;
for(n=0;n<N;n++) mult*=10;
value*=mult;
return Math.round( value,N)/mult;
}
function rnd25(yValue){ // Round to nearest 0.25
if(yValue%0.25<0.125)
y=yValue-yValue%0.25
else
y=(yValue-yValue%0.25+0.25)
return y;
}
/* for(var i=0; i<7; i++) {
xHigh = high(-i)
xLow = low(-i)
Sum1 = (xHigh+xLow)/2;
Sum2 += Sum1;
}*/
Wayne.
Comment