Who wants a strategy? Lots and for free) - page 61

 
Stellarator >> :

My friends called me to cheat on the car...

>> well...

And they say crisis ;)

 

It seams we have to start comparing one by one until fix all issues.

Here I compared FSB Accelerator Oscillator to MT iAC(...):



How to do this:

1. Update the forex rates of FSB with the current ones used in MT. (From MT Ctrl+S and save the xxxxxx.csv file in the FSB ./Data directory. If your data are in a different folder - use Market -> Data Directory from FSB to point it.)

2. Make the script Indicator_Values.mq4 printing the desired indicator. (The script is on the previous forum's page.)

3. Set this indicator in FSB. (Be sure using the same parameters.) Export the FSB indicator by function Export -> Indicators.

4. If you see any difference, please report it.


Have a nice luck!


------------

Edit:

Please use the latest FSB v2.8.3.5 Beta

 
Miroslav_Popov >> :

The classical formula is: Momentum(n) = Close - Close(n)

This is the formula FSB uses.

MT uses: Momentum(n) = 100 * Close / Close(n)

I know that. I was referring to the indicator parameters. Smoothing period. Smoothing method. We don't set it. What parameters are taken by default: 0,0?

 

Hi zfs,


You can see the default parameters in the Indicator Parameters dialog window. (Press Default)



Note that "Additional smoothing" period = 0. That means no smoothing is applied.


The second place where you can see the default values is in the source code:


        /// <summary>
        /// Sets the default parameters for the designated slot type
        /// </summary>
        public Momentum( SlotTypes slotType)
        {
            sIndicatorName  = "Momentum";
            parameters      = new IndicatorParam();
            component       = new IndicatorComp[] { };
            bSeparatedChart = true;
            bIsCalculated   = false;

            // The indicator name
            parameters. IndicatorName = sIndicatorName;

            // The slot type
            parameters. SlotType = slotType;

            // The ComboBox parameters
            parameters. ListParam[0]. Caption  = "Logic";
            parameters. ListParam[0]. ItemList = new string[]
            {
                "The Momentum rises",
                "The Momentum falls",
                "The Momentum is higher than the Level line",
                "The Momentum is lower than the Level line",
                "The Momentum crosses the Level line upward",
                "The Momentum crosses the Level line downward",
                "The Momentum changes its direction upward",
                "The Momentum changes its direction downward"
            };
            parameters. ListParam[0]. Index    = 0;
            parameters. ListParam[0]. Text     = parameters. ListParam[0]. ItemList[ parameters. ListParam[0]. Index];
            parameters. ListParam[0]. Enabled  = true;
            parameters. ListParam[0]. ToolTip  = "Logic of application of the indicator.";

            parameters. ListParam[1]. Caption  = "Smoothing method";
            parameters. ListParam[1]. ItemList = Enum. GetNames( typeof( MAMethod));
            parameters. ListParam[1]. Index    = 0;
            parameters. ListParam[1]. Text     = parameters. ListParam[1]. ItemList[ parameters. ListParam[1]. Index];
            parameters. ListParam[1]. Enabled  = true;
            parameters. ListParam[1]. ToolTip  = "The Moving Average method used for smoothing the Momentum value.";

            parameters. ListParam[2]. Caption  = "Base price";
            parameters. ListParam[2]. ItemList = Enum. GetNames( typeof( BasePrice));
            parameters. ListParam[2]. Index    = 3;
            parameters. ListParam[2]. Text     = parameters. ListParam[2]. ItemList[ parameters. ListParam[2]. Index];
            parameters. ListParam[2]. Enabled  = true;
            parameters. ListParam[2]. ToolTip  = "The price the Momentum is based on.";

            // The NumericUpDown parameters
            parameters. NumParam[0]. Caption = "Period";  <----- Parameter Name
            parameters. NumParam[0]. Value   = 10;        <----- Default Value
            parameters. NumParam[0]. Min     = 1;
            parameters. NumParam[0]. Max     = 200;
            parameters. NumParam[0]. Enabled = true;
            parameters. NumParam[0]. ToolTip = "The period of Momentum.";
 
            parameters. NumParam[1]. Caption = "Additional smoothing"; <----- Parameter Name 
            parameters. NumParam[1]. Value   = 0;        <----- Default Value
            parameters. NumParam[1]. Min     = 0;
            parameters. NumParam[1]. Max     = 200;
            parameters. NumParam[1]. Enabled = true;
            parameters. NumParam[1]. ToolTip = "The period of additional smoothing.";

            parameters. NumParam[2]. Caption = "Level";  <----- Parameter Name
            parameters. NumParam[2]. Value   = 0;        <----- Default Value
            parameters. NumParam[2]. Min     = -100;
            parameters. NumParam[2]. Max     = 100;
            parameters. NumParam[2].Point   = 4;
            parameters. NumParam[2]. Enabled = true;
            parameters. NumParam[2]. ToolTip = "A critical level (for the appropriate logic).";

            // The CheckBox parameters
            parameters. CheckParam[0]. Caption = "Use previous bar value";
            parameters. CheckParam[0]. Checked = Data. Strategy. PrepareUsePrevBarValueCheckBox( slotType);
            parameters. CheckParam[0]. Enabled = true;
            parameters. CheckParam[0]. ToolTip = "Use the indicator value from the previous bar.";
        }
 
Miroslav_Popov >> :

Hi zfs,

I didn't doubt your flawlessness in principle. The thing is, in spite of all this, the end values of the indicators don't match up for me. Or did they not? I have no time to check it now, unfortunately.

 

Zfs,

With the help of Stellarator I fixed many issues in FSB. I also changed the default parameters of FSB to be like this in MT. I hope most of the differences are fixed already.


Please don't hesitate to report any possible bugs. All feedback and critiques are well appreciated.

 
Stellarator >> :

I have to dissuade you! The key nuance is the "limit of one iteration of the EA". So, within these limits, the indicator is calculated ONE time (at its first call)! I declare this with 100% confidence. All subsequent calls don't start() it at all, but only take the necessary values from the necessary buffers. The condition is 100% when the input parameters remain unchanged (except for the buffer and offset). The rule works when calculations are performed within a single instrument. But I think the principle holds even when iCustom refers to other TFs and tools.


I am interested in writing an Expert Advisor that applies to the indicator for the value of the indicator in the current minute on the 0th bar 240 times. I.e. it turns out that the output always has the first value? Confirm please, because this is news to me.

 
zfs >> :

Off-topic question, I just got involved in writing an Expert Advisor, which on the 0th bar 240 times accesses the indicator for the value of the indicator in the current minute. I.e. it turns out that the output is always the first value? Confirm please, because this is news to me.

>>The Expert Advisor restarts on every new tick and this is a different iteration, and therefore the indicator values will be different.

 
rider >> :

The EA will restart on every new tick, and this is a different iteration, and therefore the indicator values will be different.

If you use "Use previous bar value" parameter correctly you don't need the current bar value of the indicator.

Let say you us MA(simple, 12, close) on a daily chart. To calculate this MA correctly you need the closing prices of 12 bars.

If now is 3PM, the current "close" price is not the real close price of the bar. It is going to be changed till 12PM. So using MA for the current bar doesn't include the real close price but a temporary one. In the same time the back test uses real (already fixed) closing price of the historical bars. This practice will bring differences between the backtest and the real trade.


Even worse:

Let see the logic rule "A FastMA goes above a SlowMA" where both MAs are based on Close price.

If during the day the market rises rapidly, the FastMa can cross above the SlowMA, which will rise a buy signal. You will buy following the signal. Let after the deal the market goes down and closes so lower, that will move the FastMA below the Slow one. Do you see the problem? You have already bought befor the close of the bar. If you backtest this strategy later, you will see that there is no such buy signal for within this bar. And what? You will blame the backtester, but the problem is in the wrong strategy logic.


The Forex Strategy Builder protects you from such logical errors by altomatically setting the "Use previous bar value" parameter. FSB never uses changing (not yet fixed) indicators for backtesting. And in that logic why an EA has to calculate an indicator for every tick if the strategy don't use it. One calculation per bar is enough:

- if the indicator uses Open price - the calculation has to be at bar opening;

- if the indicator uses Close, High, Low or any combination of the prices - the calculation has to be at bar closing.






 

Good evening everyone!


I'm without a computer for the weekend :(. And today I just had nothing to do because of work, so... somehow...

Had time to think, though. And (hopefully) decided strategically (in terms of indicator framework).

In general, the internal structure of the indicators from now on will be similar (I will describe it later, maybe tomorrow). What "sticks out" to the outside (parameters) - as close to FSB as possible. I.e. their number, values (and their boundaries) and the functionality defined by them - well... almost one to one :). Micro nuances remain, but we'll decide it as we go along.


