Announcement

Collapse
No announcement yet.

Retrieving high() & low() values from different intervals

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

  • Retrieving high() & low() values from different intervals

    Hi,

    In this efs I’d like to select the symbol and interval so that it plots the “high(0), low(0), high(-1), low(-1)” on a chart. The issue is that I get null values when I add the “capability” to select a different symbol and interval than that displayed on the chart. In other words, I’d like to display say, above values from a 3 min chart onto a 55T chart.

    The attached efs is my original modification using the charts own symbol and interval and it works fine. The following code returns the null values.
    PHP Code:
    /******************************************************************************************
    Copyright © eSignal, a division of Interactive Data Corporation. 2005. All rights reserved.
    This sample eSignal Formula Script (EFS) may be modified and saved under a new filename;   
    however, eSignal is no longer responsible for the functionality once modified.             
    eSignal reserves the right to modify and overwrite this EFS file with each new release.    
    @version 3.0 by Alexis Montenegro for eSignal                                              
    *******************************************************************************************/
    //20080810, ADDED MENU ITEMS AND OTHER FORMULAS
    debugClear();
    var 
    aFPArray            = new Array();

    function 
    preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("High-Low(-1) or High-Low(0) Text1-mgn.efs");
        
    setCursorLabelName("TO");
        
    setShowCursorLabel(false); 
        
    setShowTitleParametersfalse ); 

    var 
    x=0;
        
    aFPArray[x] = new FunctionParameter("vSymbol"FunctionParameter.STRING);
        
    with(aFPArray[x++]){
            
    setDefault();
        }
        
    aFPArray[x] = new FunctionParameter"Interval0"FunctionParameter.String); 
        
    withaFPArray[x++] ) { 
            
    setName"MA1 Interval" ); 
            
    addOption"55T" ); 
            
    addOption"233T" ); 
            
    addOption"512T" ); 
            
    addOption"1" );
            
    addOption"3" );
            
    addOption"10" );
            
    addOption"15" );
            
    addOption"30" );
            
    addOption"60" );
            
    addOption"120" );
            
    addOption"240" );
            
    addOption"D" );
            
    addOption"W" );
            
    addOption"M" );
            
    addOption"Default" );
            
    setDefault"Default" ); 
        }   
        
    aFPArray[x] = new FunctionParameter"vDisplay"FunctionParameter.STRING);
        
    withaFPArray[x++] ) {
            
    setName"Bars to Display" );
            
    addOption"High(0)/low(0)" ); 
            
    addOption"High(-1)/low(-1)" ); 
            
    addOption"Both" ); 
            
    setDefault"Both" );
        }  
        
    aFPArray[x] = new FunctionParameter"vDispWhere"FunctionParameter.STRING);
        
    withaFPArray[x++] ) {
            
    setName"Text Placement" );
            
    addOption"Top Margin" ); 
            
    addOption"By Price" ); 
            
    addOption"Both" ); 
            
    setDefault"Both" );
        }  
        
    aFPArray[x] = new FunctionParameter"vOffset"FunctionParameter.NUMBER);
        
    withaFPArray[x++] ) {
            
    setName"Text Offset" );
            
    setLowerLimit);
            
    setUpperLimit20 );
            
    addOption); 
            
    addOption); 
            
    addOption); 
            
    addOption); 
            
    addOption); 
            
    addOption); 
            
    addOption); 
            
    addOption); 
            
    setDefault);
        }  
        
    aFPArray[x] = new FunctionParameter"vFontSize"FunctionParameter.NUMBER);
        
    withaFPArray[x++] ) {
            
    setName"Font Size" );
            
    addOption); 
            
    addOption); 
            
    addOption10 ); 
            
    addOption11 ); 
            
    addOption12 ); 
            
    setDefault10 );
        }  
        
    aFPArray[x] = new FunctionParameter"vFontColor1"FunctionParameter.COLOR);
        
    withaFPArray[x++] ) {
            
    setName"Text Color High" );
            
    setDefaultColor.blue );
        }  
        
    aFPArray[x] = new FunctionParameter"vFontColor2"FunctionParameter.COLOR);
        
    withaFPArray[x++] ) {
            
    setName"Text Color Low" );
            
    setDefaultColor.red );
        }  
        
    aFPArray[x] = new FunctionParameter"DisplayDarkLabel"FunctionParameter.BOOLEAN); 
        
    withaFPArray[x++] ) { 
            
    setName"Display Dark Price" ); 
            
    setDefaultfalse ); 
        }       
        
    aFPArray[x] = new FunctionParameter"vRndTo25"FunctionParameter.BOOLEAN); 
        
    withaFPArray[x++] ) { 
            
    setName"Round to 0,25" ); 
            
    setDefaulttrue ); 
        }       
    }

    var 
    bInit false;
    var 
    vAvgBar6 null;
    var 
    vIntHigh null;
    var 
    vIntLow null;
    var 
    vHigh1 0;
    var 
    vLow1 =0;

    function 
    main(vSymbol,Interval0,vDisplay,vDispWhere,vOffset,vFontSize,vFontColor1,
                  
    vFontColor2,DisplayDarkLabel,vRndTo25) {
        
    //    if(isMonthly() || isWeekly() || isDaily())
     //   return;
        
        
    if(bInit == false){
            var 
    vSymbol getSymbol();
            if(
    Interval0 == "Default" || Interval0 == nullInterval0 getInterval();
            var 
    xSymbol "\""+vSymbol+","+Interval0+"\"";
            
    vIntHigh high(sym(xSymbol));
            
    vIntLow low(sym(xSymbol));
            
    bInit true;
    //debugPrintln(xSymbol);
    debugPrintln(vIntHigh);
        }

        var 
    vHigh vIntHigh.getValue(0);// getValue("High", 0,1, xSymbol);
        
    var vLow vIntLow.getValue(0);// getValue("Low", 0, 1,xSymbol);
    //debugPrintln(vHigh);
     

        
    if (!vRndTo25){
            
    vHighTxt rnd(vHigh,2);
            
    vLowTxt rnd(vLow,2);
            
    vHigh1Txt rnd(vHigh1,2);
            
    vLow1Txt rnd(vLow1,2);
        }else if (
    vRndTo25){
            
    vHighTxt rnd25(vHigh);
            
    vLowTxt rnd25(vLow);
            
    vHigh1Txt rnd25(vHigh1);
            
    vLow1Txt rnd25(vLow1);
        }
        if (
    getBarState() == BARSTATE_NEWBAR){
            
    vHigh1 vHigh;
            
    vLow1 vLow ;
        }
    var 
    vHigh1Txt+" High (0)";
    var 
    vLen1High h.length;
    var 
    vLow1Txt+" High (0)";
    var 
    vLen1Low l.length;
    var 
    vDistance Math.max(vLen1High,vLen1Low);

    if(
    DisplayDarkLabel){
    var 
    vx1 Color.black;
    var 
    vx2 Color.black;
    var 
    vx3 Color.RGB(192,192,192);
    var 
    rd1 5;
    var 
    rd2 21
    }else{
    var 
    vx1 vFontColor1;
    var 
    vx2 vFontColor2;
    var 
    vx3 "null"
    var rd1 5;
    var 
    rd2 18
    }

            if(
    vDisplay == "High(0)/low(0)"){
                if(
    vDispWhere == "By Price" || vDispWhere == "Both"){
                    
    drawTextAbsolute(vOffsethigh(0), "-- "+vHighTxt+" High (0)", eval(vx1), eval(vx3), Text.LEFT|Text.VCENTER"Arial"vFontSize"textH0");
                    
    drawTextAbsolute(vOffsethigh(0)-.5"-- "+vLowTxt+" Low (0)", eval(vx2), eval(vx3), Text.LEFT|Text.VCENTER"Arial"vFontSize"textL0");
                }if(
    vDispWhere == "Top Margin" || vDispWhere == "Both"){
                    
    drawTextRelative( -1rd1vHighTxt+" High (0)", eval(vx1), eval(vx3), Text.VCENTER Text.RELATIVETOTOPnullvFontSize"textH0a" );
                    
    drawTextRelative( -1rd2vLowTxt+" Low (0)", eval(vx2), eval(vx3), Text.VCENTER Text.RELATIVETOTOPnullvFontSize"textL0a" ); 
                }
            }else if(
    vDisplay == "High(-1)/low(-1)"){
                if(
    vDispWhere == "By Price" || vDispWhere == "Both"){
                    
    drawTextAbsolute(vOffsethigh(-1), "-- "+vHigh1Txt+" High (-1)", eval(vx1), eval(vx3), Text.LEFT|Text.VCENTER"Arial"vFontSize"textH1");
                    
    drawTextAbsolute(vOffsethigh(-1)-.5"-- "+vLow1Txt+" Low (-1)", eval(vx2), eval(vx3), Text.LEFT|Text.VCENTER"Arial"vFontSize"textL1");
                }if(
    vDispWhere == "Top Margin" || vDispWhere == "Both"){
                    
    drawTextRelative( -1rd1vHigh1Txt+" High (-1)", eval(vx1), eval(vx3), Text.VCENTER Text.RELATIVETOTOPnullvFontSize"textH1a" );
                    
    drawTextRelative( -1rd2vLow1Txt+" Low (-1)", eval(vx2), eval(vx3), Text.VCENTER Text.RELATIVETOTOPnullvFontSize"textL1a" ); 
                }
            }else if(
    vDisplay == "Both"){
                if(
    vDispWhere == "By Price" || vDispWhere == "Both"){
                    
    drawTextAbsolute(vDistancehigh(0), "-- "+vHighTxt+" High (0)", eval(vx1), eval(vx3), Text.LEFT|Text.VCENTER"Arial"vFontSize"textH2");
                    
    drawTextAbsolute(vDistancehigh(0)-.5"-- "+vLowTxt+" Low (0)", eval(vx2), eval(vx3), Text.LEFT|Text.VCENTER"Arial"vFontSize"textL2");
                    
    drawTextAbsolute(vOffsethigh(0), "-- "+vHigh1Txt+" High (-1)", eval(vx1), eval(vx3), Text.LEFT|Text.VCENTER"Arial"vFontSize"textH3");
                    
    drawTextAbsolute(vOffsethigh(0)-.5,"-- "+vLow1Txt+" Low (-1)", eval(vx2), eval(vx3), Text.LEFT|Text.VCENTER"Arial"vFontSize"textL3");
                }if(
    vDispWhere == "Top Margin" || vDispWhere == "Both"){
                    
    drawTextRelativevDistance-3rd1vHighTxt+" High (0)", eval(vx1), eval(vx3), Text.VCENTER Text.RELATIVETOTOPnullvFontSize"textH4" );
                    
    drawTextRelativevDistance-3rd2vLowTxt+" Low (0)", eval(vx2), eval(vx3), Text.VCENTER Text.RELATIVETOTOPnullvFontSize"textL4" ); 
                    
    drawTextRelative( -1rd1vHigh1Txt+" High (-1)", eval(vx1), eval(vx3), Text.VCENTER Text.RELATIVETOTOPnullvFontSize"textH4a" );
                    
    drawTextRelative( -1rd2vLow1Txt+" Low (-1)", eval(vx2), eval(vx3), Text.VCENTER Text.RELATIVETOTOPnullvFontSize"textL4a" ); 
                }
            }
            else return;

        return;
    }
    //ROUNDING FUNCTION
    function rnd(valueN) {   //N = round to N # of digits
        
    var n;
        var 
    mult=1;
        for(
    n=0;n<N;n++) mult*=10;
        
    value*=mult;
        return 
    Math.roundvalue,N)/mult;
    }   
    function 
    rnd25(yValue){    // Round to nearest 0.25
    if(yValue%0.25<0.125)
        
    y=yValue-yValue%0.25
    else
        
    y=(yValue-yValue%0.25+0.25)
        
    return 
    y;
    }
    /*    for(var i=0; i<7; i++) {
            xHigh = high(-i)
            xLow = low(-i)
            Sum1 = (xHigh+xLow)/2;
            Sum2 += Sum1;
        }*/ 
    Any help is greatly appreciated.

    Wayne.
    Attached Files
    Last edited by waynecd; 08-12-2008, 09:54 PM.

  • #2
    Got it.

    I needed to use eval() for:
    vIntHigh = high(sym(eval(xSymbol)));
    vIntLow = low(sym(eval(xSymbol)));


    The code is attached.
    Attached Files

    Comment

    Working...
    X