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

[amibroker] Help with Coding Problem Please



PureBytes Links

Trading Reference Links

Hi All,

Can anyone help out please, as I'm currently stuck with a coding 
problem and struggling to resolve it.

What I want to do is calculate the number of previous bars (within 
the last 100bars) where the previous closes were within 3% of the 
CURRENT Closing Price.

What I have so far is shown below. The code is not very elegant as 
I'm trying to keep it very simple in an attempt to find out where I'm 
going wrong.


Lookback = 100;
RangePercent = 3;

RangeHigh = Close + (Close*(RangePercent/100));
RangeLow = Close - (Close*(RangePercent/100));

WithinRange = (Close <= RangeHigh) AND (Close >= RangeLow);

NoOfBars = Sum(WithinRange,Lookback);

Plot( NoOfBars , " Support Percentage", ParamColor( "Color", 
colorCycle ), ParamStyle("Style") );



At the moment, when I plot this code the line remains at 100.00. 

I believe the reason for this is that for each previous bar, the same 
previous Close value is also referenced which results in the 
Rangehigh & RangeLow ALWAYS being either side of the corresponding 
close and therefore the WithinRange value ALWAYS being true, which is 
clearly not what I want :-(

Consequently, can anyone suggest how I can resolve this as my coding 
skills are pretty limited.

Thanks in advance,



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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/