Discussion of article "Adaptive Trading Systems and Their Use in the MetaTrader 5 Client Terminal" - page 2

 

Is it a bother to translate the documentation to English? I always appreciate some good docs. Great article, thanks for your awesome contribution. 

 
Lugner:

Is it a bother to translate the documentation to English? I always appreciate some good docs. Great article, thanks for your awesome contribution. 

We will translate the attached documentation as soon as possible.
 

To work with input parameters (variables), it's easy with just declaring them before class declaration, and

following the the class (includes) calling path.

 
Lugner:

Is it a bother to translate the documentation to English? I always appreciate some good docs. Great article, thanks for your awesome contribution. 

Thank you. The documentation is translated.
 
AM2:

In the CAdaptiveStrategy class I try to trade only stochastics:

I disabled the rest, but the chart in the tester is still the same. As far as I understand, this is where strategies are connected and disconnected?

Yes, strategies are connected in the CAdaptiveStrategy::Expert_OnInit() function. For convenience, it is better to use the debug-version of the Expert Advisor, it has added saving the results to files. You can figure out which signals of which strategies were used in real trading by using the file direction_res.txt.

When using an adaptive strategy consisting of the specified 5 stochastics(EURUSD H1, test from the beginning of 2010 to 1 September 2010), the following results are obtained:




 

This is probably the most thought provoking article I have read on programmatic/robotic trading for a very, very, long time. A big thank you!

Acting on this new enthusiasm, I have adapted Eugene's work a little. [Apologies - at least I too will share ideas ;-) ]

I adapted an existing EA (not Object Oriented yet, unfortunately) for:

1. Multiple time scales:  M1, M3, M5, M10, M20, M30, H1
2. Multiple Fast MA's:  3,5,7,9,11
3. Multiple Slow MA's:  17,27,37,47 etc 97,107, 117 etc

Attached to an M1 tick, on a foreach(period)-foreach(fast)-foreach(slow) loop. Each tick works out if it needs to check for a 'virtual' trade, and 'executes' if need be, keeping a logical/virtual P/L balance.

Results are very suprising, and very positive ...

Optimisation is now in the areas of removing short time periods (e.g. M1, M3) [as higher time periods eventually 'win'], and also in determining how often to clear down the 'running P/L' counter to allow for detection of 'rapidly improving' parameter sets.

I have also to interface my favourite trading EA into this work (to add ADX/RSI/MACD/RVI checks etc), so that it always uses optimal, winning fast/slow MA pairs, and also has good market, money, position and trade management logic.

Thanks again,

T. 

 

Quantum,

  obviously if i want add more buy and sell conditions (or pairs/combos of buy and sell conditions), apart from the still gifted 

  

if(buy_condition_1 && buy_condition_2) new_state=SIGNAL_OPEN_LONG;
if(sell_condition_1 && sell_condition_2) new_state=SIGNAL_OPEN_SHORT;

 in example in CStrategyMA.mqh,

  to trigger other opportunities for

new_state=SIGNAL_CLOSE_SHORT;
// and 
new_state=SIGNAL_CLOSE_LONG;

  it have not logical sense to add those combos  in the file  CStrategyMA.mqh, but for every new conditions or pairs/combos 

  of conditions, it should be dedicated another include/class file,

 

that's right?

 

I rapidly mean, in example, if i want add those conditions:

// Buy condition 3: MA new 
   bool buy_condition_3=(m_values[0+5]>m_values[1+7]) && (m_values[1+5]>m_values[2+7]);
// Buy condition 4: previous OPEN price is higher than MA
   bool buy_condition_4=(p_open>m_values[1]);

// Sell condition 3: MA new 
   bool sell_condition_3=(m_values[0+5]<m_values[1+7]) && (m_values[1+5]<m_values[2+7]);
// Buy condition 4: previous OPEN price is lower than MA
   bool sell_condition_4=(p_open<m_values[1]);

