Announcement

Collapse
No announcement yet.

How to get the last x# of highs from a different symbol/interval from the charts

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

  • How to get the last x# of highs from a different symbol/interval from the charts

    The code -getValue("High",0,-5);- retrieves the last 5 highs of the charts symbol and interval.
    But there doesn’t seem to be a way to get those same values for a different symbol and/or interval.

    For example: using -sym(“symbol, interval”)-
    The code below outputs:

    1168.75,1168.75,1169,1169,1169 -v- 1168.75 -x

    Where - getValue("High",0,-5);- outputs five values but high(0,-5, sym(xSymbol));- outputs only one (see debugPrint in the code below).

    Article # 1068 of the knowledge base has the syntax for high() as - high([nRelativeOffset] [, nNumBars [, Symbol ] ])- where nNumBars: Number of bars to retrieve (a negative number) with the example:
    -high(0, -10, "INTC"); gets the last 10 highs for INTC and places them in an array-

    PHP Code:
    var bInit false;
    var 
    xSymbol null;
    var 
    vSymbol null;
    var 
    Interval0 3;

    function 
    main(){
        if(
    bInit == false){
            if(
    vSymbol == null || vSymbol == ""vSymbol getSymbol();
            if(
    Interval0 == "Default" || Interval0 == nullInterval0 getInterval();
            
    xSymbol vSymbol+","+Interval0;
            
    bInit true;
        }

        var 
    vHigh getValue("High",0,-5);
        var 
    xHigh high(0,-5sym(xSymbol));
    debugPrintln(vHigh+" -v- "+xHigh+" -x");


    Thanks in advance.

    Wayne
    Last edited by waynecd; 03-31-2010, 12:11 PM.

  • #2
    The only way I've been able to retrieve the last few highs of the higher interval (3 min) on a lower interval chart (100T) was via efsInternal as demonstrated by the variable -zzHigh- below.
    I don't know if it is there is a better way but this will have to do.

    Both -yHigh- and -zHigh- each only return the last high of the external interval. Only the returned efsInternal series -zzHigh- retrieves the last two highs for the external interval correctly.

    the -Formula Output- is:
    --------------------------------
    1170, 1170.25 -zz
    1170,1170.25 -v- 1170,1170.25 -x- 1170 -y
    1170,1170.25 -z
    --------------------------------
    Wayne

    PHP Code:
    var bInit false;
    var 
    xSymbol null;
    var 
    vSymbol null;
    var 
    Interval0 3;

    function 
    main(){
        if(
    bInit == false){
            if(
    vSymbol == null || vSymbol == ""vSymbol getSymbol();
            if(
    Interval0 == "Default" || Interval0 == nullInterval0 getInterval();
            
    xSymbol vSymbol+","+Interval0;
            
    bInit true;
        }

        var 
    vHigh getValue("High",0,-2);
        var 
    xHigh high(0,-2);//, sym(xSymbol));
        
    var yHigh high(0,-2sym(xSymbol));
    debugPrintln(vHigh+" -v- "+xHigh+" -x- "+yHigh+" -y");
        var 
    zzHigh efsInternal("Int_Highs",sym(xSymbol));
    debugPrintln(getSeries(zzHigh,0)+", "+getSeries(zzHigh,1)+" -zz");//only one that returns both values for 3 min interval on a 100T chart

    }
    function 
    Int_Highs(){
        var 
    zHigh high(0,-2);
        
    debugPrintln(zHigh+" -z");
        return 
    zHigh;


    Last edited by waynecd; 04-01-2010, 12:37 AM.

    Comment


    • #3
      Just to close this thread with the correct solution.

      both:
      PHP Code:
          var vHigh high(0,-3,xSymbol);
          
      debugPrintln(vHigh[0]+" -0, "+vHigh[1]+" -1, "+vHigh[2]+" -2 "); 
      and
      PHP Code:
          var vHigh getValue("High",0,-3,xSymbol);
          
      debugPrintln(vHigh[0]+" -0, "+vHigh[1]+" -1, "+vHigh[2]+" -2 "); 
      work fine.

      Can't figure out why they gave me so much trouble.

      Wayne

      Comment

      Working...
      X