Foreign("~~~EQUITY", "C" ) returns EMPTY

My call to Foreign("~~~EQUITY", “C” ) returns EMPTY. Can somebody tell me what I am doing wrong?

I am using the AFL in the Analysis window.
In my settings I have Initial Equity set to 1000000

In my code I also have:

SetOption("InitialEquity", 1000000 );
SetOption("UsePrevBarEquityForPosSizing", True );

You ask LOTS of questions that show that you did not read the manual.
You should start with reading the docs
http://www.amibroker.com/guide/a_equity.html

Excerpt:

Portfolio Equity special symbol

After running portfolio-level backtest, AmiBroker writes the values of portfolio equity to special symbol “~~~EQUITY”. This allows you to access portfolio-level equity of last backtest inside your formula.

The key words are “after running”. The symbol is available after you run backtest.

Believe me I did already read that page, but did not help. It can happen.

@zaxxon You have not given any information or the code you ran your backtest on. You ask what you are doing wrong but without any important information how can anyone help you? You may have done a dozen things “wrong” but we are left to gaze into our crystal ball and find an answer.

1 Like

As Thomasz’ link suggests, I had to run a backtest first to get this equity.