Brokerage in ami

trash

Well-Known Member
#3
Add this to your system code and set commission method and amount.
See SetOption. Additional code will create two additional columns and in report at the bottom you will also see the total commission amount.

Code:
SetOption( "CommissionMode", 2 );//overrides SETTINGS, 0 = Commision Table; 1 = percent; 2 = $ per trade; 3 = $ per share/contract
SetOption( "CommissionAmount", 2.5 ); // currently $ amount enabled

//Custom Metrics
//First we need to enable custom backtest procedure and tell AmiBroker to use current formula
SetCustomBacktestProc( "" );

//Now custom-backtest procedure follows
if ( Status( "action" ) == actionPortfolio )
{
    bo = GetBacktesterObject();
    bo.Backtest( 1 ); // run default backtest procedure. 

    SumCosts = 0;

    // iterate through closed trades first
    for ( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
    {
        //  Loop through all closed trades
        Comm     = trade.GetCommission();
        SumCosts = SumCosts + Comm;

        trade.AddCustomMetric( "Trade Commission", Comm ); // visible in result list
        trade.AddCustomMetric( "Sum Commission", SumCosts ); // visible in result list
    }

    bo.AddCustomMetric( "Sum Commission", SumCosts );   // visible in report

    bo.ListTrades();
}
 
Last edited:
#5
SORRY for late but my system giving problem all these days so can t log in...


anyway it works in afl but charge comm only 5 pts per trade where I have brokerage in percentage in my setting
so how I get it?

So just half an hour after your multiple smilies disorder you have disappeared all of the sudden?
 
#6
SORRY for late but my system giving problem all these days so can t log in...


anyway it works in afl but charge comm only 5 pts per trade where I have brokerage in percentage in my setting
so how I get it?
Read the first two lines of Trash's code carefully! It's mentioned there how to activate percentage. In the second line you enter the amount.
 

Similar threads

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?