Very briefly for now (I'm going to bed now, I won't be here tomorrow or the day after, probably, I have a lot of things to do at work) (by the example of "our lovely" RSI :D):

1. Parameters:

// -------- Indicator parameters
extern int     slotType = SLOT_TYPE_OPENFILTER; // SLOT_TYPE_LC
extern int     indLogic = INDICATOR_RISES;      // INDICATOR_RISES <= indLogic <= INDICATOR_CHANGES_DIR_DOWNWARD
extern int     maMethod = MA_METHOD_SMOOTHED;   // MA_METHOD_SIMPLE <= maMethod <= MA_METHOD_SMOOTHED
extern int     basePrice= BASE_PRICE_CLOSE;     // BASE_PRICE_OPEN <= basePrice <= BASE_PRICE_WEIGHTED
extern int     iPeriod  = 14;                   // 1 <= iPeriod <= 200
extern int     dLevel   = 30;                   // 0 <= dLevel <= 100
extern bool    iPrvs    = True;                 // True / False




I think it's more or less clear from the picture as it is. The only thing that can cause difficulty: slotType, its respective values (which perhaps differ from FSB, but in this case it is not a major point):

// Slot Types
#define  SLOT_TYPE_OPEN                   0  // Point of the Position
#define  SLOT_TYPE_CLOSE                  1  // Point of the Position
#define  SLOT_TYPE_OPENFILTER             2  // Logic Condition
#define  SLOT_TYPE_CLOSEFILTER            3  // Logic Condition

