Announcement

Collapse
No announcement yet.

Volume by Price

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Volume by Price

    Hi.

    Is it possible to do the Volume by price indicator in eSignal?

    I found this example, http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:volu me_by_price

    The main focus though would be in intraday charts because plotting this indicator on top of it, you could see the volume by price for each day and then knowning where in the day, the maximum volume was made.

    I attached 1 image for you to see what I'm talking about.

    Regards

  • #2
    Hi PTC Man,

    I created something very similar for my personal use but i don't see any problems if it will help you in your trading

    EMET

    PHP Code:
    var fpArray = new Array();
    var 
    bInit false;

    function 
    preMain() {

        
    setPriceStudy(true);
        
    setShowCursorLabel(false);
        
    setShowTitleParametersfalse );
        
        
    setStudyTitle("Volume by Price");

      
        
    askForInput();
        var 
    x=0;
        
    fpArray[x] = new FunctionParameter("LineColor1"FunctionParameter.COLOR);
        
    with(fpArray[x++]){
            
    setName("Up Volume Color");
            
    setDefault(Color.RGB(255,160,160)); 
        }    

        
    fpArray[x] = new FunctionParameter("LineColor2"FunctionParameter.COLOR);
        
    with(fpArray[x++]){
            
    setName("Down Volume Color");
            
    setDefault(Color.grey);
        }    


        
    fpArray[x] = new FunctionParameter("TextColor1"FunctionParameter.COLOR);
        
    with(fpArray[x++]){
            
    setName("Up Volume Text Color");
            
    setDefault(Color.black);
        }    

        
    fpArray[x] = new FunctionParameter("TextColor2"FunctionParameter.COLOR);
        
    with(fpArray[x++]){
            
    setName("Down Volume Text Color");
            
    setDefault(Color.white);
        }    

        
        
    fpArray[x] = new FunctionParameter("Width"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Price Range (Big Point)");
            
    setLowerLimit(0.01);        
            
    setDefault(1);
        }

        
    fpArray[x] = new FunctionParameter("BarsAgo"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Bars Ago");
            
    setLowerLimit(1);        
            
    setDefault(200);
        }

        
    fpArray[x] = new FunctionParameter("ViewValue"FunctionParameter.BOOLEAN);
        
    with(fpArray[x++]){
            
    setName("Display Volume Value");
            
    setDefault(false);
        }    


    }

    var 
    aCumVolumes = new Array();
    var 
    aDownVolumes = new Array();
    var 
    nMaxValueCumVolumes 0;
    var 
    nMinPosition 0;
    var 
    nMult 0;
    var 
    nHighest 0;
    var 
    nLowest 0;
    var 
    nMaxCount 0;

    function 
    main(BarsAgoWidthLineColor1LineColor2TextColor1TextColor2ViewValue) {
    var 
    nLeft BarsAgo;
    var 
    nArrayPosition 0;
    var 
    nXAllVol 0;
    var 
    nXDownVol 0;
    var 
    nState getBarState();
    var 
    bFind false;


        if (
    getNumBars() <= BarsAgo) return;

        if (
    nState == BARSTATE_NEWBAR) {
            if (
    isLastBarOnChart()) {
                
    nHighest =  my_highest(BarsAgo);
                
    nLowest =   my_lowest(BarsAgo);
                if (
    nLowest == null || nHighest == null) {
                    return;
                } 
            }
        }

        if (
    nState == BARSTATE_NEWBAR) {
            if (
    isLastBarOnChart()) {
                
    nMaxCount Math.round(nHighest Width);
                
    nMinPosition Math.round(nLowest Width);
                
    nMinPosition nMinPosition 1;

                
    ClearArray(nMaxCount);
                for (var 
    0<= BarsAgoi++) {
                    
    bFind false;
                    
    nArrayPosition nMinPosition;
                    while (
    bFind == false) {
                        if (
    close(-i) > nArrayPosition Width && close(-i) <= (nArrayPosition Width) + Width) {
                            
    bFind true
                        } else {
                            
    nArrayPosition++;
                        }    
                    }
        
                    if (
    nArrayPosition <= nMaxCount) {
                        
    aCumVolumes[nArrayPosition] += volume(-i); 
                        if (
    open(-i) - close(-i) > 0) {
                            
    aDownVolumes[nArrayPosition] += volume(-i);
                        }
                        if (
    nMaxValueCumVolumes aCumVolumes[nArrayPosition]) {
                            
    nMaxValueCumVolumes aCumVolumes[nArrayPosition];
                            
    nMult Calc_Mult(nMaxValueCumVolumesBarsAgo);            
                        }    
                    }    
                }    
            } 
        }


    if (
    nState == BARSTATE_NEWBAR) {
        if (
    isLastBarOnChart()) {
            for (var 
    0nMaxCounti++){
                if (
    aCumVolumes[i] != 0) {
                    
    nXAllVol Math.round(aCumVolumes[i] / nMult);
                    
    nXDownVol Math.round(aDownVolumes[i]  / nMult);      
                    for (var 
    BarsAgo nXDownVol>= Math.round(BarsAgo nXAllVol); j--) {
                        
    drawLineRelative( -j  Width, -j   ,  Width WidthPS_SOLID 2LineColor1"LineVCum"+j+i); 
                    }
                    if (
    ViewValue ==  true) {
                        
    drawTextRelative( -nLeft 15Width Width"V = "+(aCumVolumes[i] - aDownVolumes[i]), TextColor1,
                        
    LineColor1Text.ONTOP Text.CENTER"Courier New"10 "Text"+i); 
                    }
            
            
                    for (var 
    nLeft>= Math.round(BarsAgo nXDownVol); j--) {
                        
    drawLineRelative( -j  Width, -j   ,  Width WidthPS_SOLID 2LineColor2"LineV"+j+i); 
                    }
                    if (
    ViewValue ==  true) {
                        
    drawTextRelative( -nLeft 15 Width + (Width 2),  "V = "+aDownVolumes[i], TextColor2,  
                        
    LineColor2Text.ONTOP Text.CENTER"Courier New"10 "Text2"+i); 
                    }    
                }
            }
        
            for (var 
    0nMaxCounti++){
                if (
    aCumVolumes[i] != 0) {
                    
    drawLineRelative( -nLeft Width10WidthPS_DASH 2Color.white"Line0"+i); 
                }    
                
    DrawFirst false;    
            }
        }
    }
     
        return;

    }

    function 
    ClearArray(nMaxCount){
        for (var 
    0<= nMaxCounti++) {
            
    aCumVolumes[i] = 0;
            
    aDownVolumes[i] = 0;
        }
        
    debugClear();
        
    clearText();   
        
    clearLines(); 
        
    nMaxValueCumVolumes ;
        return;
    }

    function 
    Calc_Mult(nValuenBarsAgo){
    var 
    nRes 0;
       
        
    nRes Math.round(nValue nBarsAgo);
           
        return 
    nRes;
    }

    function 
    my_highest(nBarAgo){
    var 
    nRes 0;
        for (var 
    0<= nBarAgoi++) {
            if (
    nRes close(-i)) nRes close(-i);
        }
        return 
    nRes;
    }

    function 
    my_lowest(nBarAgo){
    var 
    nRes close(0);
        for (var 
    0<= nBarAgoi++) {
            if (
    nRes close(-i)) nRes close(-i);
        }
        return 
    nRes;

    Attached Files

    Comment


    • #3
      emet,

      Beautiful piece of code, thanks for sharing it. Any tips on how you use it would be appreciated.

      thanks again,

      glen
      Glen Demarco
      [email protected]

      Comment


      • #4
        Hi emet.

        I don't know what is happening but I can't see the indicator on the chart.

        I load it but nothing is ploted on daily and intraday charts.

        Can you give me any idea on hou to resolve this issue?

        Thank you for your help.
        Regards

        Comment


        • #5
          Originally posted by PTC Man
          Hi emet.

          I don't know what is happening but I can't see the indicator on the chart.

          I load it but nothing is ploted on daily and intraday charts.

          Can you give me any idea on hou to resolve this issue?

          Thank you for your help.
          Regards
          Not sure what can be the reason, it works good for me. The only idea is that Days Ago > than number of bars on the chart.

          Comment


          • #6
            Hi emet.

            I've no idea what happened but it's working now

            Anyway, this is very good.

            One question, is it possible to have a specific version for intraday charts?

            Instead of using days ago , is it possible for the formula to recognize each session day - intraday session - and plot the price by volume for that day?

            Basically what I want is to be able to see the price by volume for the day in a intraday chart - any time interval and not only for today but also for the past days.

            I tried to include an image so you could see more clearly what i'm requesting but the image attach option isn't working. I selected the image but it wasn't posted

            Regards
            Last edited by PTC Man; 09-20-2008, 10:21 AM.

            Comment


            • #7
              PTC Man

              Basically what I want is to be able to see the price by volume for the day in a intraday chart - any time interval and not only for today but also for the past days.
              In this thread you can find a script that does what you describe
              Alex

              Comment

              Working...
              X