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

[amibroker] Re:Dynamically change PositionSize



PureBytes Links

Trading Reference Links

I did this couple of days ago, not fully test yet. hope it might help.

delta = 3000;
if( Status("action") == actionPortfolio){
    bo = GetBacktesterObject();
    bo.PreProcess();
    for(bar = 0; bar < BarCount; bar++){
        profitSofar = Max(bo.Equity - bo.InitialEquity, 0); // profit can't
go below 0, a perfect world :)
        for(sig = bo.getFirstSignal(bar); sig; sig = bo.getNextSignal(bar)){
            // set position size for current signal
            sig.posSize = FixRatioPositionSize(delta, profitSofar) *
sig.MarginDeposit;
        }
        bo.processTradeSignals(bar);
    }

    bo.postProcess();
} // the end

Eric

Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.30/674 - Release Date: 2/7/2007 3:33 PM