C# developers who want to get their DLL to link to Metatrader now have a means to that end. Using Robert Giesecke's Unmanaged C# DLL Exports template, it is possible to create a DLL that may be referenced from non-Com enabled languages, like Metatrader's MQL4 or other scripting languages available in many trading packages, such as EasyLanguage (TradeStation).
Sample code and a downloadable sample project are available here.
19.07.2012 г.
8.07.2012 г.
EA performance and fundamental analysis
Is there a relationship betwen the EA performance and the fundamental analysis?
http://www.zerohedge.com/news/ecbs-balance-sheet-hits-new-record-highs-fair-eurusd-value-900-pips-lower
As you can see there is a very interesting correlation Fed/ECB and EUR/USD.
The author says make your bets.
I was thinking if it is possible to do something else. I will write more on that later. For the moment I am making some assumptions.
The idea is that there is a relationship between a fundamental situation and EA. The best example was the EUR/CHF system by vgc.
Here on this correlation there may lie another relationship between a fundamental situation and EA.
We see that there is a big disbalance between a fundamental relationship and the current market situation.
We could hypothetize that we have a disbalance between a fundamentals and the market.
So whenever the market goes back to balance, it will make it in a movement that would be related with volatility. And even more we can hypothetize that we could have a particular market state that has at least short term predictability.
If you follow me, the idea is that whenever we see a special break - out we can turn our EAs on and they will deal with the situation. As the movement would have at least short term predictability and high volatility we can use EA systems that do work in those kind of situations:
-Spinal implant
-Brain Trend
-Asctrend EA
They would work very good in those market conditions when the market goes with a strong movement towards its fundamental balance.
So to summarize:
1.Fundamental disbalance
2. Looking for a shift of the market towards the balance
3. We swith on the impulse following EAs hypothetizing that the movement would be more or less predictable.
4. We swith of the EA when the market gets into balance again (or at least lower the market exposure).
http://www.zerohedge.com/news/ecbs-balance-sheet-hits-new-record-highs-fair-eurusd-value-900-pips-lower
As you can see there is a very interesting correlation Fed/ECB and EUR/USD.
The author says make your bets.
I was thinking if it is possible to do something else. I will write more on that later. For the moment I am making some assumptions.
The idea is that there is a relationship between a fundamental situation and EA. The best example was the EUR/CHF system by vgc.
Here on this correlation there may lie another relationship between a fundamental situation and EA.
We see that there is a big disbalance between a fundamental relationship and the current market situation.
We could hypothetize that we have a disbalance between a fundamentals and the market.
So whenever the market goes back to balance, it will make it in a movement that would be related with volatility. And even more we can hypothetize that we could have a particular market state that has at least short term predictability.
If you follow me, the idea is that whenever we see a special break - out we can turn our EAs on and they will deal with the situation. As the movement would have at least short term predictability and high volatility we can use EA systems that do work in those kind of situations:
-Spinal implant
-Brain Trend
-Asctrend EA
They would work very good in those market conditions when the market goes with a strong movement towards its fundamental balance.
So to summarize:
1.Fundamental disbalance
2. Looking for a shift of the market towards the balance
3. We swith on the impulse following EAs hypothetizing that the movement would be more or less predictable.
4. We swith of the EA when the market gets into balance again (or at least lower the market exposure).
18.06.2012 г.
Shark 7.0 EA review
This is a review by a trader of the Shark 7.0 EA.
+ Though I didn’t figure out what activates the logic, I like the idea behind. As it places orders only when the market moves quickly, there is a great probability given that either a sell or a buy order will close in profit.
(It is not possible to figure out the logic if it uses Artificial intelligence algorythms)
+ It uses pending orders only. I consider it to be an advantage, as it decreases slippage greatly.
(That is not necessary some brokers still have slippage on pending orders.)
+ trades two currency pairs.
+ It does not open more than one trade at a time.
Cons:
- As SL is placed very close to the market price, dishonest brokers may play dirty games.
(That is important as it is about very close orders to the price. Choose carefully the broker and always always monitor the execution. That is why you need to backtest with your broker tic by tic.)
(And of course you can't have something for nothing everything has its cost, here as thestrategy seeks for the tightest stop loss, that necessarily comes with costs: extra care and control over the execution).
- I am certain that Shark 7.0 will not work with market makers, and results will vary from broker to broker.
(I agree on this, but I would add some market makers not all market makers, I think if you play with 0.01 lots as basic lot instead of 0.1 lot you may have less problems in the first time)
- The final version input parameters are limited to money management settings only. Other parameters are not accessible by the user and can’t be changed. To my mind that’s a bad thing for experienced traders as they don’t have much “space” to maneuver with their settings. Who knows, maybe they change that after seeing this post.
- The user manual does not include any information regarding broker and VPS requirements. That’s not a big deal for experienced traders but clearly, a disadvantage for newbies.
That EA has potential but extreme care need to be used when implemented.
I would add that the quality of the code is guaranteed as the EA is done by experienced traders and programmers.
We would negotiate for EA Shark 7.0 discount coupons for our members even one evaluation copy may be available to one of the most serious contributors on www.beathespread.com.
It is recommended to buy this EA (is someone is interested) and not to search free copies because of the support. The support is a critical feature and without support do not even think to let it trade for you. (Personnal opinion).
Pros:
+ Though I didn’t figure out what activates the logic, I like the idea behind. As it places orders only when the market moves quickly, there is a great probability given that either a sell or a buy order will close in profit.
(It is not possible to figure out the logic if it uses Artificial intelligence algorythms)
+ It uses pending orders only. I consider it to be an advantage, as it decreases slippage greatly.
(That is not necessary some brokers still have slippage on pending orders.)
+ trades two currency pairs.
+ It does not open more than one trade at a time.
Cons:
- As SL is placed very close to the market price, dishonest brokers may play dirty games.
(That is important as it is about very close orders to the price. Choose carefully the broker and always always monitor the execution. That is why you need to backtest with your broker tic by tic.)
(And of course you can't have something for nothing everything has its cost, here as thestrategy seeks for the tightest stop loss, that necessarily comes with costs: extra care and control over the execution).
- I am certain that Shark 7.0 will not work with market makers, and results will vary from broker to broker.
(I agree on this, but I would add some market makers not all market makers, I think if you play with 0.01 lots as basic lot instead of 0.1 lot you may have less problems in the first time)
- The final version input parameters are limited to money management settings only. Other parameters are not accessible by the user and can’t be changed. To my mind that’s a bad thing for experienced traders as they don’t have much “space” to maneuver with their settings. Who knows, maybe they change that after seeing this post.
- The user manual does not include any information regarding broker and VPS requirements. That’s not a big deal for experienced traders but clearly, a disadvantage for newbies.
That EA has potential but extreme care need to be used when implemented.
I would add that the quality of the code is guaranteed as the EA is done by experienced traders and programmers.
We would negotiate for EA Shark 7.0 discount coupons for our members even one evaluation copy may be available to one of the most serious contributors on www.beathespread.com.
It is recommended to buy this EA (is someone is interested) and not to search free copies because of the support. The support is a critical feature and without support do not even think to let it trade for you. (Personnal opinion).
12.06.2012 г.
PNN for metatrader using Parzen window classification version 2 with kernel smoothing of inputs
This is the PNN using Parzen window classification version 2 with kernel smoothing of inputs. You need to have the PFE indicator.
Here you will file the standard PNN called version 2. And the PNN with money management and kernel smoothing of inputs.
Nevertheless this is a beta version, because I am not sure that the integration of the kernel smoothing with the PNN code is correctly executed.
So this is what we have for now. Anyway the idea is interesting.
In the normal PNN Eric we have as input the difference between:
b[bar]= Close[bar]-Open[bar+AmoutOfForecastBars-1])
The idea was to replace this piece of code with something else and to see how it would affect the EA.
So I replaced this by the kernel smoothing of PFE.
b[bar] = kernel()
So this is the idea. However the number of bars of parameters is still an important parameter because it affects the initial period for training:
TrainingStartTime = Time[0] + Period()*60*AmoutOfForecastBars
Of course we can replace this piece of code by Numbars_for_Training as a parameter, but I chose not to touch this for the moment.
TrainingStartTime = Time[0] + Period()*Numbars_for_Training
Any wise look in the code would be welcome as there is not many native mql code for neural implementations.
Here you will file the standard PNN called version 2. And the PNN with money management and kernel smoothing of inputs.
Nevertheless this is a beta version, because I am not sure that the integration of the kernel smoothing with the PNN code is correctly executed.
So this is what we have for now. Anyway the idea is interesting.
In the normal PNN Eric we have as input the difference between:
b[bar]= Close[bar]-Open[bar+AmoutOfForecastBars-1])
The idea was to replace this piece of code with something else and to see how it would affect the EA.
So I replaced this by the kernel smoothing of PFE.
b[bar] = kernel()
So this is the idea. However the number of bars of parameters is still an important parameter because it affects the initial period for training:
TrainingStartTime = Time[0] + Period()*60*AmoutOfForecastBars
Of course we can replace this piece of code by Numbars_for_Training as a parameter, but I chose not to touch this for the moment.
TrainingStartTime = Time[0] + Period()*Numbars_for_Training
Any wise look in the code would be welcome as there is not many native mql code for neural implementations.
4.06.2012 г.
Linear regression technical analysis
![]() |
http://www.fao.org/docrep/W5449E/w5449e04.htm |
As for me the main model of the technical analysis is the linear regression. The oscillators are not intended to measurecycles, they are intended to measure the deviation from the central line of the linear regression. and yes, when you deviate from those center line there is an increase probability that you will reverse to the center line of the linear regression.
That is the true reason why oscillator tend to work (of course according to the theory).
That theory is completely different from the Ehlers theory of trend mode and cycle mode.
I am not sure that I am really clear, that is why I am giving to the introduction to the video of linear regression.
And yes that is the basic model. Imagine: trend lines, Andrew's Pitchfork theories (look here it is very revelative how he defines the linear regression manually).
The second important model is the heteroscedasticity of the volatility. All the patterns of the technical anlysis are driven by this phenomenon, it is related also with the market state analysis.
Definition of 'Heteroskedasticity'
In statistics, when the standard deviations of a variable, monitored over a specific amount of time, are non-constant. Heteroskedasticity often arises in two forms, conditional and unconditional. Conditional heteroskedasticity identifies non-constant volatility when future periods of high and low volatility cannot be identified. Unconditional heteroskedasticity is used when futures periods of high and low volatility can be identified.
Read more: http://www.investopedia.com/terms/h/heteroskedasticity.asp#ixzz1swlH5Cfh
Investopedia explains 'Heteroskedasticity'
In finance, conditional heteroskedasticity often is seen in the prices of stocks and bonds. The level of volatility of these equities cannot be predicted over any period of time. Unconditional heteroskedasticity can be used when discussing variables that have identifiable seasonal variability, such as electricity usage.
Read more: http://www.investopedia.com/terms/h/heteroskedasticity.asp#ixzz1swlOdQge
The Third important thing is coming from the chaos thoery by measuring the fundamental properties of the price time series. Fractal dimension and Lyapunov exponent.
Those measurements matters because imagine the third window when you are using a limit order. Knowing the fractal dimension will save you to prevent your stop to be hit when the limit order is activated.
So here we are. We can explain most of the common technical analysis by some mathematical models.
By this theory it is clear that the oscillators may be adapted according to the volatility arround the central tendancy.
Do you see really what they are doing ? They measure how far we are going away from the central tendancy. If the central tendacly is going up we are saying up trend, if the central tendancy is going down (down trand), and if it is horizontal we say (range).
Those posts are a little bit long but they are related to the general theories underlying the technical analysis.
We are looking for a kinf of unifiying theory. Why those efforts? Well that is because we see how the linerar regression together with the volatility models are expaining so much of the technical analysis.
We ask ourself what the creators of this or that technical method really see. What is the mathematical underlying reality of what the technical authors really see.
To this we can add the psychology we have seen how the psychology is creating an accumulation of orders at specific places. Then in turn those places act as attraction points and are activated.
All this is forming a very complex soup.
We can observe this but our knowledge as a speculative knowledge is limited.
Nonetheless, speculative knowledge is not perfect knowledge of the phenomenon under inquiry, on the contrary, speculative knowledge is precisely imperfect, partial, fragmentary, as such a knowledge is rooted in the necessity of contingency, which implies the knowledge that perfect knowledge is illusory (not in an epistemological sense but in an ontological one).
Read more: http://fractalfinance.blogspot.de/2011/04/possibility-of-cognition.html
14.05.2012 г.
Commodity Channel Index mod

This is a mod of the CCI (Commodity Channel Index) written in mql for the Metatrader 4 plateform (mt4). The idea behind this mod is that the CCI formula uses a constant. Well why a constant?
This is the biggest secret about this indicator why do we have to use a constant in the formula.
As the formula is:
CCI = (Typical Price - 20-period SMA of TP) / (.015 x Mean Deviation)
Hmmm, why 0.015?
The CCI was created by Lambert. His idea was to use a multiplier 0.015, so as a result 70% to 80 % of the price action would remain within -1oo and +100.
So this is a containment range. Within this channel or containement range we expect most of the price action to be.
If the price goes beyound that range, we are in cases of extreme volatility.
Then comes the question that the markets Labert was contemplating are not the markets of today. So maybe it may be wise to modify the constant, so it becomes a variable and by this it may suits us to try to make a commodity index where 70 % - 80 % of the price action will be.
The formula of the mod is:
CCI = (Typical Price - 20-period SMA of TP) / (variable x Mean Deviation) .
In the books Volatility illuminated the author suggested that this was connected in someway with the Chebyshev’s inequality.
"According to Chebyshev’s inequality, the probability that a value will be more than two standard deviations from the mean (k = 2) cannot exceed 25 percent. Gauss’s bound is 11 percent, and the value for the normal distribution is just under 5 percent. Thus, it is apparent that Chebyshev’s inequality is useful only as a theoretical tool for proving generally applicable theorems, not for generating tight probability bounds."
So the constant is empirically set to take into account those 70 - 80 % that in practice needed to be within the channel.
9.04.2012 г.
Linear regression and trend line
A really brief introduction to the "best fit" line through X:Y data.
Watch this video. As a matter of fact all the basic technical analysis are a variation on the theme of the Linear Regression Analysis.
- Trend classification: The trend line is going up - up trend; or the Trend line is going down - down trend
- Finding an entry within the trend: two basic entries:
a. Buyung the dips when in up trend, or Selling the Highs in a Down trend
b. Buying the break - outs over the previous highs or the previous lows.
- Finding when a trend reaches its end. Counter trend entries when the trend - line is violated.
For example Head and Shoulders. And of course there is no reversal pattern unless there was a previous
Trend.
The trend is the technical term very similar with the Linear regression analysis. Of course it is not exactly the same when you form a trend line you are looking to find the lows (uptrend) and the highs (downtrend).
However the linear regression channels are quite popular within Metatrader 4 (mt4) and are a part of some very popular templates of indicators in mt4. Consider also the Andrew's Pitchfork (linear regression again), it is a part of any technical analysis package software mt4 and mt5.
So the idea here is to see that what may looks like some kind of mystical technical analysis tools are in fact an application of basic statistical tools.
And when you form trend lines you are doing that manually and as you will see in the video the linear regression line is the line that minimizes the error.
2.04.2012 г.
Trading methods: from Complexity to Simplicity and Back Again
In our trading methods and experiments here on Forex-TSD and Forex Factrory that way basically to move from complexity to simplicity.
What does it mean in practice? We used some advanced methods in order to preprocess the time series. There are different methods: as for me I was interested in the practical implementations of the jurik type ofdigital filters (the most popular among traders) (Thanks to Kositsin) and the SSA (Singulat Spectrum Analysis Thanks to Klot).
The idea came as I saw an isolated project in the Russian language Alpari forums for using digital filters in order to smooth the time series and then putting it into more complex trading strategies. This was the first digital Brain Trend.
After that this was popullarized on Forex - TSD, and many with my friends here we were together (Camaron, Jaguar , Francis, Albert etc.) into this. On Forex Factory we experimented with SSA and feeding it into more complex strategies like Trend magic, TDI (Traders dynamic index), ASCTrend become the Digital ASCTrend.
Later on, I was surprised to learn that this had an effect, on the mql5 database, the MT5 version of the digital Brain Trend become one of the most rated systems (the second and the third place).
We turned into the complex SSA indicators as the ultimate form of sophistication for an oscillator. The oscillator idea in its best.
In fact in the SSA approach (end-pointed and Noxa) they use complex matrix calculations: eigen decomposition of a matrix.
SSA uses singular value decomposition and extracts the trend, the cycle (seasonal components ) and noises.
Then the Noxa CSSA for example is using a genetic optimizer in order to find the best parameters of the
NOXA CSSA for buy and sell. However that does not work so well in practice and is away from the expected money mochine I have believed to be.
Yes it works but you need to carefully examine the market state using a discretionary approach (I did not find yet a way to make an algorythm for market state detection).
Here are example of scripts using metatrader for Support Vector Machine. There is also a matrix indicator, one of a kind.
So the classical implementation of the SSA is using a method to decompose and simplify the
indormation. And from then to use a direct approach to derive by genetic algorythm or other ai learning way trading rules.
However ithas been argued that Generalizing a problem can make the solution simpler or more complicated, and it’s often hard to predict which beforehand.
So it may sound as a paradox but it may appear that using a complex algorythm like SSA, Independant Component Analysis, Wavelets etc. may actually leave you with a bigger problem.
In fact those preprocessing tools are used because the direct approach of feeding the price into a Neural networks makes it close to impossible to make a good prediction because of the specifics of the neural nets that make a lot of local optima.
However with the rise of the kernel machines, they use a complete different paradigm. They say, yes it exist a simple solution, but in order to find that solutions we may need to map it into high dimensional space and they (the kernel does exactly that), we may find a linear solution into this space.
And for that you do not need to map all the points into this multidimensional mathematical space (that is the kernel trick, brilliant).
So here I make a loop to the beginning, if we have a light matrix indicator we may feed it within the kernel. With SSA ep we cannot practically do that because it is very demanding of computational ressources to make a lot of passes.
19.03.2012 г.
Chaos kernel function using the logistic map?
I made some experiments with different kernels and I would like to share among friends some ideas.
Well it is about to use a function expressing chaotic behaviour itself as a kernel.
The simplest thing was to look at the most simple logistic map.
Xn+1 = r Xn (1 - Xn)
That is the equation of the logistic map. What we can do with that.
What is interesting for us is the parameter r. If we vary the parameter we will have different behaviour (sensitivity of the initial conditions). I keep it short here but we can get some very interesting stretching-and-folding structures , please look at the Wikipedia article.
This is a 3d plot of the logistic map (with just iteration ) for x varying between 0.001 and 1. and r from 1 to 2.
And this is with just one cycle. It is necessary to use parameters from 0 to 1 if more iterations are going to be used.
And this can be used as a kernel for some specific trading strategies. I have in mind some strategies like EURCHF strategy.
However we can go further.
So the idea as as follows:
Given the logistic map equation:
Xn+1 = r Xn (1 - Xn)
we can vary three parameters and to use this as a kernel:
1. We can vary x (from 0 to 1 with step 0.01, or 0.001 for example): this is giving us the initial conditions
2. We can vary the r parameter (from 1 to with step 0.01, or 0.001 for example) this is the parameter governing the chaos. r approximately 3.57 is the onset of chaos, so we can limit from 1 to 3.
3. And of course finally we can vary the limitmap parameter governing the number of iterations. This is the third parameter for the difference equation. Here I need some help because the code I made is missing to plot the values of first two iterations and it is beginning to plot from the third.
So We can call this chaos kernel, in fact I do not know even if that has a name. I did not find in the available litterature anything of this kind. So it is possible that this appears on this site for the first time. I know crazy it is.
The two MAIN ideas ARE:
- TO USE RECURRENT DIFFERENCE EQUATION GENERATING COMPLEX BEHAVIOR with GENETIC OPTIMIZER
- TO USE SOME PORTION OF CHAOS OF THE KERNEL ITSELF
If that is true with just one kernel we have something extremely powerfull. And even more, there are many other maps waiting to be exploited as kernels.
I am using here the logistic map because it is something extremely simple but generating extremely complex mathematical behavior.
Using chaos kernel to harness the chaos itself ;). Why not after all?
Below you can see the plot under MT5 of the logistic map.
This is the MT5 code (I miss the first two iterations any help would be welcome).
Basically this can be used as a chaotic kernel.
Here is the code of the logistic kernel (chaos kernel, in fact it does not have a name yet) you can implement in your trading strategies:
double chaoskernel()
{
//---
double w, j;
{
//---
double w, j;
w=(r*x*(1-x));
for(j=0;j<=limitmap;j++)
{
w=(r*w*(1-w));
}
double p1 = iCustom(TimeFrame,Symbol(),"PFE",x5,true,5,0,0);// This is a NORMALIZED input
return(w* p1);// We multiply the input value by the weight
}
for(j=0;j<=limitmap;j++)
{
w=(r*w*(1-w));
}
double p1 = iCustom(TimeFrame,Symbol(),"PFE",x5,true,5,0,0);// This is a NORMALIZED input
return(w* p1);// We multiply the input value by the weight
}
5.03.2012 г.
beathespread.com EA systems
Here I will show you two shots. Both if the shots are out of sample. The training was from
16.01.12 - 23.02.12.
The out of sample testing is from 24.02.12 - today 05.03.12
One of the systems is the Spinal Implant EA. The characteristic of this system is to enter into a trade only when there is larger Hurst exponent. In practice it tries to catch the break - outs and looks very much what an experienced price action specialist would do.
So the characteristics of this system is to know when to trade.
When the decision is taken it is upt to the Neural net to take a directionnal decision.
The second EA is using the ASCTrend expert as a basis but it is a little bit more sophisticated because it is using radial basis activatin function in the neurones in order to adapt the indicator settings. This expert is not using the Hurst exponent so it is more vulnerable than the Spian Implant to adverse market conditions. However during the out of sample the market did very good swings and the expert was able to catch them very well. So with this expert you need to monitor the market state carefully. The worse that can happend is ranging and volatile market state, the expert will open a loosing after loosing trade.
Абонамент за:
Публикации (Atom)