PureBytes Links
Trading Reference Links
|
Hi Joe,
When we talked last week, you expressed an
interest in using the ZigZag as a benchmark for your systems. I am in the
process of rewriting some old indicators, and I just finished a new
and better version of the Opt Zig. Just thought you might like to try it.
If you shouild have any quetions, please feel free to ask. Happy
trading!
Steve
PS - From/To dates (in param dialog) don't work
right now due to bug in ParamDate function. TJ is aware and once it is fixed I
think these dates will work OK.
----------------------------------------------------------------------------------------------
// Filename: AO Zig.afl
// Task: Plot auto-opt ZigZag.
// Settings:
// -Apply To: use filter > watchlist > eod universe
// -Range: n last quotations > n = (pds to test) OR from: (start date),
to: (end date)
// -Button: explore
// Notes:
// user defined parameters
InitEquity = GetOption(
"InitialEquity" );
// do not remove, InitEquity used again
further down
SetPositionSize ( InitEquity, spsValue );
// use initial equity for all
trades
// set charting options
//SetBarsRequired( 100000, 100000 );
SetChartOptions ( 0, chartShowDates|chartShowArrows
);
// initialize variables
OptP1 = 0; // percent change
OptEquity = 0;
OptInd = 0;
// optimization loop
Field = ParamField(
"Apply To", -1 );
MinPar1 = Param(
"Opt Loop - Min % Change",
1, 1, 100, 1 );
MaxPar1 = Param(
"Opt Loop - Max % Change",
50, 1, 100, 1 );
StepPar1 = Param(
"Opt Loop - Step % Change", 1, 0.1, 10.01, 0.1 );
for ( StepP1 = MinPar1; StepP1 <= MaxPar1; StepP1 =
StepP1 + StepPar1 )
{
// define buy/sell rules
StepInd = Zig( Field,
StepP1 );
StepInd1B = Ref(
StepInd, -1 );
// StepZig 1 day back
StepInd2B = Ref(
StepInd, -2 );
// StepZig 2 days back
Cover = Buy = StepInd > StepInd1B AND StepInd1B <
StepInd2B;
Sell = Short = StepInd < StepInd1B AND StepInd1B >
StepInd2B;
// evaluate step results
RangeType = Param(
"Equity() Range Type",
-1, -2, 3, 1 );
FromPds = Param(
"Quotes/Days ( Range Types 1/2 )", 126, 2, 2520, 1 );
FromDate = ParamDate(
"From Date ( Range Type 3 )", Date() );
ToDate = ParamDate(
"To Date ( Range Type 3 )", Date() );
if ( RangeType
== 3 )
StepEquity = LastValue(
Equity( 1, RangeType, FromDate, ToDate ) );
else
StepEquity = LastValue(
Equity( 1, RangeType, FromPds ) );
if( StepEquity
> OptEquity )
{
OptP1 = StepP1;
OptEquity = StepEquity;
OptInd = StepInd;
}
}
// calculate profits
OptProfitPts = OptEquity - InitEquity;
OptProfitPct = OptProfitPts / InitEquity * 100;
// exploration results
Filter = BarIndex()
== BarCount - 1;
AddColumn ( OptP1, "Opt
Pct" );
AddColumn ( OptProfitPts, "$ Profit" );
AddColumn ( OptProfitPct, "% Profit" );
// plot results
Color = Param(
"Color", 42, 0, 55, 1
);
Plot ( OptInd, "Opt
Zig", Color, styleLine );
Plot ( OptP1, "Opt Zig %
Change", Color,
styleOwnScale|styleNoLine|styleNoLabel );
Plot ( OptProfitPts, "$
Profit", Color,
styleOwnScale|styleNoLine|styleNoLabel );
Plot ( OptProfitPct, "%
Profit", Color,
styleOwnScale|styleNoLine|styleNoLabel );
Plot ( Close, "Price", colorBlack, styleCandle
);
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 other support material please check also:
http://www.amibroker.com/support.html
SPONSORED LINKS
YAHOO! GROUPS LINKS
|
|