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

Re: [amibroker] Re: Need coding help with volume indicator



PureBytes Links

Trading Reference Links

Wow, /Valuewhen /looks very useful! Thanks!

Amibroker is great, and so are its users.

Lorin

Graham wrote:
>
> Another way to do this is using valuewhen
>
> UpVol = Valuewhen(C > O, V);
> DownVol = Valuewhen(C < O, V);
> Period = Param("Period",3,2,10,1);
> UpVolAvg = EMA( UpVol, Period ) ;
> DownVolAvg = EMA( DownVol, Period ) ;
> Plot(UpVolAvg,"UpVolume", colorGreen);
> Plot(DownVolAvg, "DownVolume", colorRed);
>
>
>
> -- 
> Cheers
> Graham
> AB-Write >< Professional AFL Writing Service
> Yes, I write AFL code to your requirements
> http://www.aflwriting.com <http://www.aflwriting.com>
>
> On 03/12/06, *Lorin Abarr* <l_abarr@xxxxxxxxx 
> <mailto:l_abarr@xxxxxxxxx>> wrote:
>
>     Thanks, Mr. Valley!  A histogram of the difference between the EMA of
>     UpVolume and the EMA of DownVolume seems somewhat interesting. I
>     really
>     appreciate the help!
>
>     Period = Param("Period",3,2,10,1);
>     UpVol =IIf(C > O, V, -1);
>     DownVol =IIf(C < O, V, -1);
>     UpVol[0] = DownVol[0] = V[0]; // Be sure to start with something
>     // Loop through to pad the arrays
>     for (i = 1; i < BarCount; i++)
>     {
>     if (UpVol[i] < 0)
>     {
>     UpVol[i] = UpVol[i - 1];
>     }
>     if (DownVol[i] < 0)
>     {
>     DownVol[i] = DownVol[i - 1];
>     }
>     } // need another
>     UpVolAvg = EMA( UpVol, Period ) ;
>     DownVolAvg = EMA( DownVol, Period ) ;
>     VolumeHist = UpVolAvg - DownVolAvg;
>     //Plot(UpVolAvg,"UpVolume", colorGreen,1);
>     //Plot(DownVolAvg, "DownVolume", colorRed,1);
>     Plot (VolumeHist, "VolumeHist", colorBlack,2);
>
>     Mr. Valley wrote:
>     >
>     > Period = Param("Period",3,2,10,1);
>     > UpVol =IIf(*C* > *O*, *V*, -1);
>     > DownVol =IIf(*C* < *O*, *V*, -1);
>     > UpVol[0] = DownVol[0] = *V*[0]; // Be sure to start with something
>     > // Loop through to pad the arrays
>     > *for* (i = 1; i < *BarCount*; i++)
>     > {
>     > *if* (UpVol[i] < 0)
>     > {
>     > UpVol[i] = UpVol[i - 1];
>     > }
>     > *if* (DownVol[i] < 0)
>     > {
>     > DownVol[i] = DownVol[i - 1];
>     > }
>     > } // need another
>     > UpVolAvg = EMA( UpVol, Period ) ;
>     > DownVolAvg = EMA( DownVol, Period ) ;
>     > Plot(UpVolAvg,"UpVolume", *colorGreen*,1);
>     > Plot(DownVolAvg, "DownVolume", *colorRed*,1);
>     >
>     >     -----Original Message-----
>     >     *From:* amibroker@xxxxxxxxxxxxxxx
>     <mailto:amibroker@xxxxxxxxxxxxxxx>
>     >     [mailto:amibroker@xxxxxxxxxxxxxxx
>     <mailto:amibroker@xxxxxxxxxxxxxxx>]*On Behalf Of *steesehwy
>     >     *Sent:* Saturday, December 02, 2006 1:01 PM
>     >     *To:* amibroker@xxxxxxxxxxxxxxx
>     <mailto:amibroker@xxxxxxxxxxxxxxx>
>     >     *Subject:* [amibroker] Re: Need coding help with volume
>     indicator
>     >
>     >     Ok, here's a way to do it (warning: untested code, I'm just
>     >     free-styling here...)
>     >
>     >     UpVol =IIf(C > O, V, -1);
>     >     DownVol =IIf(C < O, V, -1);
>     >
>     >     UpVol[0] = DownVol[0] = V[0]; // Be sure to start with something
>     >
>     >     // Loop through to pad the arrays
>     >     for (i = 1; i < BarCount; i++)
>     >     {
>     >     if (UpVol[i] < 0)
>     >     {
>     >     UpVol[i] = UpVol[i - 1];
>     >     }
>     >
>     >     if (DownVol[i] < 0)
>     >     {
>     >     DownVol[i] = DownVol[i - 1];
>     >     }
>     >
>     >     Period = Param("Period",3,2,10,1);
>     >     UpVolAvg = EMA( UpVol, Period ) ;
>     >     DownVolAvg = EMA( DownVol, Period ) ;
>     >     Plot(UpVolAvg,"UpVolume", colorGreen);
>     >     Plot(DownVolAvg, "DownVolume", colorRed);
>     >
>     >     - Bill
>     >
>     >     --- In amibroker@xxxxxxxxxxxxxxx
>     <mailto:amibroker@xxxxxxxxxxxxxxx>
>     >     <mailto:amibroker%40yahoogroups.com
>     <mailto:amibroker%40yahoogroups.com>>, "l_abarr" <l_abarr@xxx> wrote:
>     >     >
>     >     > I want UpVolume defined as Volume on days when the Close >
>     Open.
>     >     > DownVolume is Volume on days when Close < Open. Then I'd
>     like to
>     >     plot
>     >     > two moving averages: one for UpVolume and one for
>     DownVolume. The
>     >     > problem is that on each day there will be no value for either
>     >     UpVolume
>     >     > or DownVolume. So if the Close > Open today, we'd have a
>     value for
>     >     > UpVolume (today's Volume) but no value for DownVolume. So I'd
>     >     like the
>     >     > value for DownVolume to remain at yesterday's DownVolume
>     value.
>     >     >
>     >     > Thanks, I'm new at this, I appreciate your patience.
>     >     >
>     >     > --- In amibroker@xxxxxxxxxxxxxxx
>     <mailto:amibroker@xxxxxxxxxxxxxxx>
>     >     <mailto: amibroker%40yahoogroups.com
>     <mailto:amibroker%40yahoogroups.com>>, "steesehwy" <steesehwy@> wrote:
>     >     > >
>     >     > > The arguments for IIf are (condition, truearray,
>     falsearray).
>     >     In your
>     >     > > first and second lines, you use a value for the
>     "falsearray",
>     >     not an
>     >     > > array.
>     >     > >
>     >     > > Also, you seem to be trying to repeat the last value for
>     >     volume when
>     >     > > it isn't up or down - that is, repeat the last down
>     volume on
>     >     an up
>     >     > > day. That will cause a falsely weighted average. For
>     example, in a
>     >     > > strong up trend, the down-volume average could consist
>     of repeated
>     >     > > entries of the last down day's volume. I don't have a good
>     >     > > work-around, unless I knew a little more about what you are
>     >     trying to
>     >     > > accomplish.
>     >     > >
>     >     > > - Bill
>     >     > >
>     >     > >
>     >     > > --- In amibroker@xxxxxxxxxxxxxxx
>     <mailto:amibroker@xxxxxxxxxxxxxxx>
>     >     <mailto: amibroker%40yahoogroups.com
>     <mailto:amibroker%40yahoogroups.com>>, "l_abarr" <l_abarr@> wrote:
>     >     > > >
>     >     > > > I'm new at this. I'm getting an error in the first line
>     >     because the
>     >     > > > variable 'upvol' hasn't been initialized. I want UpVol to
>     >     remain the
>     >     > > > same as yesterday if C < O. Thanks for any help!
>     >     > > >
>     >     > > > UpVol =IIf(C > O, V, Ref(UpVol,-1));
>     >     > > > DownVol =IIf(C < O, V, Ref(DownVol,-1));
>     >     > > > Period = Param("Period",3,2,10,1);
>     >     > > > UpVolAvg = EMA( UpVol, Period ) ;
>     >     > > > DownVolAvg = EMA( DownVol, Period ) ;
>     >     > > > Plot(UpVolAvg,"UpVolume", colorGreen);
>     >     > > > Plot(DownVolAvg, "DownVolume", colorRed);
>     >     > > >
>     >     > >
>     >     >
>     >
>     >
>
>
>
>     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 <http://amibroker.com>
>
>     For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
>     http://www.amibroker.com/devlog/ <http://www.amibroker.com/devlog/>
>
>     For other support material please check also:
>     http://www.amibroker.com/support.html
>     <http://www.amibroker.com/support.html>
>
>     Yahoo! Groups Links
>
>
>         (Yahoo! ID required)
>
>         mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
>     <mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx>
>
>
>
>
>
>
>  


Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.430 / Virus Database: 268.15.4/563 - Release Date: 12/2/2006 9:59 AM