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

[amibroker] ApplyStop



PureBytes Links

Trading Reference Links

You can analyze the Random() with an AB Exploration, see code below. Copy
the result to excel for plotting and further analysis, the result show a
pretty even distribution (magnify the Y-axis for proper analysis)...the
errors that you are getting may be due to some other problem. I set the
number of trials to 1000000 (see code), this takes about a minute.

herman


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

Buy=Sell=Short=Cover=0;
Filter = Status("lastbarintest");
SetOption("NoDefaultColumns",True);
    for(Limit=0; Limit<100; Limit++)
    {
    VarName = "N-"+NumToStr(Limit,1.0);
    StaticVarSet(VarName,0);
    }

NumberOfTrials = 1000000;
for(T=0; T<NumberOfTrials ; T++)
    {
    R = LastValue(Random()) * 100;
    for(Limit=0; Limit<100; Limit++)
    {
    if( R > Limit AND R < (Limit+1) )
        {
        VarName = "N-"+NumToStr(Limit,1.0);
        StaticVarSet(VarName,StaticVarGet(VarName)+1);
        }
    }
}

for(Limit=0; Limit<100; Limit++)
    {
    VarName = "N-"+NumToStr(Limit,1.0);
    AddColumn(StaticVarGet(VarName),VarName,1.0);
    }

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

-----Original Message-----
From: seneca_kw [mailto:wwells@xxxxxxxxxx]
Sent: Tuesday, August 17, 2004 6:15 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Random trades: is Excel better than Amibroker?


I hope I can generate interest in discussing what I think is an
important topic:  the use of random trades to evaluate backtesting
results.

Here's some background on what I'm trying to accomplish.  This is
based largely on Acrary's posts on Elite Trader.

Consider a system that enters at the open, exits at the close, and
generates 500 trades during the test period.  For comparison, you
would generate 500 random trades drawn from the same period, each
with an entry at the open and exit at the close.  You would repeat
the random test at least 1,000 times.  You could then see how your
system test results compare to the random results.  I won't go into
the details of that step, but in general you're looking for profit
results that beat at least 70% of the random tests.

I've been unable to figure out how to do this in Amibroker.  The
tests have to do two things:  1) generate truly random trades;  2)
generate a specified number of trades during the test period.
For the first requirement, I used this formula based on one provided
by Herman Van Den Bergen:
      Y = Random()*100;
      Buy = Cross(Y, 50);
After a number of test runs, I became convinced that this was not
generating truly random trades.  For a 14 year test of 99 stocks,
approximately 20% of the trades were occurring in the first month.
This frontloading of trades happened consistently.

In addition, when a trade signal was generated, multiple trades were
generated on the same day.  So there'd be no trades for weeks at a
time, then 7 trades on the same day, then another dry period, and 6
trades on the same day.

These two observations convinced me that the trades were not being
executed randomly, with each stock and each trading day having an
equal chance of being selected.

I discussed the second point in my previous thread ("How to Limit
Number of Trades?").  Herman made a suggestion for dealing with this
problem that I haven't followed up on yet.

Unable to figure out how to get what I needed with Ambroker, I turned
to Excel.  I generated a complete trading history for the test period
(entering at each open and exiting at each close for each stock).  I
exported this list to Excel and am developing formulas to randomly
pull trades out of this list.  It's been no picnic working with a
spreadsheet containing over 260,000 trades.

I have no doubt that I can get what I need using Excel but I can't
help but think it would be easier and better to work inside
Amibroker.  Has anyone else gone this route or have any suggestions
about how it can be done?

Thanks,
Wayne



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

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.


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