StockFetcher Forums · Filter Exchange · A Little Help TRO<< 1 2 >>Post Follow-up
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);

}


TheRumpledOne
6,411 posts
msg #45565
Ignore TheRumpledOne
7/8/2006 2:12:12 PM

You're kidding, right?

LOL!


guru_trader
485 posts
msg #45589
Ignore guru_trader
modified
7/9/2006 4:48:40 AM

TRO, you can do it! :)



TheRumpledOne
6,411 posts
msg #45593
Ignore TheRumpledOne
modified
7/9/2006 11:47:19 AM

Fetcher[
/* Keltner Bollinger Squeeze Filter */

set{xUp, days(upper bollinger(20,2.0) above the Upper Keltner Band(20) , 100 )}
set{xDn, days(lower bollinger(20,2.0) below the Lower Keltner Band(20) , 100 )}

set{xUBB, days(high >= upper bollinger(20,2.0) , 100 )}
set{xLBB, days(low <= lower bollinger(20,2.0) , 100 )}

set{xRange, high - low }
set{xRPCT, xRange / atr(20) }

set{xMomStudy, cema(momentum(12), 10) }
set{xReturn1, xMomStudy + MACD Fast Line(12,26) }
set{xReturn, xReturn1 / 2 }

/* plots */

draw xUp
draw xDn on plot xUp

draw xRange
draw atr(20) on plot xRange

draw momentum(12)
draw macd(12,26,9)
draw xReturn


/* column displays */

add column xUp
add column xDn

add column xUBB
add column xLBB

add column xRange
add column atr(20)
add column xRPCT
add column xReturn

/* squeeze selection */

upper bollinger(20,2.0) below the Upper Keltner Band(20)

lower bollinger(20,2.0) above the Lower Keltner Band(20)

/* price, volume selection */

close above 1
volume above 300000
]




There's a quick 'n dirty filter for the Keltner/Bollinger Squeeze.


xUp : number of days upper Bollinger below upper Keltner
xDn : number of days lower Bollinger above lower Keltner

xUBB : number of days since close >= upper Bollinger
xLBB : number of days since close <= lower Bollinger

Trade in direction of breakout.

HTH.

P.S. You guys owe me for this one!!
















leaddog
38 posts
msg #45600
Ignore leaddog
7/9/2006 3:34:46 PM

Thank you TRO immensely! Your coding skills are top notch. I also thought you would enjoy the challenge of it.

Best regards.


TheRumpledOne
6,411 posts
msg #45603
Ignore TheRumpledOne
7/9/2006 5:33:57 PM

Enjoy? LOL!

You still owe me for this one.


mystiq
650 posts
msg #80057
Ignore mystiq
9/25/2009 8:02:46 AM

nice (-.-)

satanscashcow
19 posts
msg #108013
Ignore satanscashcow
9/11/2012 3:41:11 PM

People are still using the TTM squeeze...you guys
did a great job on this...bump.

four
5,087 posts
msg #144706
Ignore four
9/18/2018 6:34:36 PM

pop

Ruaquik1
5 posts
msg #144753
Ignore Ruaquik1
9/24/2018 10:39:48 PM

Does this still work? :)

StockFetcher Forums · Filter Exchange · A Little Help TRO<< 1 2 >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2022 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.