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

[amibroker] Re: sum only positive days



PureBytes Links

Trading Reference Links

<If I understand you correctly you would add more weight to the 2
dollar down move. For the purposes of money flow I think I would
perhaps take the other side of that argument>

Jayson,

The very best thing about AB is that everything is measurable in one
way or another.

Just for the purpose of commentary:

While you did not intend for your original code to represent a valid
backtest platform, it can in fact serve as a benchmark for measuring
different views of raw volume versus $Vol weighted metrics.

I added the necessary Setup criteria to your code including trade
delays, InitialEquity, PositionSize, etc., etc., etc.

Then I ran a real backtest that might mimic real life trading in some
shape, form or fashion.

That backtest provided me with the benchmark that I needed for
comparison purposes.

Then I converted the raw Vol A-D measurements to a $Vol A-D
measurement and ran the same backtest.

While neither backtest resulted in a system that I would trade, the
$Vol A-D version significantly outperformed the raw Vol A-D version.

So you might correctly guess that my next steps will be to focus upon
the $Vol A-D approach.  

And the really interesting part of using AB is that you might continue
refining the raw Vol A-D at the same time I am 'doing my thing' with
$Vol A-D, and you might very well ferret out a better trading system
approach than I do, and I'll never figure it out!

I'll tell you what... AB's capabilities can certainly excercise the mind.

This whole excercise is not much different from what I routinely do
every time I work with potential new trading systems. This is one of
the purist forms of entertainment that I engage in.

Regards,

Phsst




