Run a system to an equity symbol

After doing a backtest (or an optimization), I get an equity (~~~EQUITY).
I have changed its name to store it in a watch list (~~~EQUITY_Name), because I want to get more equities from differents systems.
After that, I have a watch list with all the equities in my portfolio.
In order to know which is the TOTAL equity of the portfolio (sum of all them), I have run a buy and hold system to the watch list, but I get a message saying that don’t recongnize the simbol (no simbol to apply the sistem).
Any idea to solve this issue?
Thank you very much in advance.

You need to move them OUT of group 253. Group 253 is special one for equities and composites so they are automatically EXCLUDED from backtest or any other Analysis operation (normally you don’t want equities and composites to be included in backtest as “stocks”).

1 Like

Hi Tomasz!!!
I have done everything as you have told me... I have changed name of the ticker (for instance, ~~~OSEQUITY_BOTIAS), I have moved the ticker from 253 to a different market (and group) called EQUITY.

Actually, I just want get the sum equity of the equities in a watch List. So I have use next code (buy and hold) which run to the watch list.

// BUY AND HOLD CAGIGAS (Informe 27/11/2013)
systemName = "Buy & Hold";
PositionSize=MarginDeposit=1;
Capital = Param("Capital inicial", 100000, 25000, 100000, 25000);  
SetOption("InitialEquity",Capital); 
SetOption("MaxOpenPositions",100); 
SetChartOptions(0, chartShowDates|chartWrapTitle);
Buy = Cum(1); 
Sell= 0; Short = Cover =0;
Plot(C, "Cierre", colorBlue, ParamStyle("Style Price"));
Title1 = StrFormat(EncodeColor( colorred ) + systemName + " " +Date() + EncodeColor( colorblack ) + "\n" + Name() + " "  
+ " Open %g, Hi %g, Lo %g, Close %g (%.1f%%)", O, H, L, C, SelectedValue( ROC( C, 1 )));
Title = Title1;

I have run the code to this watck list

imagen

And I get next error

"Notice No symbols matched Apply to / filtering criteria"

Of course, I don't usually take equity as a simbol to run trading system, but sometime (like this one) I want to run a code to an equity ticker (doing everything as you indicate).

Could anybody help me?

did you assign something here:
image

min spec. are point value...

Dio

