Announcement

Collapse
No announcement yet.

study: historical bars

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

  • study: historical bars

    Hi,

    please see function below for details. What I am trying to do is compare the relative distances between ADX, PDI and NDI and apply some buy/sell rules based on the results.

    I would like 5 previous bars of data for ADX, PDI and NDI. What is the syntax for grabbing and referencing these bars? If I can print them to the debug window that will be sufficient and I can plod on my merry way. Thanks for your help.

    Regards,

    Sal

    var study = new ADXDMStudy(14, 14);

    function preMain() {
    setDefaultBarFgColor(Color.white, 0); // ADX
    setDefaultBarFgColor(Color.lightyellow, 1); // PDI
    setDefaultBarFgColor(Color.black, 2); // NDI

    }

    var BarCntr = 0;
    function main() {
    var vADX = study.getValue(ADXDMStudy.ADX);
    var vPDI = study.getValue(ADXDMStudy.PDI);
    var vNDI = study.getValue(ADXDMStudy.NDI);


    debugPrintln("vNDI Historical values: " + vNDI(0) + " , " + vNDI(-1) + " , " .... etc );

    return new Array(vADX, vPDI, vNDI);
    }

  • #2
    Hello salska,

    In our Help Examples forum in the EFS Library and Discussion Board, you will find two help formulas that will demonstrate two different ways to accomplish your task.

    RefUsage2.efs uses the ref() function to access the historical bar's returned data.

    CustomFuncRef.efs will show you how to store your values in an array so that you can refer to the historical bar's data.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment

    Working...
    X