Topic: Getting Equity And Balance Values in Indicators

Hi,

I am trying to get equity values from with-in the indicator.

Currently I am using this: curBalance = Backtester.MoneyEquity(iBar); inside the calculate method.
But this function either remains same as initial balance or returns an abrupt value after a few 100 bars have been processed. I tested it during debugging as well. Same for all the other money and profit loss functions.

Is it possible to access the Backtester object or Session object through the indicator to get hold of these values.

I don't want to write additional code in the Backtest Calculator to process this indicator because then I will have to go and modify Forex Stratey Trader as well. And I want things to be kept as standard as possible.

Please advise.
Regards,
Riz

Re: Getting Equity And Balance Values in Indicators

Hi Riz,
Unfortunately this is not possible as is with FSB. (Mr Popov may have more comments). Based on the FSB source code, as I understand it, the indicator values are calculated first. The indicator's Calculate function runs over the entire bars, then returns the array of indicator values -- there is no information that gets in other than the Price series. Then, the backtester iterates through the bars, checking the array values from each indicator for a given bar and determines if it should open/close a position or not. If a position is open, it updates the floating balance / equity balance.

The only workaround I've found, which I don't recommend, is try to simulate the equity balance in the indicator. This is a lot of work, because you basically have to include all of your strategy into one indicator, and then simulate the backtest. And then, the equity balance I got did not match because of things like the spread, and rollover, and others. If I had to choose, I'd go with making a custom build of FSB and FST, it will probably work better and be a better solution your can use with different strategies.

sorry I could not help more
krog

Re: Getting Equity And Balance Values in Indicators

But I should be able to go through open positions and calculate current P/L of all open positions correct?
If yes then can you please point me to the function?

I am after something similar to Account Percent Stop but on the positive side.

Re: Getting Equity And Balance Values in Indicators

syedrizwanm wrote:

But I should be able to go through open positions and calculate current P/L of all open positions correct?
If yes then can you please point me to the function?

Unfortunately not -- the indicators calculate and return their values before the steps in Backtester.Calculate that figure out the open positions / account balances for the back test. The indicator calculations and position calculations are totally separate. The open positions and current P/L is available in the FSB source code, in the Backtester Calculator.cs (or Backtester class), you can check it as it goes in the TransferFromPreviousBar method, or from the Position/Session object at a given bar.

(Here though is about as far as I understand the source code; Mr Popov may have more insight on the exact methods for getting the info)

Re: Getting Equity And Balance Values in Indicators

You are correct. I so don't want to modify FST. I am more than happy to modify FSB. Because then result's can't be guaranteed.

Having said that is Popov the only person working on this or is he happy to have more developers working on this source code?

I don't see a centralized source control anywhere.

Regards,
Riz

Re: Getting Equity And Balance Values in Indicators

Yes, there is a centralized source control, give me a couple minutes, I'll find the thread ...

Re: Getting Equity And Balance Values in Indicators

Ok, for FSBuilder:

http://forexsb.com/forum/topic/2189/for … urce-code/

for FSTrader:
http://forexsb.com/forum/topic/2402/for … urce-code/

Then, it is controlled through GitHub -- an open source control web site. Using the site, I was able to get through the how-tos in about 30 - 45 minutes to get my version and start working with my local copy and branch on the site.

I've worked on the FSB code, but not the FST code.

Re: Getting Equity And Balance Values in Indicators

I have donwloaded the source code from there that's how I was working on it. But what I meant to ask was that if I make changes to the system how do I send it back to the community or Popov for that matter.

Re: Getting Equity And Balance Values in Indicators

Oh I see -- that's on the GitHub site. It lets you branch from Mr Popov's main branch, then download to keep a local copy. It has a download exe that controls uploading your changes from your machine to your branch on the website. After you've committed your changes, you send a pull request to Mr Popov, and he can merge your changes into the main branch.