Announcement

Collapse
No announcement yet.

MA Study

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

  • MA Study

    The following EFS does not give a syntax error but when I put it in a chart it gives me an error that says, "C:/Users/Robert/Documents/Interactive Data/Formulas/My Formulas/17EMA-50MA.efs, line 54: Error: Failed to call 'MAStudy': parameter # 1 is invalid.". I am trying to subtract the difference between an exponential moving average and a simple moving average and put it on a chart as a histogram oscillator

    var vLastAlert = -1;




    function preMain() {

    setPriceStudy(false);
    setStudyTitle("MAxDiff");
    setCursorLabelName("Diff", 0);
    setCursorLabelName("Ave", 1);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarStyle(PS_SOLID, 1);
    setDefaultBarFgColor(Color.red, 0);
    setDefaultBarFgColor(Color.blue, 1);
    setDefaultBarThickness(1, 0);
    setDefaultBarThickness(1, 1);
    setPlotType(PLOTTYPE_LINE, 0);
    setPlotType(PLOTTYPE_LINE, 1);

    addBand(0, PS_SOLID, 2, Color.black)

    }




    function main(vEMA, vSMA, vAve) {

    if (vEMA == null) vEMA = 250 ;
    if (vSMA == null) vSMA = 625;
    if (vAve == null) vAve = 100;


    var vEMA = new MAStudy(vEMA, 0, "Close", MAStudy.EXPONENTIAL);
    var vSMA = new MAStudy(vSMA, 0, "Close", MAStudy.SIMPLE);


    var vIntEfs = efsInternal("Diff",vEMA, vSMA);
    var vDiff = getSeries(vIntEfs,0);
    var vDiffAve = sma(vAve,getSeries(vDiff),0);





    return new Array(
    vEMA.getValue(MAStudy.MA) - vSMA.getValue(MAStudy.MA),
    vDiffAve
    );

    }




    function Diff(veMA, vsMA){
    var vEMA = new MAStudy(veMA, 0, "Close", MAStudy.EXPONENTIAL);
    var vSMA = new MAStudy(vsMA, 0, "Close", MAStudy.SIMPLE);
    return new Array (vEMA.getValue(MAStudy.MA) - vSMA.getValue(MAStudy.MA), 0);
    }







    function postMain() {

    }




    function onAction1() {
    vLastAlert = 1;
    }
Working...
X