Estimate transaction volumn

I do search the forum but cannot find best solution.
I would like to estimate total transaction volume for daily trading. The market open at 9:00 AM and take lunch break from 11:30 AM to 13:00 PM and then continue transaction and close at 14:45 PM. With current speed of transaction, I would like to estimate total volume at the closing time will reach my expert amount or not. I am using Now(4) function but cannot figured out the final volume. Please help to advise. Thankyou

Below is my code

_SECTION_BEGIN("Volume estimate");
timev=Now (4);
IIf ( timev <90000 OR timev > 144500 ,Vole=Volume, // Before 9h and after 14h45 Vole=Volume  
      IIf( timev > 90000 AND timev < 113000,Vole = (Volume * 37500)/(timev-90000), //9h to 11h30//  
         IIf (timev >113000 AND timev< 130000, vole= (Volume * 37500)/(113000-90000), // lunch time
           Vole = (Volume*37500)/(timev-90000-17000) // afternoon
           )
         )  
    ); 

Plot( Vole, _DEFAULT_NAME(), IIf( C > O, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ) ), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );

_SECTION_END();

For what it is worth, IIF is not control statement but a function. So you are using it incorrectly, see:

1 Like

Hi @topfun ( if your code is correct ?)

You have to add on your afl code the example below, to draw a volume as appear in your photo.
To change the position please adjust the BarCount + 1 to BarCount +/- 1
also adjust the width = 4 for the thickness of the Estimate Volume bar

// Original Actual Volume
Plot( V, _DEFAULT_NAME(), IIf( C > O, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ) ), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );

// Estimate Volume to plot out with blue color
// This part of the code is for using GFX 
GfxSetOverlayMode( 1 ); 
GfxSetCoordsMode( 1 ); // bar/price mode (instead of pixel) 
GfxSelectPen( colorBlue ,width = 4); 
VolumeEstimate = LastValue(Vole);
GfxMoveTo(BarCount + 1, 0); GfxLineTo(BarCount + 1,VolumeEstimate );
GfxTextOut(""+VolumeEstimate, BarCount + 2, VolumeEstimate);
1 Like

Ok. as i read the above i thought your calculation is ok. and for that reason i wrote the "add on" for your code, and it is working ok . But.

As i read more carefully i realize you try to find the Volume of specific period of the day. I can tell, you need more help on this.
You multiply the Volume*37500 what is this number? was an example or what?

So you may need to read about SparseCompress() function , and i just try to give you an idea in below unfinished afl

a sample unfinished afl to work with
 
// lunch time
LunchTime = SparseCompress(timev >113000 AND timev< 130000,Volume );
     vole =  // your calculation here 
vole = SparseExpand( LunchTime, vole ); 

// afternoon
afternoon = SparseCompress(timev >130000 AND timev <144500,Volume );
       vole =   // your calculation here 
vole = SparseExpand( afternoon, vole ); 

2 Likes

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.