--- In amibroker@xxxxxxxxxxxxxxx, "Jayson" <jcasavant@xxxx> wrote:
> Phsst,
> 
> Yes I see the difference. My code is always a day behind because   i
< pds;
> does not include the pds value. It should read i<=pds or i<pds+1
> 
> Herman's code also produces the correct results although I must
confess I
> have a little trouble following it, but that is my weakness, not
his. There
> have been many variations posted the last few days and it is interesting
> seeing the different paths taken.
> 
> Your example of a  million shares moving a stock up .05 cent and
another day
> a million shares moving it down $2 brings up an interesting point.  If I
> understand you correctly you would add more weight to the 2 dollar down
> move. For the purposes of money flow I think I would perhaps take
the other
> side of that argument. True a $2 move is significant but perhaps the big
> move represents only a small group unloading some shares. Is a million
> significantly more than is moved routinely? if not then If the
masses were
> "Running for the exits" surely it would be on larger volume. True
also with
> the up move of .05. To me this would indicate that the buyers and
sellers
> were largely in agreement as to the value of the stock. Perhaps a better
> train of thought would be to somehow weight the move as it pertains to a
> moving average of the volume as a whole.....just random thoughts and
clearly
> more work needs to be done. Thanks for your input.
> 
> Regards,
> Jayson
> -----Original Message-----
> From: Phsst [mailto:phsst@x...]
> Sent: Thursday, November 27, 2003 2:41 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Re: sum only positive days
> 
> 
> Jayson,
> 
> Add Herman's code and my filter to bottom of your AFL:
> 
> m=BarCount-1; // From Herman
> UpVolDays = 0;
> for(n=m; n>0; n--) if(C[n]>C[n-1]) UpVolDays[m--] = V[n];
> SumLastUpdays = Sum(UpVolDays,20);
> 
> Filter = 1;
> AddColumn(C,"Close",1.4);
> AddColumn(V,"Vol",1.4);
> AddColumn(SumLastUpdays,"SumLastUpdays",1.0);
> AddColumn(x,"x",1.0);
> AddColumn(y,"y",1.0);
> 
> ... then do an explore.
> 
> I compared the results from your loop to Herman's.
> 
> Herman's appears to produce the correct results.
> 
> One other point. I like your concept of working with UpVol / DownVol
> metrics, however I'll be making a significant modification to it...
> 
> assume you have two days with volume of 1,000,000
> 
> one day the close rises $.05
> 
> the other day the close falls $2.00
> 
> Your calcs would result in a net zero diff in Up versus Down volume
> 
> I plan to work with $ based volume changes in order to measure the
> real depth of price changes.
> 
> Thanks for the concept.
> 
> Regards,
> 
> Phsst
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Jayson" <jcasavant@xxxx> wrote:
> > Thanks to all who provided interesting and creative approaches to my
> > question. My goal was to look at the last 20 up days and compare the
> volume
> > to the last 20 down days. William Peters got me started with a for
> loop (I
> > really have to learn better to use these!!) and others provided
> variations.
> > and I came up with the following......
> >
> > pds=Param("PDS",20,6,22,1);
> > smooth=Param("Smooth",12,1,50,1);
> > trig=Param("Trigger",10,1,25,1);
> > x = 0;
> >
> > for( i = 1; i < pds; i++ )
> > {
> >       x = x + ValueWhen( C > Ref( C, -1 ), Volume, i );
> > }
> > y = 0;
> > for( i = 1; i < pds; i++ )
> > {
> >       y = y + ValueWhen( C < Ref( C, -1 ), Volume, i );
> > }
> >
> > vp=EMA(x-y,smooth);
> > trigger=MA(vp,trig);
> > Plot(vp,"",IIf(x-y>0,colorBrightGreen,colorRed),1);
> > Plot(trigger,"",colorYellow,1);
> >
> > Title="A/D Volume of "+Name()+ " is "+
> > WriteIf(x-y>0,EncodeColor(colorBrightGreen)+ "
> > Positive",EncodeColor(colorRed)+" Is
> Negative")+EncodeColor(colorWhite)+"\n
> > Bar % of  all Vol Average = "+WriteVal(V/MA(V,50)*100,1.0) +"%";
> > Buy=Cross(Vp,trigger);
> > Sell=Cross(trigger,Vp);Equity(1);
> >
> > I am still experimenting with look back parameters and perhaps some
> > smoothing. The MA cross may be important or perhaps a zero cross is
> more to
> > the point. It will take some study. In any case this looks like an
> > interesting way to gauge money flow into and out of a stock. If
there is
> > more interest (volume) on up days then perhaps the stock is under
> > accumulation, if more on down days perhaps distribution. At first
> glance the
> > indicator turns ahead of the price. I like that as it allows me a
> heads up.
> > Please do not confuse my reference to "Buy" and "Sell" as a system.
> This is
> > just an interesting study that some of you may find useful.
> >
> > Enjoy your Holiday
> >
> >
> > Regards,
> > Jayson
> > -----Original Message-----
> > From: Graham [mailto:gkavanagh@x...]
> > Sent: Wednesday, November 26, 2003 5:49 PM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: RE: [amibroker] sum only positive days
> >
> >
> > Jayson, this will sum the last 20 bars for  x which will either be
> zero or
> > the volume.
> >
> > x=iif(c>ref(c,-1),v,0)
> > Y = sum(x,20);
> >
> >
> >
> > Cheers,
> > Graham
> > http://groups.msn.com/ASXShareTrading
> > http://groups.msn.com/FMSAustralia
> >
> > >  -----Original Message-----
> > > From:       Jayson [mailto:jcasavant@x...]
> > > Sent:      Thursday, 27 November 2003 3:18 AM
> > > To:      1ami
> > > Subject:      [amibroker] sum only positive days
> > >
> > > I cannot seem to get my mind around what should be a fairly simple
> thing
> > > to code. Perhaps someone could nudge me in the right direction.
> > >
> > > I want to sum the volume of the last 20 up days and compare it to
> the last
> > > 20 down days. This is not to be confused with summing the up days
> of the
> > > last 20 bars,  Simple code such as  plot( c>ref(c,-1)"",4,2);
> will plot
> > > just the up days and x=iif(c>ref(c,-1),v,0) can calculate the
> volume but
> > > how do I sum the last 20 bars where x>0 as opposed to summing the
> last 20
> > > bars of X  ?
> > >
> > > TIA
> > >
> > > Regards,
> > > Jayson
> > >
> >
> >
> > Yahoo! Groups Sponsor
> > ADVERTISEMENT
> >
> >
> >
> >
> > Send BUG REPORTS to bugs@xxxx
> > Send SUGGESTIONS to suggest@xxxx
> > -----------------------------------------
> > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > --------------------------------------------
> > Check group FAQ at:
> > http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> >
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> 
> 
>       Yahoo! Groups Sponsor
>             ADVERTISEMENT
> 
> 
> 
> 
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> 
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/