leaddog 38 posts msg #45538 - Ignore leaddog |
7/7/2006 10:14:27 PM
Hi TRO,
Do you mind translating this to stockfetcher code?
Below is the uncompiled ESignal code for this indicator. I'm not really familar with Esignal Efs program language but it would appear to me that there is something going on with an ATR in the Squeeze. Perhaps when they refer to a histogram of "pure price action" this is what is being referenced.
function preMain() {
setStudyTitle("FPSqueeze");
setCursorLabelName("FPSqueeze", 0);
setDefaultBarFgColor(Color.blue, 0);
setPlotType(PLOTTYPE_HISTOGRAM,0);
setDefaultBarThickness(4,0);
//addBand(0,PS_SOLID,1,Color.black,"zero");
var BBlow=null;
var BBhigh=null;
var KClow=null;
var KChigh=null;
var Mom=null;
var vHigh=null;
var vLow=null;
var vClose=null;
var fp1 = new FunctionParameter("nMA", FunctionParameter.NUMBER);
fp1.setName("Squeeze Moving Average");
fp1.setLowerLimit(1);
fp1.setDefault(20);
var fp2 = new FunctionParameter("nSD", FunctionParameter.NUMBER);
fp2.setName("Standard Deviation");
fp2.setLowerLimit (1);
fp2.setDefault(2.0);
var fp3 = new FunctionParameter("nColorSqueeze", FunctionParameter.COLOR);
fp3.setName("Squeeze Color");
fp3.setDefault(Color.red);
var fp4 = new FunctionParameter("nColorAction", FunctionParameter.COLOR);
fp4.setName("Action Color");
fp4.setDefault(Color.lime);
}
function ATR(nInputLength) {
var dSum = 0;
var dH = high(0, -nInputLength);
var dL = low(0, -nInputLength);
var dC = close(-1, -nInputLength);
if (dH == null || dL == null || dC == null) {
return;
}
for (i = 0; i < nInputLength; ++i) {
var vTrueHigh = Math.max(dH, dC);
var vTrueLow = Math.min(dL, dC);
var vTrueRange = (vTrueHigh - vTrueLow);
dSum += vTrueRange;
}
dSum /= nInputLength;
return dSum;
}
function main(nMA, nSD, nColorSqueeze, nColorAction) {
//Bollinger Band Variables using 1.4 Standard Deviation
var myStudy1 = upperBB (nMA,nSD);
var myStudy2 = lowerBB (nMA,nSD);
var momStudy1 = ema(10,mom(12));
var macdstudy = new macdHist(12,26,9);
BBlow = myStudy2.getValue(0);
BBhigh = myStudy1.getValue(0);
Mom = momStudy1.getValue(0);
macdvalue = macdstudy.getValue(0);
var BarCntr;
var nRangeFactor = 1.5;
if (getBarState() == BARSTATE_NEWBAR)
BarCntr += 1;
if (BarCntr < nMA) {
return;
} else {
var dKeltnerBasis= call("/Library/KeltnerEMA.efs", nMA);
var dATR = ATR(nMA);
//return new Array(dKeltnerBasis + (nRangeFactor * dATR), dKeltnerBasis, dKeltnerBasis - (nRangeFactor * dATR));
KClow = (dKeltnerBasis - (nRangeFactor * dATR));
KChigh = (dKeltnerBasis + (nRangeFactor * dATR));
}
//Logic to create red or blue Squeeze signal
if ((BBhigh <= KChigh) && (BBlow >= KClow)) {
drawShapeRelative(0,0,Shape.CIRCLE,null,nColorSqueeze,Shape.TOP);
}
if ((BBhigh > KChigh) && (BBlow < KClow)) {
drawShapeRelative(0,0,Shape.CIRCLE,null,nColorAction,Shape.TOP);
}
if ((BBhigh <= KChigh) && (BBlow <= KClow)) {
drawShapeRelative(0,0,Shape.CIRCLE,null,Color.black,Shape.TOP);
}
if ((BBhigh > KChigh) && (BBlow > KClow)) {
drawShapeRelative(0,0,Shape.CIRCLE,null,Color.black,Shape.TOP);
}
if (Mom > 0) {
setBarFgColor(Color.blue);
}
else {
setBarFgColor(Color.red);
}
drawTextPixel( 1, 93, "BB Squeeze v0.1", Color.black, null, Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM | Text.BOLD, "Arial",10 );
return ((Mom+macdvalue)/2);
}
|