Daily equity for monthly system

I asked this question before in forum and there were no answers.

I have a monthly strategy and I get monthly equity series with the code below but I would like to plot the daily changes of the equity and specifically interested in the low values.

CBT code here for the equity.

SetCustomBacktestProc("");
if( Status("action") == actionPortfolio )
{
bo = GetBacktesterObject();
bo.Backtest();
AddToComposite( bo.EquityArray, "~SystemEquity", "X", atcFlagDeleteValues | atcFlagEnableInPortfolio);
}

If the above ~SystemEquity is plotted on daily chart it has steps because due to backtester settings the equity is calculated monthly.

Is it possible to get the daily equity of the strategy based on daily price changes?

Thanks in advance.

No idea what you are exactly doing but you will have to start at the beginning.

What I read in your question is "Hello, I have monthly data, but I want to plot daily values".

To me that sounds impossible. You will have to go back to the start and start with daily data, daily bars, and work from there.

That is probably also why nobody can give you a solution.... they have no idea about what you are "adding to your composite"

Just my thoughts, might be completely in the wrong direction, but maybe it helps you.

gl

4 Likes

My question is clear. My system works with monthly bars but I want the daily equity based on daily market changes. I'm not going to change to daily bars for a strategy that works with monthly bars but I want to see the daily mark-to-market equity.

No idea of the strategy? Think of any monthly strategy like a monthly RSI(14) > 70 to buy and exit it if drops below 30.

The question is clear. Sorry you don't udnerstand it.

I am sorry, the answer is apperantly also clear, since 2 people see it as the solution to your problem...

You are allready saying it yourself.

My system works with monthly bars.......

How do you expect that you can then get daily equity ?

See it this way. Maybe that will be more clear.

You have an EOD system. You can not expect to get an intraday equity curve. You can only get an intraday equity curve if you are actualy using intraday data. You can use the OHLC for the EOD to make it an EOD system but there is no other way than actualy using the intraday timeframe to get the intraday equity curve.

But because you use monthly, you suddenly expect that it will work ?

Hope that makes the answer more clear :wink:

5 Likes

As @Henri has correctly pointed out, you have no visibility into bars that are smaller than your Periodicity setting. That includes both prices and the equity curve. Many people who develop weekly or monthly trading strategies actually use daily Periodicity for exactly this reason. It's not difficult if you're familiar with AmiBroker's timeframe manipulation functions.

Also, rude responses are typically not an effective way to persuade people to help you. If someone else is willing to contribute their valuable time to try to understand and solve your problem, then you should be grateful for their generosity, even if their answer is not the one you were looking for.

4 Likes

As other wrote you several times, it is very simple: you have to use DAILY (EOD) data to get Daily equity. The system can use monthly data and generate signals based on monthly data while periodicity is set to daily. To do so use TimeFrame functions Multiple Time Frame support

2 Likes

Thank you Tomasz. I tried to use this code but I get down jumps after an entry signal is triggered. There is something wrong with "EQUITY NEW" low values.

SetCustomBacktestProc(""); 
 
if( Status("action") == actionPortfolio ) 
{ 
    bo = GetBacktesterObject(); 
 
    NumTrades = AccumMAE = AccumMFE = 0;
    bo.PreProcess();
    for (bar = 0; bar < BarCount; bar++) // Loop through all bars
    {
        bo.ProcessTradeSignals(bar);
        for ( sig=bo.GetFirstSignal(bar); sig; sig=bo.GetNextSignal(bar) )
        {
            if (sig.isEntry())
            {
                NumTrades++;
                VarSet("Bar" + NumTrades, bar);
                _TRACE("Symbol " + sig.Symbol + " TradeEQ: " + VarGet("Bar" + NumTrades));
            }
        }
    }
     
    NumTrades = 0;
     
    for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() ) 
    { 
        NumTrades++;
        TradeBar = VarGet ("Bar" + NumTrades);
        if ( TradeBar != 0 )
        {
            AccumMAE = AccumMFE = 0;
            AccumMAE = VarGet ("AccumMAE" + TradeBar);
            AccumMFE = VarGet ("AccumMFE" + TradeBar);
            if ( AccumMAE != 0 )
                AccumMAE = AccumMAE + (trade.GetMAE() * trade.EntryPrice * trade.Shares * trade.PointValue / 100);
            else
                AccumMAE = trade.GetMAE() * trade.EntryPrice * trade.Shares * trade.PointValue / 100;
                 
            if ( AccumMFE != 0 )
                AccumMFE = AccumMFE + (trade.GetMFE() * trade.EntryPrice * trade.Shares * trade.PointValue / 100);
            else
                AccumMFE = trade.GetMFE() * trade.EntryPrice * trade.Shares * trade.PointValue / 100;
                 
            VarSet("AccumMAE" + TradeBar, AccumMAE);
            VarSet("AccumMFE" + TradeBar, AccumMFE);
        }
 
    } 
    bo.PostProcess();
     
    Eq = Foreign("~~~EQUITY", "C");
    EqO = Ref(Eq,-1);
    EQLow = EQHigh = 0;
    for (bar = 0; bar < BarCount; bar++) // Loop through all bars
    {   
        _TRACE("Eq " + Eq[bar]);
        iMAE = VarGet("AccumMAE" + bar);
        iMFE = VarGet("AccumMFE" + bar);
        if (iMAE != 0)
            EQLow[bar] = Eq[bar] + iMAE;
        else
            EQLow[bar] = Eq[bar];
        if (iMFE != 0)
            EQHigh[bar] = Eq[bar] + iMFE;
        else
            EQHigh[bar] = Eq[bar];
    }
  AddToComposite( Eq, "~~~EQUITY NEW", "C", atcFlagDefaults | atcFlagEnableInPortfolio ); 
  AddToComposite( EqO, "~~~EQUITY NEW", "O", atcFlagDefaults | atcFlagEnableInPortfolio ); 
   AddToComposite( EQLow, "~~~EQUITY NEW", "L", atcFlagDefaults | atcFlagEnableInPortfolio ); 
  AddToComposite( EQHigh, "~~~EQUITY NEW", "H", atcFlagDefaults | atcFlagEnableInPortfolio ); 
}