Discussion of article "Naive Bayes classifier for signals of a set of indicators"

 

New article Naive Bayes classifier for signals of a set of indicators has been published:

The article analyzes the application of the Bayes' formula for increasing the reliability of trading systems by means of using signals from multiple independent indicators. Theoretical calculations are verified with a simple universal EA, configured to work with arbitrary indicators.

The formulas considered above are based on the assumption of independence of the analyzed random processes, which are the indicator signals in this case. But is this condition met?

Obviously, certain indicators, including many from the standard ones, have a lot in common. As a visual illustration, Figure 2 shows some of the built-in indicators.

Groups of similar standard indicators

Fig. 2. Groups of similar standard indicators

Author: Stanislav Korotky

 

The programming part, as always, is at the highest level! Practical part I almost didn't understand because of weak theoretical preparation.


Looking at fmtprnt2.mqh, there are a lot of warnings. Why did they decide to make such a template style?

    template<typename T>
    CFormatOut *operator<<(const T v)
    {
      if(typename(v) == "int" || typename(v) == "uint"
      || typename(v) == "long" || typename(v) == "ulong"
      || typename(v) == "short" || typename(v) == "ushort")

After all, for each type it would be possible to write a different operator variant and avoid corresponding compiler warnings.


ZЫ I think I understand. The Bible was written when the language didn't allow it yet.

 
fxsaber:

Looking at fmtprnt2.mqh, there are a lot of warnings. Why did they decide to make such a template style?

After all, for each type it would be possible to write a different operator variant and avoid corresponding compiler warnings.

ZЫ I think I understand. The Bible was written when the language didn't allow it yet.

Can I clarify the idea? In general, this file is not the most important in terms of the number of warnings. Some things can really be cleaned up.

If we are talking about functions with specific types, in fact, we always want to describe everything uniformly in one template, and not copy variants with different types, because why do we need templates then?

 
Stanislav Korotky:

Can I clarify the idea? In general, this file is not the highest in terms of warnings. Some things can really be cleaned up.

If we are talking about functions with specific types, in fact, we always want to describe everything uniformly in one template, and not copy variants with different types, because why do we need templates then?

I gave the link above. Enum can be identified there.
 

Do I understand the formula correctly: P(H|E) = P(E|H) * P(H) / P(E) (1), doing the calculation as follows:

P(H|E) = K2 *(1 / K1 )

In this case, I consider the indicator for buying, if it is above zero, I buy.

K2= is the result of dividing (ratio) the number of bars where the indicator is above zero and the deal was profitable / total number of bars.

K1= the ratio of the number of bars where the indicator is above zero / total number of bars.

 
forexman77:

Do I understand the formula correctly: P(H|E) = P(E|H) * P(H) / P(E) (1), doing the calculations as follows:

P(H|E) = K2 *(1 / K1 )

In this case, I consider the indicator for buying, if above zero, I buy.

K2= is the result of dividing (ratio) the number of bars where the indicator is above zero and the deal was profitable / total number of bars.

K1= the ratio of the number of bars where the indicator is above zero / total number of bars.

Yes. However, with this approach we should either make the trade duration 1 bar, or allow several open positions in the Expert Advisor, or count the probability not through the percentage of profitable ones, but, for example, as a dependence of the profit size on the indicator value (plus or minus), i.e. we should switch to probability densities.
 
Stanislav Korotky:
Yes. However, this approach requires either to make the trade duration 1 bar, or to allow several open positions in the Expert Advisor, or to calculate probability not through the percentage of profitable ones, but, for example, as a dependence of the profit size on the indicator value (plus or minus), i.e. to switch to probability densities.


Yes, the result with this approach will be blurred. I will probably replace the indicator above zero with the bar where the indicator crossed the zero mark.

I plan to make an indicator on this basis, the trades in it will be virtual and see what it will show. Maybe some significant extremums can be seen.

 
I wonder, because the Bayesian formula allows you to calculate the probability of an event depending on the probability of another, related event, and the indicators (at least those given in the article) are the same price, but viewed from the side. That is, isn't it an attempt to calculate the probability of a sandwich falling downwards depending on which side it falls on the floor?
 
fxsaber:

The programming part, as always, is at the highest level! The practical part I almost didn't understand because of weak theoretical preparation.

I will try to retell in my own words more simply:

1. Let there are three strategies:

  • strategy Strat_A based on indicator A with probability of a winning trade P(Win|A) =0.63
  • strategy Strat_B based on the indicator B with a probability of a winning trade P(Win|B) =0.58
  • strategy Strat_C based on indicator C with probability of a winning deal P(Win|C) =0.57

2. All three indicators A, B and C do not correlate with each other - i.e. they give signals to enter the market independently of each other.

3. It is required to calculate the theoretical percentage of winning trades for the Start_ABC strategy, in which market entry occurs only if all three indicators show entry in the same direction simultaneously.

Then P(Win|ABC) = P(Win|A)* P(Win|B)* P(Win|C) /[ P(Win|A)* P(Win|B)* P(Win|C) - (1 - P(Win|A))*(1 - P(Win|B))*(1 - P(Win|C))) ]


Right, @Stanislav Korotky?

 
Rashid Umarov:

I'll try to retell in my own words more simply:

Right, @Stanislav Korotky?

Yeah, that's pretty much how I was putting it ;-)

 
Stanislav Korotky:

Yes, that's almost what I was saying ;-)

Then the topic of another article - how to find indicators that are independent of each other automatically?

And then we almost have a simple KnowHow for creating robots from any indicator collection. Further, you can add trailing, mani-management and so on to the basic algorithm via the MQL5 Wizard.