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

[amibroker] Re: MAE code help



PureBytes Links

Trading Reference Links

The simplest answer is probably to upgrade to the pro version which 
includes these statistics ... 

When using Explores or even when developing systems it is sometimes 
handy to initially at least show all the intermediate results so you 
can easily tell when things aren't happening the way you expect ...

This is probably not the simplest solution but it appears to work.

I put a dummy system on top that basically buys on or after the 10th 
of the month and sells on or after the 20th.  

Buy  = Day() >= 10 AND Ref(Day(), -1) < 10;

Sell = Day() >= 20 AND Ref(Day(), -1) < 20;

InOut = Flip(Buy, Sell);

BarsIn = BarsSince(InOut == 0);

EntPrc = IIf(Ref(BarsIn, -1) > 0, Ref(C, -(Ref(BarsIn, -1))), 0);

MAE = IIf(EntPrc > 0, 100 * (EntPrc - LLV(L, Ref(BarsIn, -1))) / 
EntPrc, 0);
MFE = IIf(EntPrc > 0, 100 * (HHV(H, Ref(BarsIn, -1)) - EntPrc) / 
EntPrc, 0);

Filter = 1; // Sell == 1;

AddColumn(C,      "Close",  1.2);
AddColumn(H,      "High",   1.2);
AddColumn(L,      "Low",    1.2);
AddColumn(Buy,    "Buy",    1.0);
AddColumn(Sell,   "Sell",   1.0);
AddColumn(InOut,  "InOut",  1.0);
AddColumn(BarsIn, "BarsIn", 1.0);
AddColumn(EntPrc, "EntPrc", 1.2);
AddColumn(MAE,    "MAE",    1.2);
AddColumn(MFE,    "MFE",    1.2);

--- In amibroker@xxxxxxxxxxxxxxx, "coba702002" <coba702002@xxxx> 
wrote:
> I have been trying to get a version of MAE code to work either in 
> backtester OR explorer without any luck. I am trying to get the 
most 
> amount of points a long/short has gone against me AFTER i enter 
the 
> trade on close.
> 
> I started with this in explore
> 
> BarsInTrade=IIf(Sell,BarsSince(Buy),0); 
> MaximumPrice=HHV(H,BarsInTrade); 
> MinimumPrice=LLV(L,BarsInTrade); 
> MFE=IIf(Sell, 100 * (MaximumPrice-ValueWhen(Buy,C,1))/ValueWhen
> (Buy,C,1), 100 * 
> (ValueWhen(Short,C,1)-MinimumPrice)/ValueWhen(Short,C,1)); 
> MAE=IIf(Buy, 100 * (MinimumPrice-ValueWhen(Buy,C,1))/ValueWhen
> (Buy,C,1), 100 * 
> (ValueWhen(Short,C,1)-MaximumPrice)/ValueWhen(Short,C,1)); 
> 
> it doesnt work... Im not sure why!
> 
> Then i tried to get something to work in backtester with no good 
> results
> 
> 
> HELP!




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/DldnlA/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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

 
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/