Announcement

Collapse
No announcement yet.

Referring to previous value in custom price action study.

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

  • Referring to previous value in custom price action study.

    Can someone please help me quickly as i am finding esignal efs more and more frustrating. I have searched many posts on this forum as well as google but still can't comprehend this simple problem. I think other questions have been asked about this but they seem to refer more to esignal price studies which it is easy to refer to previous value.

    Lets say i have custom price study:
    e.g.

    var longLow = null;

    if (low(0) < low(-1)) &&
    (low(0) < low(-2)) &&
    (low(0) < low(-3))

    longLow = low(0); // Hence all i am doing is storing this variable.

    Now lets assume all my entry conditions were met once again (lets say 30 bars later - assuming 1 min intraday bars), then how do i refer back to longLow(-1).

    I am finding it impossible to get the value of longLow(-1) as it is a custom variable based on a custom price study. The strategy i am currently working on has on average 5 signals per day. However, each new signal requires the values of the previous signal.

    Please help anyone.

    Thankyou

  • #2
    Can anyone please help - i have searched past links again and whenever a thread re-directs to a previous knowledge based article the link is broken and never works.

    I know this should be pretty easy so can someone please help me out.

    Comment


    • #3
      I have not implemented exactly your issue but I suggest you refer to java script documentation and look at the push function and maybe something like this would work...


      var longLowSave = []; //this declares a new array
      longLowSave.push(longLow); //this pushes the current longLow value into the array

      var longLowLast = longLowSave[1]; //where the 1 is the last element of the array, could be any number to retrieve older values



      I am sure there are other ways of doing this...

      Originally posted by kingmins View Post
      Can someone please help me quickly as i am finding esignal efs more and more frustrating. I have searched many posts on this forum as well as google but still can't comprehend this simple problem. I think other questions have been asked about this but they seem to refer more to esignal price studies which it is easy to refer to previous value.

      Lets say i have custom price study:
      e.g.

      var longLow = null;

      if (low(0) < low(-1)) &&
      (low(0) < low(-2)) &&
      (low(0) < low(-3))

      longLow = low(0); // Hence all i am doing is storing this variable.

      Now lets assume all my entry conditions were met once again (lets say 30 bars later - assuming 1 min intraday bars), then how do i refer back to longLow(-1).

      I am finding it impossible to get the value of longLow(-1) as it is a custom variable based on a custom price study. The strategy i am currently working on has on average 5 signals per day. However, each new signal requires the values of the previous signal.

      Please help anyone.

      Thankyou
      ....Mike

      Comment


      • #4
        Hi Mike, thanks for the reply.

        I just tried this but in debugPrintln - it says longLowLast is undefined and i still can't get a value for it.

        Any help?

        Comment


        • #5
          I just checked java script documentation and the push method adds an element to the back of an array.
          The method that inserts and removes an element into the front of an array is shift and unshift.

          If you append your non working code I might get something to work. It has been a long time since I played with this stuff.



          So maybe the following, notice square brackets in first declaration and for the array to have any elements there must have been at least one value unshifted in...

          var longLowSave = []; //this declares a new array

          longLowSave.unshift(longLow); //this places the current longLow value into the front of the array

          var longLowLast = longLowSave.shift(); //returns the first element of the array and removes it from the array
          ....Mike

          Comment


          • #6
            Try this code snippet to see if it fits your needs:
            PHP Code:
            debugClear();
            var 
            a_longLow = new Array(5); // I would limit the length of the array to the # you need stored.
            var b_longLow = []; // alternative example in case you need all the values
            var ArrCtr=0;
            function 
            main(){
                if (
            low(0) < low(-1) &&
                
            low(0) < low(-2) &&
                
            low(0) < low(-3)){
                    
            a_longLow.push(low(0)); // adds array element to end of array increasing array length by 1 
                    
            a_longLow.shift(); // returns and removes first array element keeping the array length at 5 elements 
                    
            b_longLow[ArrCtr]=low(0);
                    
            ArrCtr++;
                    
            //alternatively you can limit the array size of "b_longLow" by resetting "ArrCtr" to 0 when it reaches the desired length.  To do this just uncomment the next line
                    //if(ArrCtr >= 5) ArrCtr = 0;
                

                
                
            debugPrintln("a: "+a_longLow); //array length = 5 
                
            debugPrintln("b: "+b_longLow);//array length = continuous/indefinite

            Comment


            • #7
              Hey guys, Mike and Waynecd want to thank you very much. Finally got this working and it will help me with my efs immeasurably.

              Cheers lads.

              Kind Regards
              kingmins

              Comment

              Working...
              X