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

[amibroker] AFL - Monthly Highs - Lows



PureBytes Links

Trading Reference Links





First hope everyone had a good XMAS ... and wish 
all Happy remaining Holidays!
<FONT color=#000000 
size=2>**********************************************************************************************************************
I wrote the code below to locate Swing Highs and 
Swing Lows on a monthly basis.
The code correctly computes and plots the monthly 
values, as well as provide the month of when Swing Hi/Lo occur.
Variable values are printed correctly in 
interpretation window.
Problem: When I try to get the value of a monthly 
high for a particular month, the code works when I use a numeric value for 
month#. When I sybstitute a variable (with the correct value as printed in int 
window) I get incorrect values.
Code below is commented to show problem 
area.
 
Appreciate any help
 
Ara
//Swing Hi/Lo - use monthly for day charts
//Swing Hi: High with lower high on both sides
//Swing Low: Low with higher Low on both sides<FONT 
size=1>
PlotOHLC<FONT 
size=1>(Open,High,Low,Close,<FONT 
color=#ff00ff size=1>""<FONT 
size=1>,colorBlack,styleCandle); <FONT color=#0000ff 
size=1>
TimeFrameSet(inMonthly);
Res = High < Ref<FONT 
size=1>(High,-1) 
AND Ref<FONT 
size=1>(High,-1) 
> Ref<FONT 
size=1>(High,-2<FONT 
size=1>);
Sup = Low > Ref<FONT 
size=1>(Low,-1) 
AND Ref<FONT 
size=1>(Low,-1) 
< Ref<FONT 
size=1>(Low,-2<FONT 
size=1>);
MonthDate = ValueWhen<FONT 
size=1>(res,Month<FONT 
size=1>(),1)-<FONT 
color=#ff00ff size=1>1; // Month when Swing Hi occurs - 
provides correct value.
YearDate = ValueWhen<FONT 
size=1>(res,Year<FONT 
size=1>(),1);
MonBars = ValueWhen<FONT 
size=1>(res,BarIndex<FONT 
size=1>(),1);
MonthlyHigh = TimeFrameExpand<FONT 
size=1>(High,inMonthly,expandFirst); 
MonthlyLow = TimeFrameExpand<FONT 
size=1>(Low,inMonthly,expandFirst);<FONT 
color=#008000 size=1>
//Plot monthly High and Low values - OK
Plot(MonthlyHigh,<FONT color=#ff00ff 
size=1>"",colorAqua,<FONT color=#ff00ff 
size=1>1);
Plot(MonthlyLow,<FONT color=#ff00ff 
size=1>"",colorAqua,<FONT color=#ff00ff 
size=1>1);
TimeFrameRestore();
// The 2 lines below work OK. I have used numeric value (9) instead of 
Monthdate.
SW_High = ValueWhen<FONT 
size=1>(Month<FONT 
size=1>()==9<FONT face="Courier New" 
color=#008000 size=1>/*Monthdate<FONT 
face="Courier New" color=#008000 size=1>*/<FONT 
size=1>,Monthlyhigh,1<FONT 
size=1>);
SW_BarInx = ValueWhen<FONT 
size=1>(Month<FONT 
size=1>()==9<FONT color=#008000 
size=1>/*Monthdate*/ AND 
High==SW_High,BarIndex<FONT 
size=1>(),1<FONT 
size=1>);
// These 2 lines 
below use the variable <FONT 
face="Courier New" color=#008000 size=1>"M<FONT color=#008000 
size=1>onthdate" that has 
the correct value (9) as printed in interpretation window, but does not provide 
correct value for SW_High
SW_High = ValueWhen<FONT 
size=1>(Month<FONT 
size=1>()==Monthdate,Monthlyhigh,1<FONT 
size=1>);
SW_BarInx = ValueWhen<FONT 
size=1>(Month()==Monthdate 
AND High==SW_High,<FONT color=#0000ff 
size=1>BarIndex(),<FONT color=#ff00ff 
size=1>1);
"Mon high " + <FONT color=#0000ff 
size=1>WriteVal(Monthlyhigh,<FONT color=#ff00ff 
size=1>1.2);
"Mon Date " + <FONT color=#0000ff 
size=1>WriteVal(MonthDate,<FONT color=#ff00ff 
size=1>1.0);
"Sel Date " +<FONT color=#0000ff 
size=1>WriteVal(<FONT color=#0000ff 
size=1>Month(),<FONT color=#ff00ff 
size=1>1.0);
"SW_High " + <FONT color=#0000ff 
size=1>WriteVal(SW_High,<FONT color=#ff00ff 
size=1>1.2);
"SW_BarInx " + <FONT color=#0000ff 
size=1>WriteVal(SW_BarInx,<FONT color=#ff00ff 
size=1>1.0);
"Bar Index " + <FONT color=#0000ff 
size=1>WriteVal(<FONT color=#0000ff 
size=1>BarIndex(),<FONT color=#ff00ff 
size=1>1.0);
 
Title = Name() + 
" " + <FONT 
color=#0000ff size=1>WriteVal(<FONT color=#0000ff 
size=1>DateNum()) + " 
" + High + " 
" + Low;


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








Yahoo! Groups Sponsor


  ADVERTISEMENT 









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 the Yahoo! Terms of Service.