Announcement

Collapse
No announcement yet.

Passing data to the MA function

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

  • Passing data to the MA function

    Hello,

    I am trying to use (OHLC)/4 as the data to be averaged. In lines 31-40 I calculate the OHLC average. Then in line 42 I try to pass that average (vAvg) to the MAStudy.

    The error message reads that param 3 (vAvg) is invalid. - In Rev B of this indicator I used "close", which works fine.

    QUESTION:
    How do I pass the vAvg = (OHLC/4) to the MAStudy?

    Thank You in Advance,

    Ed Hoopes
    [email protected]


    /************************************************** **************************************************
    Author: EAH
    Date: Apr 2004
    Revision: C
    Name: LLag Mov Avg set up as a function TO BE CALLED from Adaptive Moving Average
    Fix logic errors Dec 28, 2003
    Rev C: Added OHLC/4 to further smooth the LLMA
    ************************************************** ************************************************** */


    function preMain() {
    debugClear();
    checkVersion(2,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/MAofMA.efs");

    }

    //*** Global Vars Go Here;

    var vMA = null;
    var vMA_Val = null;
    var vMAofMA = null;
    var vMAofMA_Val = null;
    var vLLMA = null;
    var vMADiff = null;


    //*** End of Global Vars;

    function main(MALength,vPers) {

    //*** Local Vars Go Here;

    var vOpen = open();
    var vClose = close();
    var vHigh = high();
    var vLow = low();

    var vAvg = (vOpen + vClose + vHigh + vLow );

    //*** End of Local Vars;

    if (vMA == null) vMA = new MAStudy(MALength, 0, vAvg, MAStudy.EXPONENTIAL);
    if (vMAofMA == null) vMAofMA = new MAStudy(MALength, 0, vMA, MAStudy.MA, MAStudy.SIMPLE);

    //debugPrintln("vMA = " + vMA.getValue(MAStudy.MA) + "\n");
    //debugPrintln("vMAofMA = " + vMAofMA.getValue(MAStudy.MA) + "\n");

    var vMA_Val = vMA.getValue(MAStudy.MA,vPers);
    var vMAofMA_Val = vMAofMA.getValue(MAStudy.MA,vPers);

    //Exit MAIN until we get valid returns for all the required inputs;
    if(vMA_Val == null || vMAofMA_Val == null ) return;

    //debugPrintln("vMA_Val = " + vMA_Val);
    //debugPrintln("vMAofMA_Val = " + vMAofMA_Val + "\n");

    vMADiff = vMA_Val - vMAofMA_Val;
    vLLMA = vMA_Val + vMADiff;

    //debugPrintln("vLLMA = " + vLLMA + "\n");

    return vLLMA;

    }

  • #2
    Ed
    I think it should work just using var vAvg="OHLC/4";
    Alex

    Comment

    Working...
    X