Announcement

Collapse
No announcement yet.

Hull or KAMA

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hull or KAMA

    Chris, I've been using an MA crossover with your Hull MA script. (also playing with the KAMA.) I was wondering if you or anyone else had done a MACD using KAMA or Hull Ma?

  • #2
    Well, I took a stab at it and missed a thing or two. Would appreciate some help.



    /************************************************** ******************
    MACD using HULL MAs
    Modified from original script by Chris Kryza

    Title: Hull MA Script for eSignal 7.x
    By: Chris D. Kryza (Divergence Software, Inc.)
    Email: [email protected]; [email protected]
    Incept: 01/13/2006
    Version: 1.0.0

    ************************************************** ********************/

    debugClear()

    //External Variables
    var nBarCounter = 0;
    var nStudy1 = null;
    var nStudy2 = null;
    var nPlot = null;
    var nPlot_1 = null;
    var aFPArray = new Array();
    var bInitialized = false;
    var Period = 30;

    //== PreMain function required by eSignal to set things up
    function preMain() {
    var x;

    setPriceStudy(false);
    setStudyTitle("Hull MACD");
    setCursorLabelName("Hull MACD", 0);
    setDefaultBarFgColor( Color.blue, 0 );
    setShowTitleParameters( false );


    //initialize formula parameters
    x=0;
    aFPArray[x] = new FunctionParameter( "f_Period", FunctionParameter.NUMBER);
    with( aFPArray[x] ) {
    setName( "Hull fast MA Period" );
    setLowerLimit( 2 );
    setUpperLimit( 9999 );
    setDefault( 13 );
    }
    x++;
    aFPArray[x] = new FunctionParameter( "s_Period", FunctionParameter.NUMBER);
    with( aFPArray[x] ) {
    setName( "Hull slow MA Period" );
    setLowerLimit( 2 );
    setUpperLimit( 9999 );
    setDefault( 39 );
    }
    x++;
    aFPArray[x] = new FunctionParameter( "Signal", FunctionParameter.NUMBER);
    with( aFPArray[x] ) {
    setName( "Signal Length" );
    setLowerLimit( 2 );
    setUpperLimit( 9999 );
    setDefault( 9 );
    }
    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" );
    }

    }


    //== Main processing function
    function main( f_Period, s_Period, Signal, Price) {

    var x;

    //script is initializing
    if ( getBarState() == BARSTATE_ALLBARS ) {
    return null;
    }

    if ( bInitialized == false ) {

    nSrc = eval( Price )();
    Period = f_Period;
    f_Study1 = efsInternal( "custSeriesFunc", Period, nSrc );
    f_Study2 = wma( Math.floor( Math.sqrt( Period ) ), nStudy1 );
    Period = s_Period;
    s_Study1 = efsInternal( "custSeriesFunc", Period, nSrc );
    s_Study2 = wma( Math.floor( Math.sqrt( Period ) ), nStudy1 );

    bInitialized = true;
    }

    //called on each new bar
    if ( getBarState() == BARSTATE_NEWBAR ) {

    fPlot_1 = fPlot;
    sPlot_1 = sPlot;
    nBarCounter++;
    }

    fPlot = f_Study2.getValue(0);
    sPlot = f_Stdud2.getValue(0);

    /*****
    if ( nPlot>nPlot_1 ) {
    setBarFgColor( UpColor, 0 );
    }
    if ( nPlot<nPlot_1 ) {
    setBarFgColor( DnColor, 0 );
    }
    ******/

    nPlot = sPlot - fPlot;


    return( nPlot );

    }


    /*************************************************
    SUPPORT FUNCTIONS
    **************************************************/

    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


    • #3
      MACD using Hull MA

      changed a few things still not working.

      --------------------------------------------------------------
      PHP Code:
      /********************************************************************
          MACD using HULL MAs
          Modified from original script by Chris Kryza

      Title:        Hull MA Script for eSignal 7.x
      By:         Chris D. Kryza (Divergence Software, Inc.)
      Email:      [email][email protected][/email]; [email][email protected][/email]
      Incept:     01/13/2006
      Version:    1.0.0

      **********************************************************************/

      debugClear()

      //External Variables
      var nBarCounter            0;
      var 
      nStudy1                null;
      var 
      nStudy2                null;
      var 
      fPlot               null;
      var 
      fPlot_1             null;
      var 
      sPlot               null;
      var 
      sPlot_1             null;
      var 
      aMACD                = new Array();
      var 
      aSignal             = new Array();
      var 
      aFPArray            = new Array();
      var 
      bInitialized        false;
      var 
      Period              30;

      //== PreMain function required by eSignal to set things up
      function preMain() {
      var 
      x;

          
      setPriceStudy(false);
          
      setStudyTitle("Hull MACD");
          
      setCursorLabelName("Hull MACD"0);
          
      setDefaultBarFgColorColor.blue);
          
      setShowTitleParametersfalse );

          
          
      //initialize formula parameters
          
      x=0
          
      aFPArray[x] = new FunctionParameter"f_Period"FunctionParameter.NUMBER);
          
      withaFPArray[x] ) {
              
      setName"Hull fast MA Period" );
              
      setLowerLimit);
              
      setUpperLimit9999 );
              
      setDefault13 );
          }
          
      x++;
          
      aFPArray[x] = new FunctionParameter"s_Period"FunctionParameter.NUMBER);
          
      withaFPArray[x] ) {
              
      setName"Hull slow MA Period" );
              
      setLowerLimit);
              
      setUpperLimit9999 );
              
      setDefault39 );
          }
          
      x++;
          
      aFPArray[x] = new FunctionParameter"nLen"FunctionParameter.NUMBER);
          
      withaFPArray[x] ) {
              
      setName"Signal Length" );
              
      setLowerLimit);
              
      setUpperLimit9999 );
              
      setDefault);
          }  
          
      x++;
          
      aFPArray[x] = new FunctionParameter"Price"FunctionParameter.STRING);
          
      withaFPArray[x] ) {
              
      setName"Hull MA Price Source" );
              
      addOption"close" );
              
      addOption"open" );        
              
      addOption"high" );
              
      addOption"low" );
              
      addOption"hl2" );
              
      addOption"hlc3" );
              
      addOption"ohlc4" );
              
      setDefault"close" );
          }

      }


      //== Main processing function
      function mainf_Periods_PeriodnLenPrice) {
       
      var 
      x;
          
          
      //script is initializing
          
      if ( getBarState() == BARSTATE_ALLBARS ) {
              return 
      null;
          }

          if ( 
      bInitialized == false ) {
          
              
      nSrc = eval( Price )();
              
      Period f_Period;
              
      f_Study1 efsInternal"custSeriesFunc"PeriodnSrc );
              
      f_Study2 wmaMath.floorMath.sqrtPeriod ) ), nStudy1 );
              
      fPlot f_Study2.getValue(0);
              
              
      Period s_Period;
              
      s_Study1 efsInternal"custSeriesFunc"PeriodnSrc );
              
      s_Study2 wmaMath.floorMath.sqrtPeriod ) ), nStudy1 );
              
      sPlot s_Study2.getValue(0);
              
              
      bInitialized true;
          }

          
      //called on each new bar
          
      if ( getBarState() == BARSTATE_NEWBAR ) {
              
              
      fPlot_1 fPlot;
              
      sPlot_1 sPlot;    
              
      nBarCounter++;
          }
          
          
      /*****    
          if ( nPlot>nPlot_1 ) {
              setBarFgColor( UpColor, 0 );    
          }
          if ( nPlot<nPlot_1 ) {
              setBarFgColor( DnColor, 0 );
          }
      ******/

          
      aMACD sPlot fPlot;
          
      aSignal ema(nLenaMACD
          
          return new array ( 
      aMACD.getValue(0), aSignal.getValue(0) );

      }


      /*************************************************
                   SUPPORT FUNCTIONS                    
      **************************************************/    

      var _study1 null;
      var 
      _study2 null;
      var 
      bInit false;
      function 
      custSeriesFunc_len_src ) {

          if ( 
      bInit==false ) {
              
      _study1 wmaMath.floor_len/), _src );
              
      _study2 wma_len_src );
              
      bInit true;
          }
          
          return( 
      _study1.getValue(0)-_study2.getValue(0) );
          
      }
          
      //== gID function assigns unique identifier to graphic/text routines
      function gID() {
          
      grID ++;
          return( 
      grID );

      Last edited by pj909; 10-24-2008, 09:42 AM.

      Comment

      Working...
      X