[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] How to plot volume in price pane using 1/3 of pane?



PureBytes Links

Trading Reference Links

Hello,
 
There is easier to use technique, which is already shown by built-in volume code:
 
Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorBlueGrey ), ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick, maskHistogram  ), 2 );
 
 
This '2' in the end controls how tall volume histogram is. 2 means 1/2 of pane. 3 would mean 1/3 of pane.
You can parametrize it to allow free-scaling:
 
Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorBlueGrey ), ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick, maskHistogram  ), Param("1/n Height", 2, 1, 10, 0.25 ) );

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: Dan Clark
Sent: Sunday, October 09, 2005 5:09 PM
Subject: RE: [amibroker] How to plot volume in price pane using 1/3 of pane?

Tony,

 

Hi.   I just wanted to post the code with the changes that I made to Bill’s code.    Below is a full version that you should be able to use. 

 

The PlotVolumeBool is just a parameter that I use to toggle it on and off quickly.  I’ve found that sections are useful for grouping code logically, but I like to group key parameters (like “control” flags) together.   So, while I may have code and other parameters in sections, I place the parameters at the top and order them as I please.   I’ve added the PlotVolumeBool parameter.

 

The other code is the L1 and U1 functions.   On my system, I’ve placed them in an include file with my other functions.  To make this run, I added them to the code below.    If you want to stuff the L1 and U1 functions into an include file:

 

  1. Create the include file.
  2. Save it to the …\Amibroker\Formulas\Include\ folder with an appropriate name (e.g. “ABFunctions.afl”).
  3. Cut (not copy) and paste the L1 and U1 function code to the include file.
  4. Unrem the ““#include…” line below.
  5. Change the filename in the “#include…” line to your filename.

 

Regarding include files…

 

I recommend using an include file under virtually all circumstances.  It cleans up the code and makes it much more manageable.   There’s nothing worse that having linear regression code that is slightly differently in three different instances.   That’s nightmare city.

 

When developing new code, I create and test it in-line.  Then, when it’s finished I move it to an include file if it meets one of two conditions:

  • If the code is more than about 10 lines long, or
  • If there is even a slight possibility that the code will be reused in another scan or chart.

 

The only exception where I keep in-line code is when a scan, exploration or a back testing that runs slowly because of the include file.    I.e., I’ll put the code in an include file and then move it back to in-line code if it’s unacceptably long-running.   So far, I haven’t found that condition.

 

Regards,

 

Dan.

 

 

_SECTION_BEGIN("Color Volume Overlay ");

 

//#include <YourFunctionIncludeFileNameHere.afl>

 

PlotVolumeBool         = ParamToggle("Plot Volume?", "No|Yes", 1);

 

function L1 (Var, LowerFreespacePercent, UpperFreespacePercent)

       {

       // Lower limit for plotting one variable

    vis = Status("barvisible");

    Hii = LastValue(Highest(Var*vis));

    Loo = LastValue(Lowest((Var - Hii)*vis) + Hii);

    range = Hii - Loo;

    rangePercent = 100 - LowerFreespacePercent - UpperFreespacePercent;

    mult = range / rangePercent;

    result = Loo - mult*LowerFreespacePercent;

    return result;

       }

 

// Upper limit for plotting one variable

function U1 (Var, LowerFreespacePercent, UpperFreespacePercent)

       {

    vis = Status("barvisible");

//    vis = Status("barvisible");

    Hii = LastValue(Highest(Var*vis));

    Loo = LastValue(Lowest((Var - Hii)*vis) + Hii);

    range = Hii - Loo;

    rangePercent = 100 - LowerFreespacePercent - UpperFreespacePercent;

    mult = range / rangePercent;

    result = Hii + mult*UpperFreespacePercent;

    return result;

       }

 

if (PlotVolumeBool)

       {

       V = round(V/1000);

       Plot(V, "Vol", IIf( C > Ref(C, -1), ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ) ), styleHistogram | styleOwnScale + styleNoLabel + styleNoTitle, L1(V, 5, 65), U1(V, 5, 65) );

       Plot( round(MA( V, 50 )), "Vol MA(50)", ParamColor( "Vol MA Color", colorOrange), styleLine | styleOwnScale + styleNoLabel + styleNoTitle, L1(V, 5, 65), U1(V, 5, 65) );

       }

 

_SECTION_END();

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Tony Lei
Sent: Sunday, October 09, 2005 6:40 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] How to plot volume in price pane using 1/3 of pane?

 

Hi Dan,

I seem to get an error from the volume code.

Any help

thanks

tony

On 10/8/05, Dan Clark <dan_public@xxxxxxxxxxx> wrote:

Ara,

 

Sorry for the confusion.  I wasn't referring to PlotVAPOverlay().   I was referring to Plot(V).

 

Thanks anyway,

 

Dan.

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Ara Kaloustian
Sent: Saturday, October 08, 2005 8:23 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] How to plot volume in price pane using 1/3 of pane?

 

Dan,

 

you can control it by parameters.. Once you display the volume on price, display the parameters and change the "width"

 

Ara

----- Original Message -----

From: Dan Clark

Sent: Friday, October 07, 2005 11:47 PM

Subject: [amibroker] How to plot volume in price pane using 1/3 of pane?

 

Hi,

I'd like to overlay a volume histogram in a price bar pane, but set it up so that the tallest volume bar take up onlys

Thanks and regards,

Dan.




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html




YAHOO! GROUPS LINKS

 

 






Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





YAHOO! GROUPS LINKS