@Dionysos thank you very much for your answer…
No I did not assign anything. I have it like the rest of all my simbols.
Point value is 1 and margin deposit is 1 too (I have writen it in the BUY AND HOLD code. I think I don’t need any more.
¿¿??

HI @Tomasz again,
First of all thank you very much for your dedication...
As you told me, I did everything you post in your message, even I have tried many different thing to solve it (changing the name without ~~~OSEQUITY_, following the suggestion of @Dionysos...).
It is estrange that an exploration to take the close of the "equity simbol" (equity each day) works properly recognizing the "equity symbol",

Filter = C AND ROC(C, 1, 1.2);
AddColumn(C, "Close", 1.2);
AddColumn(ROC(C, 1, 1.2), "ROC(1)", 1.2);

imagen

but it doesn't when I run a system (back test)...
I guess I could take this exploration, paste in a file and take as a symbol with import wizard, but I think this is not a good way to solve the problem...

Any idea??

As I wrote, make sure that you “EQUITY” is NOT group 253 (numerically). It is important.
Changing the NAME of group without actually MOVING symbol outside group NUMBER 253 won’t work. Name does not matter. What counts is the fact that the group is 253rd group. See Categories window.

You need to check the most basic things one step at a time. For example using this forumula

Buy = 1; // buy and hold
Sell = 0;

Set range to “ALL Quotes”

Run “SCAN”. Do you see single signal?
Then run a backtest. You should see one backtest.

1 Like

Hi Tomasz,
First of all Merry Christmast and Happy New Year....
On the other hand... believe me that I haven't wanted disturbe to you with this "easy" matter anymore... but I have done all your indications more than one time and I can`t run the backtest.
Even before you sent me last mail, I have done it by myself...
Of course I have move all the equities from the 253 group (now it is empty) to a new group (I have changed the names of the equities too, because I need to run the buy and hold code over some equities).
I have run an scan and it works properly. I see the signal as you told me.
But When I run a backtest I get next "Notice":

imagen

As you see in the mails above, I have checked and exploration too.... The problem come when I run a backtest.

If you want to verify the code I am using, which works properly to normal securities (I have tried of course the very simple version you wrote above) and It doesn't work...

/*// BUY AND HOLD CAGIGAS (Informe 27/11/2013)
systemName = "Buy & Hold";
PositionSize=MarginDeposit=1;
Capital = Param("Capital inicial", 100000, 25000, 100000, 25000);  
SetOption("InitialEquity",Capital); 
SetOption("MaxOpenPositions",100); 
SetChartOptions(0, chartShowDates|chartWrapTitle);
*/
Buy = 1; 
Sell= 0; /*Short = Cover =0;
Plot(C, "Cierre", colorBlue, ParamStyle("Style Price"));
Title1 = StrFormat(EncodeColor( colorred ) + systemName + " " +Date() + EncodeColor( colorblack ) + "\n" + Name() + " "  
+ " Open %g, Hi %g, Lo %g, Close %g (%.1f%%)", O, H, L, C, SelectedValue( ROC( C, 1 )));
Title = Title1;

So sorry, because I know this should be very very simple, but I don't know what happen, and I can't find my mistake...:cry:

I apreciate your help!!!

@svaztej I replicated your situation and got the same “Notice” using the backtest. Scan works, exploration (with the minimal code suggested by @Tomasz) works but backtest seems not to like the “equity” tickers/data.
I tried both 6.10 (32 bits) and 6.27.1 (54 bits). Same result. so probably there is still some missing and/or misunderstood step to have it properly working…

1 Like

~~~EQUITY ticker is special and it is marked specially so backtester normally skips that because NOT skipping it would create havoc.
So you should use this KB article to create COPY of equity array:
http://www.amibroker.com/kb/2006/03/11/how-to-create-copy-of-portfolio-equity/

3 Likes

Thank you for your last trick @Tomasz and for your checking @beppe…,
The problem I have found now is regarding with the walk forward test… In this case I get a flat equity (without any movement)…
Anyway, I could convert the OSEQUITY I get from the walkforward test by hand (export to excel and import as a new symbol to AB).
Just telling you, as a suggestion, it could be interesting to get this equity as a symbol after running a walk forward (after running a backtest is already solved with the article you recommend us) .
I use it to joing different equity from different system to know the equity of a systems porfolio running buy and hold system over them, and some statistics of this action…
Thank you very much (as always)

1 Like

Regarding with last post…
If it was possible to get the ~~~OSEQUITY after running a walk forward in the same way we did it when we run a a simple back test with the code you told us (http://www.amibroker.com/kb/2006/03/11/how-to-create-copy-of-portfolio-equity/).
I have tried to addapt it getting ~~~OSEQUITY like I show you below… (but it doesn’t work… :cry::cry::cry:)
I had to use the “foreign” version (prior to 5.50 AB), because I wanted to get the “symbol” ~~~OSEQUITY instead normal EQUITY (with the last version of the code with “bo.EquityArray”)

// A pre-5.50 way of making portfolio copy
// YOUR TRADING SYSTEM HERE
// ....
SetCustomBacktestProc("");
if( Status("action") == actionPortfolio )
{
 bo = GetBacktesterObject();
 bo.Backtest();
 AddToComposite( Foreign("~~~OSEQUITY","C"), 
                 "~~~MY_OSEQUITY_COPY", "X", 
                 atcFlagDeleteValues | atcFlagEnableInPortfolio );
}

I think It could be easy to adpat it, but I haven’t enough skills to do it…
Any help???

Thank you in advance… (:sweat::sweat::sweat:)

You could use EquityArray anyway as instructed in Knowledge Base. AddToComposite would concatenate values if you don’t use atcFlagDeleteValues flag. Also it is possible to use StaticVarAdd instead of composites. You can also use Symbol->Merge to create copy of ~~~OSEQUITY manually (merge to empty symbol without any quotes creates a copy)

1 Like

Well…
I have been doing some test, trying different choices with flag in composites… but I couldn’t get any result… :cry::cry::cry:
But, On the other hand, I didn’t realize the way to get the equity simbol by hand as you told me (with merge). In this case I have saved a lot of time to get the equities of my portfolio… So I am really happy…
Maybe when I had better skills I will get the trick and understand the authomatic way to take OSEQUITY… :sweat::sweat::sweat: little by little… (I am happy because I am learning a lot in AB… I feel sastified!!!)
Thank you very much again!!!

Hi again…
I have kept studying about this matter and using Foreign() calling to OSEQUITY instead bo.EquityArray I get the simbol of the OSEQUITY as I wanted… :sweat_smile::sweat_smile::sweat_smile:
But it only happend after running walk forward twice (first time I got flat OSEQUITY). I guess It have to be the way I am using actflag (I have copied and paste the expample from kb). I have tried other options with different actflag, but I have never got my goal…
I have write a very simple system to test it and I show you if you want to check it.
Thank again… I am learning a lot from all of you!!

//STARTING CAPITAL AND COMMISSIONS//
Com = Param("Comisión", 50, 10, 150, 10);
SetOption( "initialequity", 100000 ); // Capital inicial   
SetOption("PriceBoundChecking",1);
SetOption("CommissionMode", 2);
SetOption("commissionamount",Com);  // Coste de la comisión y estimación de deslizamiento en la entrada y la salida

//VARIABLES
//FUTURE DEFINITION
PointValue=50; //Es el multiplicador del miniSP500 @ES#C (IQFeed)
PositionSize = 1; //Siempre operamos un futuro
MarginDeposit = 1; //Entendiendo que hay capital suficiente para el análisis no hacemos restricciones por garantía

// PERIOD AVERAGE
periodoMT = Param("Periodo Media Tendencia", 220, 90, 300, 10); 

// RSI
periodoRSI = Optimize("Periodo RSI", 5, 5, 20, 5);
Lsup = Optimize("Umbral Sobrecompra", 90, 60, 90, 5);
Linf = Optimize("Umbral Sobreventa", 25, 10, 40, 5);

// Stop loss
stop = Param("Stop Loss", 6000, 1000, 10000, 500);

// CONDITIONS
//TREND FILTER
CondicionTendenciaAlcista = C >= MA(C, periodoMT);

//Overbought and Oversold
CondicionSobrecompra = RSI(periodoRSI) > Lsup;
CondicionSobreventa =  RSI(periodoRSI) < Linf;

//ACTIVATION
// LONG
Buy = CondicionTendenciaAlcista AND CondicionSobreventa;
Sell =  CondicionSobrecompra;

//NO SHORT
short =  0;
cover = 0; 

// NO EXTRA SIGNAL
Buy = ExRem(Buy, Sell OR Short);
Short = ExRem(Short, Cover OR Buy);
Sell = ExRem(Sell, Buy);
Cover = ExRem(Cover, Short);

// STOP LOSS
ApplyStop(stopTypeloss, stopModePoint, stop/PointValue, True, false);
Equity(1,0);  

//PLOTTING PRICE
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", colorDefault, styleNoTitle | styleBar); 

//PLOTTING AVERAGE
pintarMEDIA = ParamToggle("Pintar Media tendencial","No|Yes", 0);

if(pintarMEDIA==1)
{
Plot( MA(C, periodoMT), "Media tendencial", colorBlue, styleNoTitle + styleline);
}
//PLOTTTING RSI 
pintarRSI = ParamToggle("Pintar RSI","No|Yes", 0);

if(pintarRSI==1)
{
Plot(Linf, "Umbral Sobreventa", colorgreen, styleLine + styleThick +  styleLeftAxisScale + styledashed);
Plot(Lsup, "Umbral Sobrecompra", colorred, styleLine + styleThick +  styleLeftAxisScale + styledashed);
Plot(RSI(periodoRSI), "RSI", colorOrange, styleLine + styleThick +  styleLeftAxisScale);
}
 
SetOption("EveryBarNullCheck", True);
intradeLong = Flip(Buy, Sell OR Short);

//PLOTTING STOP LOSS
stoplineLONG = IIf(intradeLong, (valuewhen(Buy, BuyPrice -  stop/PointValue)), Null);

pintarSTOP = ParamToggle("Pintar Stop","No|Yes", 0);

if(pintarSTOP==1) 
{ 
Plot( stoplineLONG, "stop line", colorLightGrey, styleLine+styleDashed+styleThick); 
} 

// PLOTTING ACTIVATIONS
distancia = 3*ATR(14);
for(i=0; i<BarCount; i++)
{
if(Buy[i]) PlotText("buy\n" + BuyPrice[i], i, H[i]-distancia[i], colorGreen );
if(Sell[i] AND !Short[i]) PlotText("sell\n" + SellPrice[i], i, L[i]+distancia[i], colorRed);
if(Short[i]) PlotText("short\n" + ShortPrice[i], i,  L[i]+distancia[i], colorRed);
if(Cover[i] AND !Buy[i]) PlotText("cover\n" + CoverPrice[i], i, H[i]-distancia[i], colorGreen );
}

//PLOTTING SHAPES OF ACTIVATIONS
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorGreen,0,L,-15);   
PlotShapes(IIf(Buy,shapeHollowCircle,shapeNone),colorGreen,0,BuyPrice,0);   
PlotShapes(IIf(Sell AND !Short,shapeDownArrow,shapeNone),colorRed,0,H,-15);   
PlotShapes(IIf(Sell AND !Short ,shapeHollowCircle,shapeNone),colorRed,0,SellPrice,0);   
PlotShapes(IIf(Short,shapeDownArrow,shapeNone),colorRed,0,H,-15);   
PlotShapes(IIf(Short,shapeHollowCircle,shapeNone),colorRed,0,ShortPrice,0);   
PlotShapes(IIf(Cover AND !Buy,shapeUpArrow,shapeNone),colorGreen,0,L,-15);   
PlotShapes(IIf(Cover AND !Buy,shapeHollowCircle,shapeNone),colorGreen,0,CoverPrice,0); 

// A pre-5.50 way of making portfolio copy
// YOUR TRADING SYSTEM HERE
// ....
SetCustomBacktestProc("");
if( Status("action") == actionPortfolio )
{
 bo = GetBacktesterObject();
 bo.Backtest();
 AddToComposite( Foreign("~~~OSEQUITY","C"), 
                 "~~~MY_OSEQUITY_COPY", "X", 
                 atcFlagDeleteValues | atcFlagEnableInPortfolio );
}