Announcement

Collapse
No announcement yet.

Minimum

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

  • Minimum

    Suppose you already have defined a new function/indicator f which is defined for all unit steps. It may simply be an usual indicator as eg ema(10).
    I try to define a new function g which corresponds to the minimum value of f on a past interval (t-K1,t-K2) where K1 and K2 are defined constants.
    For small values of K1 and K2, it can be done iteratively. But I would like to try to obtain this function g for large values of K1 (typically 200) and values of K2 around 10.
    Is there an easy way to define g analytically?

    Thanks.

  • #2
    I think I understand your requirements??

    You want to define g (which will be the minimum of a unique instance of f)?

    So it sounds like you are creating a function (f) that returns a value and want to then access the "minimum" of f.

    If I understand this correctly, you may have multiple returns of f and thus want to access multiple "minimums" of f - right?

    I'm pretty sure you can do this with "series" function in EFS2, but I would do it as an array because I like working with arrays.

    You would simply store the f returns into an array per bar, then you could scan/identify any "minimum" value returned by any specific "f call".

    You could also reset a series of "fMin" values on the start of a new trading session and track the lowest value identified as you step thru the chart. In RT, you would want to address the END OF BAR f value, then run a Math.min function to identify the minimum.

    The benefit of using the arrays is you can access any minimum from any bar on the chart using lookup functions.

    I'm trying to help, but I'm not sure I understand your needs?
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Precisions

      In fact, f is a function which gives a single scalar for each bar (as eg f=ema(15)). So I have a function f(t) for each time t.
      Now, I'm interested at the function g(0)=min(f(u)), -K1<=u<=-K2 (as 0 is current time)
      We can therefore define g(0) as

      g(0)=f(-K1);
      for u=(-K1+1) to (-K2)
      if f(u)<=g(0) then g(0)=f(u)
      next u;

      or something like that....

      but doesn't there exist an instruction like
      g(t)=applicmin(f(t-K1:t-K2))?
      because I would like to plot f and g on the same graph

      Comment


      • #4
        not that I know of. You have to do it in code/function using Math.min and Math.max functions.

        I assume you know what these are?

        The concept I had for doing it with arrays may be of help to you. A simple way of optimizing arrays is with a simple reset of the Total Array Count.

        PHP Code:
        var arraylimit 100;
        var 
        MyArray = new Array();

        function 
        main()
          var 
        nState getBarState();
          if (
        nState == BARSTATE_NEWBAR) { 
            
        MyArray.push(0);  //  Push a zero into the array.
          
        }

          if (
        MyArray.length >= arraylimit) {
            
        MyArray.shift();
            
        //  remove an item from the beginning of the array
          
        }

          var 
        HighestHigh LLHHn(0,10,1);
          var 
        LowestLow LLHHn(0,10,-1);

        }

        function 
        LLHHn(StartBarLengthDir) {
          
        // Lowest Low/Highest High Function
          //  StartBar = 0 to whatever.  This is like an offset from the current bar BACKWARDS.
          
        var TotalLB = (StartBar Length) ;
          var 
        x0;
          var 
        LL;
                if (
        Dir 0) {   LL 999999999; }
                if (
        Dir 0) {   LL 0; }

           if (
        MyArray.length TotalLB) {
             if (
        StartBar 0) {
               
        = -StartBar;
             }

                while ((
        >= 0) && (> (MyArray.length-TotalLB) ) ) {
                  if (
        Dir 0) {
                    
        LL Math.min(LLMyArray[x]);
                  }
                  if (
        Dir 0) {
                    
        LL Math.max(LLMyArray[x]);
                  }
                  
        x--;
                }
           }

          return 
        LL;


        Hope this helps??
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment

        Working...
        X