Re: Tutorial: Building Custom Indicator with FSB

Popov wrote:

Is the current bar 0 or 62777?

We give the data series to the indicator via the Calculate method.

So, we can use the price directly with Close[Bars-1].

ok awesome that's what I thought, thanks Mr Popov!

p.s. how many indicators do I have to create to get a free copy haha smile

I am running out of computers to run the demo smile

Re: Tutorial: Building Custom Indicator with FSB

is there a way to draw an indicator into the future?

No, we cannot. The indicator uses the data series provided to it from the strategy.
You can "delay" the signals by using "shift" as in Moving Average:

 protected double[] MovingAverage(int period, int shift, MAMethod maMethod, double[] source)

But the shift cannot be negative. This limitation is done to provide equal behaviour in the tests and in the trading. Obviously we cannot see an indicator form the future in live trading, so we have not to use it for backtesting.

Re: Tutorial: Building Custom Indicator with FSB

you create a new IndicatorComp, and set the type to IndComponentType.AllowOpenLong. 
Then when that value is a 1 it will open a trade? Is that right?

Yes, this is correct.

We set "1" where the indicator allows an entry and "0" where no entry is allowed.

Re: Tutorial: Building Custom Indicator with FSB

also do the trades open on tick data (intrabar) or bar open? Is that decided by the indicator or FSB?

You can safely pretend that all calculations are executed on "tick" data. Actually there is no such thing, but the backtetsing engine cleverly puts a tick at the point of the execution. smile It is more "ticky" than the MetaTrader's "every tick" mode.

Re: Tutorial: Building Custom Indicator with FSB

how many indicators do I have to create to get a free copy haha smile
I am running out of computers to run the demo

Yes, FSB Pro is an excellent excuse to buy one more every two weeks smile


I'll give you an idea:

When the Trial expires, FSB Pro doesn't want to save strategies...
However it happily saves collections.

31 (edited by jetaro 2017-02-01 00:58:55)

Re: Tutorial: Building Custom Indicator with FSB

Popov wrote:

you create a new IndicatorComp, and set the type to IndComponentType.AllowOpenLong. 
Then when that value is a 1 it will open a trade? Is that right?

Yes, this is correct.

We set "1" where the indicator allows an entry and "0" where no entry is allowed.

Thanks for all the help Mr Popov, does that just mean whether long trade and short trades are allowed or is that the actual signal to buy/sell? I don't see anything else that looks like a buy/sell signal.

also I take it we cannot reference the ask or bid price separately, I assume it's always the ask price?

Re: Tutorial: Building Custom Indicator with FSB

Popov wrote:

how many indicators do I have to create to get a free copy haha smile
I am running out of computers to run the demo

Yes, FSB Pro is an excellent excuse to buy one more every two weeks smile


I'll give you an idea:

When the Trial expires, FSB Pro doesn't want to save strategies...
However it happily saves collections.

haha yeah, I don't think my wife would go along with that, but I agree it's a great excuse smile

thanks that's good to know!

33 (edited by jetaro 2017-02-01 06:14:55)

Re: Tutorial: Building Custom Indicator with FSB

ok, i finally figured out what my problem is. You say Bars-1 is the current bar, but that really means the last bar in the series.  I need to backtest my indicator and i need bar to equal the bar it's currently testing. Using bar-1 just means the very last bar, so the back test doesn't show anything.  So let me re-phrase my question, what variable is the current bar the backtester is working on.  Does that make sense?  thanks!

EDIT - ok I think I understand now. I'm so used to metatrader and trading station coding/backtesting.

I see since the data set is loaded in advance, I need to create my own loop to represent the current bar,
as in for (int bar = 0;bar < Bars; bar++)
then bar is the current bar for the calculations.

Re: Tutorial: Building Custom Indicator with FSB

Probably you missed the very big difference between the FSB Pro and MT backtesting engine:
- MT re-calculates indicators at every "tick". Here tick means a particular price in the data series. It starts from the beginning and goes forward to the newest bar.

- FSB Pro calculates the indicators only once for the complete DataSet. Depending on the indicator's role it uses different "components" of type IndComponentType  to save the output values. The IndicatorComponent has a value array. It is with the length of the DataSet. The "value" have one value of type "double" for each bar.

Value of 0 means no entry/ exit price or entry/exit signal.

   - IndComponentType.OpenLongPrice - the component.value stores the entry price for a long position. It has one entry price for a bar. It can be bar Open for indicators as "Bar opening" or other value for indicators as "Moving Average" or "Pivot Point"
   - IndComponentType.OpenShortPrice - stores an entry price for short positions.
   - .OpenPrice - entry price for both long and short entries. This can be used for indicators that have a single entry price (Moving Average, Bar Opening...)
   - .CloseLongPrice, .CloseShortPrice, .ClosePrice - are the same as above but FSB checks them for closing.

   - .OpenClosePrice - here you can set a single value that will work for both entry and exit in both directions. (for example Moving Average)

  - .IndicatorValue - you use this type to store a value that you want to show in the chart or in the dynamic info, but it doesn't affect the trading. For example, the middle line of Bollinger Bands.

- .AllowOpenLong, .AllowOpenShort - you set 0 or 1 for these types. FSB uses them to check if long or short entry is allowed for the bar.

- .ForceCloseLong, .ForceCloseShort, .ForceClose the same as above but for "allowing" closing signals.

Re: Tutorial: Building Custom Indicator with FSB

awesome thanks Mr Popov, that's exactly the information I was looking for!
by the way, I have to say I'm very impressed with what you have created.
You basically not only created your own strategy tester/builder but also pretty much your own language smile
My only concern continues to be the chance for differences between the .cs indicator and the .mq5 one that needs to be created separately.  I'm not sure if you downloaded the 2 indicators I created. I'm still not 100% confident that my mql code is working exactly like my .cs code.   I still see cases where sometimes when I backtest in MT5 the results look similar, and yet sometimes they are totally different.  It will show a great equity curve in FSB but then it will lose in MT5.
Do you know what may cause that discrepancy other than the mq5 code not matching the .cs?
Thanks again and have a good day,
Jim

Re: Tutorial: Building Custom Indicator with FSB

haha  no way I can answer questions about indicators, I know zilch...... I am learning from your questions...

A couple people have learned a lot about the indicators...... Footon is one of those......, myself, I am just hoping you keep asking questions. lol

Re: Tutorial: Building Custom Indicator with FSB

well thank you for at least looking and trying to help smile

I haven't seen Footon recently, in fact it doesn't seem there have been any new indicators in quite awhile.

Re: Tutorial: Building Custom Indicator with FSB

Footon is here most of the time only posts when he is concerned.

Actually, we have so many choices of indicators that additional ones are not really required. There are only a couple primary purposes for indicators like trend and range and volatility....... and I am sure those are adequately covered with the present inventory.

By adding indicators, we reduce processing time and complex what we are trying to do.

The generator explores all possibilities of the math on a random basis....... there are literally thousands of calculation patterns, maybe millions, available for the generator....... considering that each indicator has five or seven variables.

My current interest in indicators is to reduce the number of iterations to get to the good news quicker.