and 

  if(buy_condition_3  &&  buy_condition_4) new_state=SIGNAL_OPEN_LONG;
   if(sell_condition_3 && sell_condition_4) new_state=SIGNAL_OPEN_SHORT;

   if((GetSignalState()==SIGNAL_OPEN_SHORT) && (buy_condition_3 || buy_condition_4)) new_state=SIGNAL_CLOSE_SHORT;
   if((GetSignalState()==SIGNAL_OPEN_LONG) && (sell_condition_3 || sell_condition_4)) new_state=SIGNAL_CLOSE_LONG;

 it can be added in sub-classes within CStrategyMA.mqh, without affecting the core system of the 

adaptive system, in other words with continuing correctly this include file CStrategyMA.mqh interact with CAdaptiveStrategy.mqh

and CSampleStrategy.mqh, also taking consideration of the new conditions (3 and 4 of the example) in the logical core

of the EA idea?

Or for the condition 3 and 4, i should rewrite and add, for example, a file CStrategyMA3and4.mqh ???

It is possible to add those conditions within the same  CStrategyMA.mqh and working all correctly?

Maybe i've the reply by myself and i'm bit stupid, but also want ask your opinion(s)..

 

Thanks 

 
Automated-Trading:

Yes, strategies are connected in the CAdaptiveStrategy::Expert_OnInit() function. For convenience, it is better to use the debug-version of the Expert Advisor, where saving results to files has been added. You can figure out which strategy signals were used in real trading by using the direction_res.txt file.

When using an adaptive strategy consisting of the above 5 stochastics (EURUSD H1, test from the beginning of 2010 to the 1st of September 2010), the following results are obtained:

Judging by the chart you have again simply an optimised model, even if part of this optimisation turned out to be automated, but an adapted model is a model in which there is a calculation block that adapts the entry and exit to the market during the strategy operation, and the parameters in the initialisation do not matter at all. In such conditions, just the equity line in relation to the balance line will be equalised, because in cases when the distribution for closing a position by profit has changed - such a system will still recalculate new values and determine a new zone for profit, and therefore will rebuild the parameters for profit and the group of equity orders will be preserved:
Files:
 

Dear Forexistence,

You have answered your question :)

You are right, there are two ways if you want to modify trading conditions, from one side we can add new conditions to strategy CStrategyMA (but we will get the new strategy, different from the initial), the other way is to create a new class (for example, CStrategyMA34) and add additional buy/sell conditions there.

But of course, you should include file with your new strategy and add these new strategies to the Expert_OnInit function of CAdaptiveStrategy class:

#include <CStrategyMA3and4.mqh>

int CAdaptiveStrategy::Expert_OnInit()
{
.....
--- adding new strategies
   for(int i=0; i<10; i++)
     {
      CStrategyMA34 *t_StrategyMA34;
      t_StrategyMA34=new CStrategyMA34;
      if(t_StrategyMA34==NULL)
        {
         delete m_all_strategies;
         Print("Error of creation of object of the CStrategy3and4 type");
         return(-1);
        }
      int period=3+i*10;
      t_StrategyMA34.Initialization(period,true);
      t_StrategyMA34.SetStrategyInfo(_Symbol,"[MA34_"+IntegerToString(period)+"]",period,"Moving Averages with new conditions "+IntegerToString(period));
      m_all_strategies.Add(t_StrategyMA34);
     }
.....
}

The second way is better, you can add many strategies and their variations.

It isn't necessary to remove the CStrategyMA class instances (if you have ones), we will not look in their sandboxes in their results will be bad.

The market will help us to determine the best strategy in the list of strategies, included in m_all_strategies.

 
dasmen:
Judging by the chart, you again have simply an optimised model, even if part of this optimisation was automated, but an adapted model is a model in which there is a calculation block that adapts the entry and exit to the market during the operation of the strategy, and the parameters in the initialisation do not matter at all. In such conditions, just the equity line in relation to the balance line will be equalised, because in cases when the distribution for closing a position on profit has changed - such a system will still recalculate new values and determine a new zone for profit, and therefore will rebuild the parameters for profit and the group of equity orders will be preserved:

the article uses the concept and application of adaptive strategy as in mathematics, in fact as a system for implementing management choices.