The rest is simple. Numerical values are set as is. Values in ComboBoxes are numbered starting from 0 (like arrays).

Numerical values of smoothing methods and price constants are DIFFERENT from MT (I've been thinking a long time, but decided to break stereotypes for the sake of FSB compatibility :) ). All this, in fact, is done so that in the future the Expert Advisors (or what users will write themselves) can "twitch" the indicators easily and unforced :) (what they saw in FSB is what they set ("what I see is what I sing")). Roughly:

double dRSI = iCustom(NULL, 0, "-FSB- RSI", 2, 0, 3, 3, 3, 14, 30, 1, 0, 0);

for above example.


2. Returned values:

The first two indicator buffers in each indicator are reserved for position open prices (long/short respectively), or for logical conditions (1.0 - yes / any other value - no). Further we have the indicator values themselves (in case they will be interesting for somebody):


The contents of the first two buffers are determined by the logic of indicator(slotType and indLogic) (i.e. once again - there are either prices or 1 / 0 (I recommend to check it with "1", because other values can be not only zero (in general - as the indicator has no value there can be EMPTY_VALUE)).


All the indicators have been optimized taking into account IndicatorCounted() (this is the main change of the original code, by and large) (Miroslav is right, in general case - you should recalculate indicator values once per bar (again - in general case... ;)). But for correct visual display, and in general (good tone)... In general, it shouldn't slow down much.


For rendering coloured and similar ("especially gifted" :)) indicators graphical objects are used (not to occupy extra buffers). I have tested it myself and it works fine (when visually displayed, it is slower than indicator buffers, but not too critical, and when iCustom is called, graphic functions are not called at all, so "excesses" will not affect the speed).


That's all for now, I have a couple of questions for Miroslav, but I'm already exhausted :), I'll try to ask them tomorrow (but I will, as I said before - with haste)...


p.s. Before you move the files from the archive - delete fsb*.mq4 files in Experts\Indicators\ folder. The rest just need to be overwritten over the old one. From now on the file naming conventions will not change (all the indicators will have the "-FSB- " prefix).

Files:
experts_1.rar  148 kb
Reason: