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

RE: [amibroker] Re: Search Routine for Crossover Point -- EMA Version



PureBytes Links

Trading Reference Links

I don't know exactly if it can help anyone,
it is an old code of swing without zig function

/* SWING CHART */

SetBarsRequired( 200, 200 ); // needed for script

swingsize = 10;

HP = HHVBars( High, swingsize ) == 0;

LP = LLVBars( Low, swingsize ) == 0;

EnableScript("jscript");

<%

result = VBArray(AFL("High")).toArray();

function TrendLine( starti, startv, endi, endv )

{

for( j = starti; j <= endi; j++ )

{

result[ j ] = startv + ( j - starti )*(endv-startv)/(endi-starti);

}

}

High = VBArray(AFL("High")).toArray();

Low = VBArray(AFL("Low")).toArray();

HP = VBArray(AFL("HP")).toArray();

LP = VBArray(AFL("LP")).toArray();

endi = -1;

starti = -1;

dir = 0;

for( i = High.length - 0; i >= 0; i-- )

{

if( dir == 1 && LP[ i ] )

{

TrendLine( i, Low[ i ], endi, endv );

endi = i;

endv = Low[ i ];

dir = -1;

}

else

if( dir == -1 && HP[ i ] )

{

TrendLine( i, High[ i ], endi, endv );

endi = i;

endv = High[ i ];

dir = 1;

}

else

if( dir == 0 && endi == -1 && LP[ i ] )

{

endi = i;

endv = Low[ i ];

dir = -1;

}

else

if( dir == 0 && endi == -1 && HP[ i ] )

{

endi = i;

endv = High[ i ];

dir = 1;

}

}

AFL("Graph0")=result;

%>

Graph0Color=colorRed;

Graph1=Close;

Graph1Color = colorBlack;

Graph1Style=styleCandle;


> Hello,
> 
> I am an AFL neophyte and have been working for some time learning 
> AFL and how to use it in Amibroker.  I generally try to learn by 
> following code which gives interesting results that seem to fit my 
> trading style.  I appreciate the code for monthly swing highs and 
> lows that I have attached. Unfortunately I lost the original 
message 
> and cannot go back to the author with this question.  So I will 
post 
> to the board and hope someone can either help with the problem or 
> steer me to the author.
> 
> I am trying to look for stocks which have not moved much over the 
> last several months.  So I want to explore for monthly highs and 
> lows which are within $1 of the previous time period.  The code is 
> as follows:
> 
>  //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
> 
> PlotOHLC(Open,High,Low,Close,"",colorBlack,styleCandle); 
> 
> TimeFrameSet(inMonthly);
> 
> Res = High < Ref(High,-1) AND Ref(High,-1) > Ref(High,-2);
> 
> Sup = Low > Ref(Low,-1) AND Ref(Low,-1) < Ref(Low,-2);
> 
> MonthDate = ValueWhen(res,Month(),1)-1; // Month when Swing Hi 
> occurs - provides correct value.
> 
> YearDate = ValueWhen(res,Year(),1);
> 
> MonBars = ValueWhen(res,BarIndex(),1);
> 
> MonthlyHigh = TimeFrameExpand(High,inMonthly,expandFirst); 
> 
> MonthlyLow = TimeFrameExpand(Low,inMonthly,expandFirst);
> 
> //Plot monthly High and Low values - OK
> 
> Plot(MonthlyHigh,"",colorAqua,1);
> 
> Plot(MonthlyLow,"",colorAqua,1);
> 
> TimeFrameRestore();
> 
> // The 2 lines below work OK. I have used numeric value (9) instead 
> of Monthdate.
> 
> SW_High = ValueWhen(Month()==9/*Monthdate*/,Monthlyhigh,1);
> 
> SW_BarInx = ValueWhen(Month()==9/*Monthdate*/ AND 
> High==SW_High,BarIndex(),1);
> 
> // These 2 lines below use the variable "Monthdate" that has the 
> correct value (9) as printed in interpretation window, but does not 
> provide correct value for SW_High
> 
> SW_High = ValueWhen(Month()==Monthdate,Monthlyhigh,1);
> 
> SW_BarInx = ValueWhen(Month()==Monthdate AND High==SW_High,BarIndex
> (),1);
> 
> "Mon high " + WriteVal(Monthlyhigh,1.2);
> 
> "Mon Date " + WriteVal(MonthDate,1.0);
> 
> "Sel Date " +WriteVal(Month(),1.0);
> 
> "SW_High " + WriteVal(SW_High,1.2);
> 
> "SW_BarInx " + WriteVal(SW_BarInx,1.0);
> 
> "Bar Index " + WriteVal(BarIndex(),1.0);
> 
> 
> What would the explore statement look like that would allow me to 
> find stocks which have not moved much in the past n time periods ( 
1 
> to 3 months)
> 
> Thanks in advance for the help!!!
> 
> Michael Harrison


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 ---------------------~-->
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
---------------------------------------------------------------------~->

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/