Back in 2005 Alex wrote an efs: Hull crossover (Murray). It plots a Hull MA and a signal line based on an intricate Std Dev and variance calculation. The note credits Paul Murray for the idea. Does anyone know of an article somewhere that describes the theory behind the math?
Announcement
Collapse
No announcement yet.
Hull Crossover
Collapse
X
-
I downloaded this formula some time ago but could not find the orginal thread, so I started a new one.
What I was hoping to find is any documentation on the logic of the signal line.
PHP Code:/*********************************************************
Alexis C. Montenegro © October 2005
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
Paul Murray
Created a crossover study from ACM's Hull MA and Corrected
Average
**********************************************************/
var aFPArray = new Array();
//External Variables Hull MA
var nBarCounter = 0;
var nStudy1 = null;
var nStudy2 = null;
var nPlot = null;
var nPlot_1 = null;
var bInitialized = false;
function preMain(){
setShowTitleParameters( false );
setPriceStudy(true);
setStudyTitle("Hull crossover (Murray)");
setCursorLabelName("CA");
setPlotType(PLOTTYPE_LINE,0);
setDefaultBarFgColor(Color.brown,0);
setDefaultBarThickness(3,0);
// setPlotType(PLOTTYPE_LINE,1);
setCursorLabelName("HullMA", 1);
setDefaultBarFgColor( Color.blue, 1);
setDefaultBarThickness(4,1);
setPlotType( PLOTTYPE_INSTANTCOLORLINE, 1);
var x=0
aFPArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
with(aFPArray[x++]){
setLowerLimit(1);
setDefault(6);
}
aFPArray[x] = new FunctionParameter("Source", FunctionParameter.STRING);
with(aFPArray[x++]){
addOption("open");
addOption("high");
addOption("low");
addOption("close");
addOption("hl2");
addOption("hlc3");
addOption("ohlc4");
setDefault("close");
}
aFPArray[x] = new FunctionParameter( "Period", FunctionParameter.NUMBER);
with( aFPArray[x] ) {
setName( "Hull MA Period" );
setLowerLimit( 2 );
setUpperLimit( 9999 );
setDefault( 13 );
}
x++;
aFPArray[x] = new FunctionParameter( "Price", FunctionParameter.STRING);
with( aFPArray[x] ) {
setName( "Hull MA Price Source" );
addOption( "close" );
addOption( "open" );
addOption( "high" );
addOption( "low" );
addOption( "hl2" );
addOption( "hlc3" );
addOption( "ohlc4" );
setDefault( "close" );
}
x++;
aFPArray[x] = new FunctionParameter( "UpColor", FunctionParameter.COLOR);
with( aFPArray[x] ) {
setName( "Up Color" );
setDefault( Color.green );
}
x++;
aFPArray[x] = new FunctionParameter( "DnColor", FunctionParameter.COLOR);
with( aFPArray[x] ) {
setName( "Dn Color" );
setDefault( Color.red );
}
/* x++;
aFPArray[x] = new FunctionParameter( "Type", FunctionParameter.STRING);
with( aFPArray[x] ) {
setName( "Plot Type" );
addOption( "Solid" );
addOption( "Dot" );
addOption( "Dash" );
addOption( "DashDot" );
addOption( "DashDotDot" );
setDefault( "Solid" );
}
x++;
aFPArray[x] = new FunctionParameter( "Thickness", FunctionParameter.NUMBER);
with( aFPArray[x] ) {
setName( "Plot Thickness" );
setLowerLimit( 1 );
setUpperLimit( 10 );
setDefault( 3 );
}
*/
}
var bInit = false;
var SA = null;
var x1 = null;
var CA = null;
var CA1 = null;
var vLastxAlert=-1;
function main(Length, Source, Period, Price, UpColor, DnColor ){
var K = 0
if(bInit==false){
setCursorLabelName("HMA-" + Period, 1);
// setStudyTitle("Hull MA" + Period);
SA = sma(Length,eval(Source)());
x1 = efsInternal("StdDev",Length,eval(Source)())
nSrc = eval( Price )();
nStudy1 = efsInternal( "custSeriesFunc", Period, nSrc );
nStudy2 = wma( Math.floor( Math.sqrt( Period ) ), nStudy1 );
bInit=true;
}
if(SA.getValue(-Length)==null) return;
if(getBarState()==BARSTATE_NEWBAR){
CA1 = CA;
nPlot_1 = nPlot;
nBarCounter++;
}
var v1 = Math.pow(x1.getValue(0),2)
var v2 = Math.pow((CA1-SA.getValue(0)),2)
if (v2<v1){
K=0
}else{
K=1-v1/v2;
CA=CA1+K*(SA.getValue(0)-CA1);
}
nPlot = nStudy2.getValue(0);
if ( nPlot>nPlot_1 ) {
setBarFgColor( UpColor, 1 );
setDefaultBarFgColor( UpColor, 1 );
}
if ( nPlot<nPlot_1 ) {
setBarFgColor( DnColor, 1 );
setDefaultBarFgColor( DnColor, 1 );
}
if (CA > nPlot) {
setBarBgColor(Color.RGB(255,180,180),0,nPlot,CA);
/* if (vLastxAlert != 1) {
Alert.addToList(getSymbol(),getInterval() + " , CA and HA cross down at " + close(), Color.RGB(0,0,0), Color.RGB(255,0,0));
Alert.playSound("Chime Down.wav");
vLastxAlert = 1;
}
*/
} else if (CA < nPlot) {
setBarBgColor(Color.RGB(180,255,180),0,nPlot,CA);
/* if (vLastxAlert != 2) {
Alert.addToList(getSymbol(),getInterval() + " , CA and HA cross up at " + close(), Color.RGB(0,0,0), Color.RGB(0,0,255));
Alert.playSound("chimes.wav");
vLastxAlert = 2;
}
*/
}
return new Array(CA, nPlot );
}
function StdDev(prd,src){
var sumX = 0;
var sumY = 0;
for (var i=0; i<prd; i++) {
sumX += src.getValue(-i);
sumY += (src.getValue(-i)*src.getValue(-i));
}
var meanX = (sumX/prd);
var stddev = Math.sqrt((sumY/prd)-(meanX*meanX));
return stddev;
}
var _study1 = null;
var _study2 = null;
var bInit = false;
function custSeriesFunc( _len, _src ) {
if ( bInit==false ) {
_study1 = wma( Math.floor( _len/2 ), _src );
_study2 = wma( _len, _src );
bInit = true;
}
return( 2 * _study1.getValue(0)-_study2.getValue(0) );
}
//== gID function assigns unique identifier to graphic/text routines
function gID() {
grID ++;
return( grID );
}
Comment