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

Re: [amibroker] Re: median calculation



PureBytes Links

Trading Reference Links

----- Original Message ----- 
From: Bob Jagow 

Whoops--now you want the average instead of the median?

*** I want the median of the four highest peaks, which is the same thing as the average of the second and third highest peaks, yes? ***

For that, just sum peak(myOsc,chng,i) and trough(myOsc,chng, i) for the
ith most recent peaks. [Note that the peaks and troughs are supposed to
be >  0, so add a constant if needed.]

*** I only want the median value of the four highest peaks and the median value of the four lowest troughs - how is summing all the peaks and troughs going to help find the median? I assume "chng" is short for "change"? The change from what to what? Seriously - I really am not following what you're trying to convey here... ***

A bubble sort just swaps the values in 2 loops [Google bubble sort]. Do
this with AB's for loop instead of calling VBscript.

*** OK, I'll try the "for" loop solution... are you thinking nested loops? I once programmed a couple of nested for-next loops to find the median value of a fixed-length array, and even though I don't know what a Google bubble sort is, what I did sounds like a bubble sort (as I mentioned, that was 20 years ago). I guess I'll have to try to recreate it using the AB version of the next-less "for" routine (I have a hard time with the idea that you can use "for" without "next", but that's my old-dog-can't-learn-new-tricks mindset). As for VBscript, is that the same thing as Visual BASIC? If so, is VB pretty much the same as plain old generic BASIC? I might be better off just using that, since I can grasp BASIC easier than I seem to be getting AFL...***

???

DC

-----Original Message-----
From: dennisconn@xxxxxxxxxxxxxxxx [mailto:dennisconn@xxxxxxxxxxxxxxxx]
Sent: Friday, November 05, 2004 1:33 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Re: median calculation



Hi Bob,

Thanks for the response. The only problem is that I want to chart some
further calculations in AB which will be dependent on the median
calculation - so Excel won't get it.

All I can think of is to run a loop which first sets the HHV of the
array to zero, then finds the next highest value, assign it to x, set
THAT high value in the array to zero, then look for the next high value
and average it with x. Then do the same for the negative values in the
array to find the median of the four lowest troughs.

Even if I figure out how to do that, it seems awfully clumsy. There has
to be a better way, but I have a feeling it's going to involve some kind
of nested loop in VBscript or something, to sort them out. I haven't
written anything serious in 20 years, and I've forgotten most of the
how-to-do-it solutions I found then.

While writing this, I noticed your follow-up response mentioning bubble
sorts. I'm not familiar with the term, but I have the feeling it
involves what I considered in the last paragraph.

Still stumped, but plugging away...

DC
  ----- Original Message -----
  From: Bob Jagow
  To: amibroker@xxxxxxxxxxxxxxx
  Sent: Friday, November 05, 2004 4:08 PM
  Subject: RE: [amibroker] Re: median calculation


  Since "The Median function - finds median (middle element) value of
the
  array over period elements", you'd have to identify the "four highest
  peaks within a user-defined lookback range  as well as the four lowest
  troughs below zero" and try to stuff them into a new array in order to
  use it.
  I'd suggest Excel in preference to AB.

  Regards,
  Bob


  -----Original Message-----
  From: conn_dennis [mailto:dennisconn@xxxxxxxxxxxxxxxx]
  Sent: Friday, November 05, 2004 12:26 PM
  To: amibroker@xxxxxxxxxxxxxxx
  Subject: [amibroker] Re: median calculation




  So was the question that stupid, or hasn't anyone ever attempted it?

  Anyone???

  --- In amibroker@xxxxxxxxxxxxxxx, "conn_dennis" <dennisconn@xxxx>
  wrote:
  >
  > I know that the median function will return the median value of the
  > entire array, but how would one go about finding the median of only
  > some of the values in an array?
  >
  > So far, I've managed only to identify the peaks in an oscillator
  I've
  > coded, but I'm trying to have the program find the median of ONLY
  the
  > four highest peaks within a user-defined lookback range (likewise
  > with the four lowest troughs below zero).
  >
  > I think I can stumble around and figure out how to code what I need
  > once I get past this median problem. I've spent two days on this
  > trying to figure it out (I feel like Thomas Edison - I've
  discovered
  > a thousand ways to NOT find the median). : )
  >
  > Has anyone had a similar problem and found a somewhat simple
  > solution, or perhaps be willing to point me in some direction?
  >
  > DC






  Check AmiBroker web page at:
  http://www.amibroker.com/

  Check group FAQ at:
  http://groups.yahoo.com/group/amibroker/files/groupfaq.html
  Yahoo! Groups Links










  Check AmiBroker web page at:
  http://www.amibroker.com/

  Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html


        Yahoo! Groups Sponsor

        Get unlimited calls to

        U.S./Canada




------------------------------------------------------------------------
------
  Yahoo! Groups Links

    a.. To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

    b.. To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

    c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.





------------------------------------------------------------------------
------

  Message transport security by GatewayDefender
  4:11:03 PM ET - 11/5/2004

[Non-text portions of this message have been removed]




Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links










Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 



      Yahoo! Groups Sponsor 
            ADVERTISEMENT
           
     
     




--------------------------------------------------------------------------------

Yahoo! Groups Links

    a.. To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/
      
    b.. To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx
      
    c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 





------------------------------------------------------------------------------

  Message transport security by GatewayDefender
  5:24:32 PM ET - 11/5/2004

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

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