Announcement

Collapse
No announcement yet.

EFS output results keep changing

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

  • EFS output results keep changing

    Hi,

    I originally posted this in 'EFS studies' but got no replies, hopefull someone wil be able to help if I post it here:

    I'm using the following code but I'm getting different results everyday. The results are consistent within each day (even when I restart eSignal) but when I start eSignal at the start of a new day then the output data is completely different from that of the previous day.

    My first thought was that this was due to the first day 'dropping out' of my time template so I have been adding one day to the length of the template each morning (so that the start date is always the same) and still get the same problem.

    To make sure that the code is looking at the same data each time I have been noting down the start date and time, the first date and time that an output is returned and the value returned by that output. It is the value of this output which changes everyday even though (as far as I can see) it is taking it's data from identical inputs to the previous day.

    I don't think it matters what product/symbol you look at for this to happen but I have been looking at AT 1!-DT (i.e. Dax).
    Does anyone have any ideas why this is happening as I am at a complete loss? Many thanks in advance.

    The code is as follows:


    var fpArray = new Array();
    var bInit = false;
    var ECO = 0.0;
    var ECOprev = 0.0;

    function preMain() {
    setStudyTitle("XYZ");
    setCursorLabelName("XYZ", 0);
    setDefaultBarFgColor(Color.red, 0);
    addBand(0, PS_SOLID, 1, Color.cyan);

    var x=0;
    fpArray[x] = new FunctionParameter("r", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(300);
    }
    fpArray[x] = new FunctionParameter("s", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(150);
    }
    }

    var xEMA = null;
    var xvEMA = null;
    var LongStop = null;
    var ShortStop = null;

    function main(r, s) {

    var nState = getBarState();

    if (nState == BARSTATE_ALLBARS) {
    if (r == null) r = 300;
    if (s == null) s = 150;
    }

    if ( bInit == false ) {
    xEMA = ema(s, ema(r, efsInternal("CloseOpen")));
    xvEMA = ema(s, ema(r, efsInternal("HighLow")));
    bInit = true;
    }

    if (getCurrentBarCount() < Math.max(r,s)) return;

    if(xvEMA.getValue(0) != 0) {
    ECO = 100 * (xEMA.getValue(0) / xvEMA.getValue(0));
    }

    if(xvEMA.getValue(0) != 0) {
    ECOprev = 100 * (xEMA.getValue(0) / xvEMA.getValue(0));
    }

    if(xvEMA.getValue(0) != 0)

    return 100 * (xEMA.getValue(0) / xvEMA.getValue(0));


    else
    return;
    }

    function CloseOpen() {
    var nRes = 0;
    nRes = close(0) - open(0);
    if (nRes == null) nRes = 1;
    return nRes;
    }

    function HighLow() {
    var nRes = 0;
    nRes = high(0) - low(0);
    if (nRes == null) nRes = 1;
    return nRes;
    }

  • #2
    Hi naples 99,
    sorry at the moment I am not able to help you.
    Please, let me understand what is your goal with these lines of efs:

    xEMA = ema(s, ema(r, efsInternal("CloseOpen")));
    xvEMA = ema(s, ema(r, efsInternal("HighLow")));

    You want the s periods ema of r periods ema of close-open and high-low ?

    Probably the problem could be in the efsInternal functions:

    function CloseOpen() {
    var nRes = 0;
    nRes = close(0) - open(0);
    if (nRes == null) nRes = 1;
    return nRes;
    }

    function HighLow() {
    var nRes = 0;
    nRes = high(0) - low(0);
    if (nRes == null) nRes = 1;
    return nRes;
    }

    Let me know. Happy to learn !
    Bye
    Max

    Comment


    • #3
      Hi maxmax68

      no, problem. Thanks for replying.

      Yes that is exactly what I am trying to achieve (and get).

      And yes, I also think that the problem could be arising in the efsinternal functions but because the code is interrogating the same set of data each day and getting different results each day (even after taking into account adding an extra day to the time template) I am left quite confused.

      Thanks for any help you can give...

      Comment

      Working...
      X