Announcement

Collapse
No announcement yet.

return series

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

  • return series

    so i am been using the amVWAP efs by alexis, which is a great resource. I wanted to make a few adjustments

    1) add 2 VWAP lines, one for the overnight session and one for the primary session
    2) (which I have commented out b/c it was using too much CPU) A simple study that alerts if price has been above VWAP for more than XX mins.

    I did this, but now when I run the script, it is a real hog, and using up a lot more resources than the original script. I am sure I am not calling something in the most efficient manner. Can anyone suggest anything..

    in the original code, the return statement is just getSeries(xVWAP) but since I added another plot, I made an array, but to me this seems to be taking up a lot of resouces

    thanks

    see code



    PHP Code:
    var fpArray = new Array();
    var 
    max15;
    var 
    min15;
    var 
    check_xVWAP_l false;
    var 
    check_xVWAP_h false;
    var 
    check_yVWAP_l false;
    var 
    check_yVWAP_h false;
    var 
    time_conditions false;
    var 
    vwap_before_a false;
    var 
    vwap_before_b false;
    var 
    offset null;
    function 
    preMain() {

        
    setPriceStudy(true);
        
    setStudyTitle("VWAP");
        
    setCursorLabelName("VWAP",0);
        
    setCursorLabelName("VWAP1",1);
        
    setDefaultBarFgColor(Color.blue,0);
        
    setDefaultBarFgColor(Color.red,1);
        
    setPlotType(PLOTTYPE_SQUAREWAVE,0);
        
    setDefaultBarThickness(1,0);
        
    //askForInput();
        
        
    var x=0;
        
    fpArray[x] = new FunctionParameter("StartTime"FunctionParameter.STRING);
        
    with(fpArray[x++]){
            
    setName("Start Time");
            
    setDefault(930);
        }
        
    fpArray[x] = new FunctionParameter("StartTime2"FunctionParameter.STRING);
        
    with(fpArray[x++]){
            
    setDefault(200);
          }
              
    fpArray[x] = new FunctionParameter("OffsetTicks"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setDefault(3);
          }
        
    fpArray[x] = new FunctionParameter("xWAVFILE"FunctionParameter.STRING);
        
    with(fpArray[x++]){
            
    setDefault("WARNING.WAV");
          }
          
                    
    fpArray[x] = new FunctionParameter("Symbol"FunctionParameter.STRING);
        
    with(fpArray[x++]){
            
    setDefault();
            }
        
    fpArray[x] = new FunctionParameter("Interval"FunctionParameter.STRING);
        
    with(fpArray[x++]){
            
    setDefault();
        }
        
    fpArray[x] = new FunctionParameter("Params"FunctionParameter.BOOLEAN);
        
    with(fpArray[x++]){
            
    setName("Show Parameters");
            
    setDefault(false);
        }
    }

    var 
    amLib addLibrary("amStudies.efsLib");
    var 
    bInit false
    var xVWAP null;
    var 
    yVWAP null;
    function 
    main(StartTime,Symbol,Interval,Params,StartTime2OffsetTicks,xWAVFILE) {

        if(
    bInit==false){
            
    withamLib 
    {
            if(
    Symbol == nullSymbol getSymbol();
            if(
    Interval == nullInterval getInterval();
            var 
    vSymbol Symbol+","+Interval;
            
    xVWAP amVWAP2(StartTime+"",sym(vSymbol));
            
    yVWAP amVWAP2(StartTime2+"",sym(vSymbol));
            
    setShowTitleParameters(eval(Params));
            
    bInit=true;
            }
        

    }



    if(
    getBarState()==BARSTATE_NEWBAR)
    {

        
    xVWAP getSeries(xVWAP);
        
    yVWAP getSeries(yVWAP);
        
    offset OffsetTicks getMinTick();
    var 
    current_time getHour() *100 getMinute();
    max15 upperDonchian(3, -1); // on a 5min chart
    min15 lowerDonchian(3, -1)
    if ( (
    max15  offset )< xVWAP)
    {
    check_xVWAP_l true;
    vwap_before_b true;
    }
    else 
    check_xVWAP_l false;
    if ( (
    min15 offset) > xVWAP )
    {
    check_xVWAP_h true;
    vwap_before_a true;
    }
    else 
    check_xVWAP_h false;

    if (
    current_time 1100 && current_time 1550)
    time_conditions true;
    else
    time_conditions false;
    }
    // end of new bar
    /*
    if (time_conditions ==true ) 
    {
    if ( vwap_before_b == true && check_xVWAP_l==true && (high(0) + offset) > xVWAP  )
    {
    //VWAP Alert bitches,,was trading below
    //debugPrintln("VWAP test, was trading below " + current_time);
    Alert.playSound( getSoundFileRoot()+xWAVFILE );
    Alert.addToList( getSymbol(), "VWAP test, was trading below", Color.red, Color.darkgreen );
    vwap_before_b = false;
    }

    if ( vwap_before_a == true && check_xVWAP_h == true && (low(0) + offset) < xVWAP   )
    {
    // alert vwap, was trading above before
    Alert.playSound( getSoundFileRoot()+xWAVFILE );
    Alert.addToList( getSymbol(), "VWAP test, was trading above", Color.red, Color.darkgreen );
    vwap_before_a = false;
    }
    } // time constraint on VWAP check

    */
        
    return new Array(getSeries(xVWAP), getSeries(yVWAP));


  • #2
    no worries. i solved it

    Comment

    Working...
    X