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

RE: [amibroker] Fixed Ratio Trading in Amibroker



PureBytes Links

Trading Reference Links

> Message: 9
>    Date: Sat, 04 Jun 2005 20:52:56 -0000
>    From: "thechemistrybetweenus" <thechemistrybetweenus@xxxxxxxxx>
> Subject: Fixed Ratio Trading in Amibroker
> Hi,
> I just finished reading Ryan Jones excellent book on Fixed Ratio Money
> Management. Anyone familiar with the topic and how It could be done in
> Amibroker?
> Eric

Hello Eric,

I have been struggling with implementing this also (I read about it in a
different book though).  It turns out I needed to use the custom
portfolio back tester interface, so I can dynamically size the position
based on current equity.

This is what I have come up with.  Let me know if you spot any errors
:-)

Seems to work but I could be doing something wrong so test it for
yourself before you use it...

BTW: This is written for futures contracts.

SetOption("UseCustomBacktestProc", True);

Delta = 10000;
ContractMin = 1;
ContractMax = 150;

if (Status("action") == actionPortfolio)
{
    bo = GetBacktesterObject();
    bo.PreProcess();

    for (bar = 0; bar < BarCount; bar++)
    {
        for (sig = bo.GetFirstSignal(bar); sig; sig =
bo.GetNextSignal(bar))
        {
            if (sig.isEntry() && sig.IsLong())
            {
                capital[bar] = bo.Equity - bo.InitialEquity;
                capital[bar] = Max(0.01, capital[bar]);
                contracts[bar] = 1 + floor(sqrt(0.5 + ((2 * capital[bar]
/ delta[bar]) + 0.25)));
                contracts[bar] = Max(Min(contracts[bar],
ContractMax[bar]), ContractMin[bar]);
                sig.PosSize = sig.MarginDeposit * contracts[bar];
            }
        }
        bo.ProcessTradeSignals(bar);
    }
    bo.PostProcess();
}

Buy = Cross(EMA(C, 10), EMA(C, 30));   // An example system :-)
Sell = Cross(EMA(C, 30), EMA(C, 10));

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

RoundLotSize = TickSize = 1;
PointValue = 25;      // $25 AUD per point
MarginDeposit = 2200; // Australian SPI contract margin deposit




=======================================================
                                     IMPORTANT INFORMATION

This message and any files transmitted with it are confidential and should be read only by those persons to whom it is addressed.   
If you have received this message in error, please notify us immediately by way of reply. Please also destroy and delete the message from your computer. Any unauthorised form of reproduction of this message is strictly prohibited. 

It is the duty of the recipient to virus scan and otherwise test the information provided before loading onto any computer system.  
SEALCORP does not warrant that the information is free of a virus or any other defect or error.

SEALCORP is not liable for the proper and complete transmission of the information contained in this communication, nor for any delay in its receipt.

Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of SEALCORP.

=======================================================



------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/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/