Announcement

Collapse
No announcement yet.

ref

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

  • ref

    can I clarify the use of ref() to retrieve previous values for a built-in study?

    In the code below if I return "new Array(vMA1, vMA2, vMA3)" all is ok. But if I return "new Array(vMA1, vMA2)" then myValue3 is undefined.

    For a study that makes use of multiple built-in studies but doesn't want to plot them, do you suggest using functions to get previous values?


    // ref usage

    var study1 = new MAStudy(10, 0, "Close", MAStudy.Simple);
    var study2 = new MAStudy(20, 0, "Close", MAStudy.Simple);
    var study3 = new MAStudy(30, 0, "Close", MAStudy.Simple);

    function preMain() {
    setPriceStudy(true);
    }

    var BarCount = 0;

    function main() {

    var vMA1 = study1.getValue(MAStudy.MA);
    var vMA2 = study2.getValue(MAStudy.MA);
    var vMA3 = study3.getValue(MAStudy.MA);

    if (getBarState() == BARSTATE_NEWBAR) {
    BarCount += 1;
    }

    if (BarCount > 30) {
    var myRef = ref(-1);
    var myValue1 = myRef[0];
    var myValue2 = myRef[1];
    var myValue3 = myRef[2];
    debugPrintln(getCurrentBarIndex() + " " + vMA3 + " " + myValue3);
    }

    return new Array(vMA1, vMA2, vMA3);
    }
    Paul Williams
    Strategy & Applications
    www.futurenets.co.uk

  • #2
    try using arrays...

    Create functions to store the values into ARRAYS. This way, you could access them and update them without having them plot on the chart.

    Refer to the EFS Help file for examples. This should solve your problems..

    Brad
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment

    Working...
    X