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

Re: [EquisMetaStock Group] Question for Roy on Sum and Reset



PureBytes Links

Trading Reference Links

Roy,

That was all that was needed, thanks so much for your help. 

--- In equismetastock@xxxxxxxxxxxxxxx, "Roy Larsen" <rlarsen@xxxx> 
wrote:
> Deepfoobar
> 
> I'm guessing that you came across some formulas to accumulate 
weekly and
> monthly volume so I'll post the monthly version here and then 
adjust it to
> accumulate up to a constant threshold
> 
>   {Cumulate Volume By Month}
> A:=DayOfMonth()<ValueWhen(2,1,DayOfMonth());
> If(A,V,PREV+V);
> 
>   {Cumulate Volume By Constant}
> A:=10000000;
> If(PREV>A,V,PREV+V); {reset when total exceeds constant}
> 
> Set the constant to whatever is appropriate. This is by no means 
the only
> approach to take so don't regard it as THE answer. Try and keep the 
PREV
> variable as short as possible. More complexity means more 
likelihood of
> making an error. Start with the absolute minimum code and add in 
bells and
> whistles one at a time.
> 
> One last point. I notice that you said "(equal to what is being 
summed)".
> Unless you are dealing with very small integers you should NEVER 
just test
> for equal (=), always test for greater than or equal (>=) or less 
than or
> equal (<=). Single digit precision errors are likely to render 
the "equal"
> test as never being true if you're using division, multiplication 
or some
> other manipulation on the data you want to compare against the 
constant.
> 
> These sorts of tiny errors are very difficult to spot other than by 
virtue
> of the fact that a comparison that should work doesn't. If you 
examine the
> results of your calculations carefully you might find that what 
think is
> "15" is actually "15.000001" or "14.999999".
> 
>   {Cumulate Volume By Constant}
> A:=5000000;
> If(PREV+V>=A,V,PREV+V); {reset before total exceeds constant}
> 
> > I've been poking around the Oz boards (boy you folks are wicked MS
> > wizards, they should be there instead of Utah!) and I have a 
simple
> > question on your sum and reset formula.
> >
> > I wanted to adapt your sum and reset to compare a known constant
> > value to the summed value. If that constant value is reached 
(equal
> > to what is being summed) or the summed value is greater than the
> > constant value I'd want to call Reset and start the whole process
> > over again.
> >
> > While this would appear simple it is beyond me how to do it. No
> > matter how I do the compare, the values are coming out dead wrong.
> > Can't figure this one out for the life of me. Worse though the 
value
> > and constant should be reached many times over, Reset never gets
> > called.
> 
> I know the frustration. Often code will be very close to correct 
but just
> one small error makes the whole lot turn to junk. Sometimes the 
simplest
> errors are the hardest to spot. If the theory is sound then it will 
often
> come down to ">=" instead of "=" or something equally mundane.
> 
> Be aware that Cum() and PREV don't mix well.
> 
>  > PS. On the book front if you self-publish it, I'll buy it. So no
> > worries on MS beating you to the punch.
> 
> Thanks for the positive comments.
> 
> Roy


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs from home.
Over 14,500 titles. Free Shipping
& No Late Fees. Try Netflix for FREE!
http://us.click.yahoo.com/ArdFIC/hP.FAA/ySSFAA/BefplB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
equismetastock-unsubscribe@xxxxxxxxxxxxxxx

 

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