Discussion of article "Developing a trading Expert Advisor from scratch (Part 11): Cross order system"

 

New article Developing a trading Expert Advisor from scratch (Part 11): Cross order system has been published:

In this article we will create a system of cross orders. There is one type of assets that makes traders' life very difficult for traders — futures contracts. But why do they make life difficult?

The image on the left is a typical futures contract, in this case it is MINI DOLLAR FUTURE, which started a few days ago, as can be seen from the chart. The chart on the right shows the same contract and contains additional data which actually represents the values of expired contracts, so the chart on the right is a historical chart. The chart on the right is more suitable for analyzing old support and resistance levels. But a problem arises if we need to trade. It is shows below:

          

Author: Daniel Jose

 

Congratulations on this excellent article Daniel.


I think the only problem will be at the turn of the year, when the "CurrentSymbol" function needs to look up the name of next year's symbol. It seems to me that the value of i1 will always return the number of the current year (22), but in December we already start using the symbol ending in 23.


 
Guilherme Mendonca name of next year's symbol. It seems to me that the value of i1 will always return the number of the current year (22), but in December we already start using the symbol ending in 23.


In reality, this problem won't happen and the reason for this is what makes the Loop end....

                                for (int i0 = 0, i1 = mdt1.year - 2000;;)
                                {
                                        m_Infos.szSymbol = StringFormat("%s%s%d", sz0, StringSubstr(sz1, i0, 1), i1);
                                        m_Infos.szFullSymbol = StringFormat("%s%s%d", sz2, StringSubstr(sz1, i0, 1), i1);
                                        if (i0 < StringLen(sz1)) i0++; else
                                        {
                                                i0 = 0;
                                                i1++;
                                        }
                                        if (macroGetDate(dt) < macroGetDate(SymbolInfoInteger(m_Infos.szSymbol, SYMBOL_EXPIRATION_TIME))) break;
                                }

Only when this condition is met will the loop end, and the value of i1 will always be incremented... so when the year is changed, the asset will be modified automatically ....

 
Daniel Jose #:

In fact, this problem won't happen and the reason for it is what causes the TIE to end....

Only when this highlighted condition is reached will the loop end, and the value of i1 will always be incremented... so when the year is changed, the asset will be modified automatically ....

You're right.

I hadn't paid attention to the line incrementing the value of i1.