Add an amount to the current capital

Hey all,

Before asking my question, I'm French so please excuse me if I make some grammatical errors but I will do my best.

I would like to know if there is a way to simulate the recurrent addition of a certain amount to the current capital.

What I would like to do concretely is to add $1000 every months because that what I plan to do when I will invest using my formula.

So is modifying the current capital is possible in AFL ? :thinking:

PS: I would like to thanks the AmiBroker creator and the development team, I think it's the best investment I've ever made :hugs:

It is already there in AmiBroker manual see Examples 1 and 2:

/// Example 2: dollar-cost averaging (simplified formula because AB treats first sigScaleIn as buy anyway)
/// modified from:
/// @link
FixedDollarAmount = 1000;
SetPositionSize(FixedDollarAmount, spsValue);

MonthBegin = Month() != Ref( Month(), -1 );

Buy = IIf( MonthBegin, sigScaleIn, 0 ); // each month increase position
Sell = 0; // we do not sell

Thanks for your reply but I don't want to increase the position size, just the capital amount.

I'm opening a maximum of 20 positions with a size of 5% so I want to add $1 000 every months so the future positions that will be opened be bigger.

You can do that by adding $1000 to each month from inside a mid-level CBT. Just be aware that approach will change some metrics, like CAR.

1 Like

@cryptolowkey, So you want to add value to available cash every month?

That will require use of CBT

if (Status("action") == actionPortfolio) {
    bo = GetBacktesterObject();	
    new_month = Month() != Ref(Month(), -1);    
    for (i = 0; i < BarCount; i++) {
        bo.ProcessTradeSignals( i );	        
        if ( new_month[ i ] ) 
            bo.Cash += 1000;// add some amount to cash every start of month    

Thanks guys :ok_hand: