Postby SignalBender » Tue May 25, 2010 2:41 am
Well gang, some bad news.
Just got word that my idea of converting my system from Excel to MQL is simply not feasible. The reason is that the system in its entirety is massive relative to what MQL was designed to do. And, MQL's architecture is simply not programmatic enough to handle the logical relationships necessary to effectively reproduce the functionality necessary. I could give many examples, but here is just one:
The system uses both historical data and real-time data for its baseline calculations that generate Primary Indicators such as TCDs as one example. There are a couple dozen Primary Indicators alone at the core of the Engine. However, above that layer, resides the MetaIndicator layer and that's where the first problem hangs out. MetaIndicators are exactly what the name implies, Indicators of Indicators. So, MQL would need to have a facility for using the Output from Indicator_1 and using it as Input for Indicator_2, and that is just a small example of the MetaIndicator layering.
It is not uncommon in the system to either add 2 Indicator Output values together to derive a 3rd Indicator. Or, to then take the 3rd Indicator Output, add it with 3 other Indicators Output values to derive a 4th Indicator. Or, to then take the 3rd and 4th Indicator Output, run a mathematical calculation or logical statement against it to produce a 5th Indicator and then use that 5th Indicator Output as Input for a series of higher level Indicator Clusters. Nor, is it uncommon to see 10 Indicators producing the 11th, or 20 Indicators producing the 21st and so on.
From my understanding, MT4 starts to slow down when you significantly increase the number of Indicators running simultaneously and it is supposed to have an upper Indicator limit, beyond which you cannot load additional Indicators. In other words, MQL just can't handle the job of processing complex trading systems, fluently.
I've posted a power-point previously about how to integrate Excel into MT4 with no reply, so I won't post an idea I had on a possible multiple EA solution to the complexity problem in MT4, but I will say that the only concept for a solution that I can envision would be to run multiple EAs simultaneously across multiple machines and then pass output from each EA into a final EA designed solely for generating the Order (in essence the Trade Signal EA) on another machine.
So, basically, run an MT4 machine to just under its Indicator limit and classify that machine as EA_Indicator_1. Run the next MT4 machine to just under its Indicator limit and classify that machine as EA_Indicator_2, and so on, until all EA Output is passed to machine name EA_Order, where the trade is actually executed.
Otherwise, it is "Hello World" with a full-blown 32bit OOP Application, bypassing MQL altogether and going straight against the MT4 Server with the API, while building a real-time database with the lower-time interval data for the Excel Engine.
The problem with complex prototype systems, is that they are indeed complex and typically not built on a platform conducive to expansion or portability. Here is a more detailed explanation of the problem.
Let's say I wan to plot a straight linear line on an MT4 chart using this as the first data point, regressing back through the history of bars available:
Harmean(High[i]:High[i+1])+(15%*(High[i]-Low[i])/2)
Now, everyone I talk to says that MQL can easily handle this kind of work. But, this is just a line plot.
Here's the extrapolation that I came up with, including the data points that make up the linear plot:
Harmean(High[i]:High[i+1])
Harmean(High[i+1]:High[i+2])
Harmean(High[i+2]:High[i+3])
Harmean(High[i+3]:High[i+4])
Harmean(High[i+4]:High[i+5])
etc.
etc.
etc.
+
15%*(High[i]-Low[i])/2
15%*(High[i+1]-Low[i+1])/2
15%*(High[i+2]-Low[i+2])/2
15%*(High[i+3]-Low[i+3])/2
15%*(High[i+4]-Low[i+4])/2
etc.
etc.
etc.
Ok, you get the point. Easily done in MQL. But, again, it is just a line. A necessary line, but a just line nonetheless. Now, what happens when I need to place a dynamic price on the chart and then use that numeric value as either a Limit or Stop level. Here's what the output cell's dynamic price level code looks like inside the Excel Engine:
=IF(AE10>=O834,SUM(I828,AE10)/2,SUM(I828,G828)/2)
This is the ultimate problem with using MQL. Each one of the cells in the formula that make up this one dynamic price level, is itself a composite of other cells containing more calculations and to other data.
Note this dynamic price level uses 4 inputs (cells: AE10, O834, I828 and G828). Here are their individual break-outs:
AE10 = High[i+1]
O834 = SUM(K830:K834)/5-0.0005
I828 = G828+0.0025
G828 = E828+0.0025
Further extrapolation:
O834 uses input from the range K830 through K834. I828 and G828 both take input from one additional Indicator respectively with E828 being their dependency. Note that AE10 is the first in the sequence to actually use historical data from the market, the High of One Bar Ago.
Continuing the break-outs:
K830 = IF(CX75>=AR67,AR67,SUM(CX75,DH68)/2)
K831 = IF(D756="Short",SUM(F684,(((((DK76-0.0003)+(AE10+(FF30/10000)))/2)+(AF10+(AJ35*2.75)))/2))/2,(((((DK76-0.0003)+(AE10+(FF30/10000)))/2)+(AF10+(AJ35*2)))/2))
K832 = a value held in memory [I use macros to simulate the storing of values in memory]
K833 = E828+0.0025
K834 = G828+0.0025
I won't break down the details of K830 and K831 for time sake. [No circular references - my system has been debugged!]
And, this is just one lousy price level. We are not even talking about Indicator calculations yet! My goodness, to calculate this single dynamic price level in MQL would take how many lines of code?
There are 18 such dynamic limit level calculations in the system and 18 more entry level calculations, for a total of 36 dynamic variables that are all price level related (only). Here is just 1 of the 18 entry level calculations (they all contain different math and logic):
=IF(D550>0,D550,IF(AND(O539="Short",AR478="Long",AF499="Long",L574="Long",H529<>"Lead Short Off",AI736<>"Short Off",AI737<>"Short Off",AI738<>"Short Off",(AD9-J1151)>=0.002,R630="Short"),J1151,IF(AND(O539="Long",AR478="Short",AF499="Short",L574="Short",H529<>"Lead Long Off",AI736<>"Long Off",AI737<>"Long Off",AI738<>"Long Off",(J1151-AD9)>0.002,R630="Long"),J1151,IF(AND(Q782="Short",O539="Long",AG524="Long"),((AD9+0.0002)+(BP32-0.0015)),IF(AND(Q782="Long",O539="Short",AG524="Short"),((AD9-0.0002)-(BT32-0.0015)),IF(AND(L574="Short",O539="Long",V134="Long",AG524="Long",H529<>"Lead Long Off",AI736<>"Long Off",AI737<>"Long Off",AI738<>"Long Off"),(((AD9+0.0002)+(BP32*35%))+((AD9+0.0002)+((SUM(V135,O582)/2)*(U125*35%))))/2,IF(AND(L574="Long",O539="Short",V134="Short",AG524="Short",H529<>"Lead Short Off",AI736<>"Short Off",AI737<>"Short Off",AI738<>"Short Off"),(((AD9-0.0002)-(BT32*35%))+((AD9-0.0002)-((SUM(V135,O582)/2)*(W125*35%))))/2,0)))))))
I would be sitting here fore for two days straight just typing the break-outs of this cell. So, I won't bore you here. The Indicator logic gets far steeper than these dynamic price level formulas. In fact, I routinely hit the formula length limit in Excel where I end up spreading the entire formula across multiple cell regions, for a single Indicator.