Build Neural Network Indicator in MT4 using Neuroshell

Highfreq,

Can you explain in more details?
Is this Ornstein-Ulembeck mean reverting model : http://www.puc-rio.br/marco.ind/revers.html

I have applied standart deviation bands on detrended price .How can I find or calculate the optimal standart deviation bands with NN to find the most profitable signal ?Cheers.
 
Highfreq,

Can you explain in more details?
Is this Ornstein-Ulembeck mean reverting model : http://www.puc-rio.br/marco.ind/revers.html

I have applied standart deviation bands on detrended price .How can I find or calculate the optimal standart deviation bands with NN to find the most profitable signal ?Cheers.

Here is a related paper.
http://math.nyu.edu/faculty/avellane/AvellanedaLeeStatArb071108.pdf

They propose a portfolio allocation model based on the Ornstein-Ulenbek process. They do a cross-sectional PCA on the instrument of the portfolio. What I do is different; I use CSSA on a single instrument. It is equivalent to doing an incremental cross-sectional PCA but on lagged versions of itself. Anyway, don’t pay too much attention to this stuff. My system is very simple:

The Ornstein-Ulenbek is like that: dX(t) = k (m – X(t))dt + sdW(t) (see p16 of the pdf)

My system is:
1. Do dX(t) = CSSA(price) – detrended price
2. Use a neural net to predict price and do k(m–X(t))dt = prediction

Use the method described p16 and 17 to calculate the parameters k m and s of the model. When done, calculate the s-score as described p20; s-score = (X – m) / sigma. You are almost done.

Use the s-score to generate signals:
s-score > threshold1 go short
s-score < threshold2 go long

that’s it!!
 
81,2% accuracy

Maybe its interesting for you. They claim to obtain 81.2% accuracy in predicting currency rates using back propagation NN.

Krzysztof
 

Attachments

  • Artificial Neural Network Model for Forecasting Foreign Exchange Rate.pdf
    424.2 KB · Views: 2,834
Thanks for the advices Highfreq.Arry ,I've been having a lot of work recently and didn't have enough time. :| Will update more frequently next week .
Here is a related paper.
http://math.nyu.edu/faculty/avellane/AvellanedaLeeStatArb071108.pdf

They propose a portfolio allocation model based on the Ornstein-Ulenbek process. They do a cross-sectional PCA on the instrument of the portfolio. What I do is different; I use CSSA on a single instrument. It is equivalent to doing an incremental cross-sectional PCA but on lagged versions of itself. Anyway, don’t pay too much attention to this stuff. My system is very simple:

The Ornstein-Ulenbek is like that: dX(t) = k (m – X(t))dt + sdW(t) (see p16 of the pdf)

My system is:
1. Do dX(t) = CSSA(price) – detrended price
2. Use a neural net to predict price and do k(m–X(t))dt = prediction

Use the method described p16 and 17 to calculate the parameters k m and s of the model. When done, calculate the s-score as described p20; s-score = (X – m) / sigma. You are almost done.

Use the s-score to generate signals:
s-score > threshold1 go short
s-score < threshold2 go long

that’s it!!
 
I found entropy code at forum.mql4.com/ru/13708
After converting into dll then insert in NSDT as an indicator, seems good indicator, it works in positive and negative range for bullish and bearish trend.

Compare with other oscillator (JRSX, aaneuroRSI) seems entropy based indicator is good candidate for new NN predicted indicator. The cross over of entropy indicator can be earlier than others.
 

Attachments

  • Entropy NSDT.png
    Entropy NSDT.png
    77 KB · Views: 675
  • Entropy-JRSX-NeuroRSI MT4.png
    Entropy-JRSX-NeuroRSI MT4.png
    41.9 KB · Views: 883
Here comparison between aaEntropy, aaNeuroMACD and aaNeuroTrend indicators..

Here attached also the entropy indicator.

Again with proper setting, signal generated by entropy indicator is earlier than others.
 

Attachments

  • aaEntropy - aaneuromacd - aaneurotrend.png
    aaEntropy - aaneuromacd - aaneurotrend.png
    47 KB · Views: 1,129
  • Entropy.mq4
    1.7 KB · Views: 575
I read somewhere that there are different ways of using entropy(in probability theory) related to trading, but I havent' been able to figure it out yet.
 
Last edited:
Hi Tovim..me too previously I studied about entropy for thermodynamic not in trading..

I read wikipedia to remind me about entropy Entropy - Wikipedia, the free encyclopedia

As illustrated in wikipedia, entropy increases in a small "universe", a thermodynamic system consisting of the "surroundings" (the warm room) and "system" (glass, ice, cold water). The melting of ice due to warmer temperature of surrounding. The entropy of the system will change by the amount dS = δQ/T. The entropy of the surroundings will change by an amount dS = −δQ/T. The entropy of the system increases, whereas the entropy of the surroundings decreases.

As an analogy, the market price can be considered as a system which influenced by surrounding (economic news, trader action, etc). Hence we will have entropy change between market price and surrounding.

The equation form:
If X is a discrete random variable with distribution given by

H(X) = sum of p * log p .

If X is a continuous random variable with probability density p(x). I think this is related with probability theory, but I do not know in detail.

Refer to entropy indicator attached previously, actually we calculate/estimate entropy of market price. Based on entropy indicator we can define the trading rule such as : buy if entropy> 0 and sell <0, or buy if entropy cross above its MA, and sell when cross below its MA.
 
Hi Krzys,

Thanks for your given link, by the way here is the complete ebook

Index of /~gms2155/projectspring2009

Here are the complete collection about tradefx available there
[ ] Project1a.pdf 09-Sep-2009 23:03 1.8M
[ ] Project1b.pdf 09-Sep-2009 23:04 3.0M
[ ] Project2a.pdf 09-Sep-2009 23:06 6.4M
[ ] Project2b.pdf 09-Sep-2009 23:06 1.2M
[ ] Project3a.pdf 09-Sep-2009 23:07 941K
[ ] Project3b.pdf 09-Sep-2009 23:07 75K
[ ] Project4a.pdf 09-Sep-2009 23:07 808K
[ ] Project4b.pdf 09-Sep-2009 23:07 421K
[ ] Project5a.pdf 09-Sep-2009 23:07 520K
[ ] Project5b.pdf 09-Sep-2009 23:08 2.7M
[ ] Project6b.pdf 09-Sep-2009 23:09 3.8M

The correct link for tradefx is http://www.columbia.edu/~xv2103/finance/TradeFX/TradeFX.zip

Additional link for MT4 to Matlab for producing csv file is available here:
Interaction between MetaTrader 4 and Matlab via CSV Files - MQL4 Articles

I trace the required LibSVM has no more available. Any one can advice?

Arryex

Hi all, and thanks for the very interesting thread.
I am trying to follow this thread from the beginning but for the moment I cannot get TradeFX.zip, because the link is broken. Could someone upload it here (or somewhere else?).
Thanks ;)
 
I have this concept in my mind :In my opinion I think the best approach for prediction is ,genetic alghorithm or particle swarm will find the optimal n bar or n signal ahead for the self training(trained at every n bar) neural network algo example Dynamic Notions: Training Neural Networks Using Back Propagation in C# .Neuroshell calls them as adaptive nets.Then we have another dilemma what will be the optimal fitness function for GA or Swarm to find the n bar or n signal ahead?One of the criterion I can think of is Robert Pardo's perfect profit another one is profit factor.Suggestions are welcome.
 
I am thinking run the GA or Swarm algorithm to find the best fitness function(perfect profit, profit factor, sharpe ratio etc...) Suggestions are welcome.
 
Hi I just would like to copy paste quckly some things I wrote in another forum. It is about the entropy indicators.Briefly I just would like to point that the entropy indicator is not calculating actually the entropy.

It is the not the entropy but a computation of the probability of up movement and down movement based on the entropy mathematics.

And that is why it is intepreted as an oscillator.

Here are the real links.

http://www.johncon.com/john/correspo...935.21840.html

http://www.johncon.com/john/correspo...563.22218.html

Have a look at this. //by the way the numbers in our mt4 code do not seem right/

The indicator gives us (g) and not the entropy. And g is
"average multiplicative gain per iteration of the game, i.e., after t many iterations, the gambler's capital would have increased by a factor of g^t."
If g goes up uou bet to buy. Ig g goes down you bet to sell.
If there is a low reading of (g) the probabilities are low.

I made a trial to calculate p instead of g. I hope I did right.
And p is The Shannon Probability


Subject: Quantitative Analysis of Non-Linear High Entropy Economic Systems I

If you want the best 101 on entropy go to Noxa analitics register and download their entropy indicators tutorial.

just tried to use the available code in order to compute the entropy function.
Of course consider it just as a trial.

But we need such an indicator.
I just drop a shot showing how you can use it. It is fairly simple provided the indicator is correct.

We look for a drop in the entropy function. The drop would confirm a technical break - out. The logic is the same as with the fractal break - out. This time we have an entropy break - out. Well the mathematics are a little complex but the technical use is fairly simple. I just missed that indicator and tried to do something. I am sure that in that way I could attract some coder attention for futher improvements.

Subject: Stock Market

H(p) is the entropy function, H(p) = -[p log p + (1 - p) log (1 -
p)].

This is the formula of the binary entropy function
Binary entropy function - Wikipedia, the free encyclopedia

As in the previous indicator the p was computed. I used this formula even if as far as I know the classic formula is different.
Information theory - Wikipedia, the free encyclopedia

It was just one line of code.

I hope this is correct.
So I will update and make the two versions. Comments are welcome.

The binary (entropy function.mt4) should be correct but the other is not because the implementation of formula is not correct.I need a help with the Sigma. However I have the surprise I = -log (p(x)).

Here I add the indicator.
 

Attachments

  • Entropy function binary.mq4
    1.8 KB · Views: 395
  • shot1.gif
    shot1.gif
    36.4 KB · Views: 806
It is also possible to adapt indicators with the binary entropy function.

In the screenshot above I did exactly that I adapted the SSA end - pointed dividing the values by the entropy function.

The idea is when the entropy drops the readings should be bigger. And vice versa with high entropy the readings would be smaller.

So it is possible to make a complex indicators deviding their readings by the binary entropy that can be inputs for neural nets.
 
Hi John,

Welcome to the forum.

By the way the link you have given is not completely written, when I click them
the response will be:
The requested URL /john/correspo...935.21840.html was not found on this server.

You should write the complete address.

thanks
Hi I just would like to copy paste quckly some things I wrote in another forum. It is about the entropy indicators.Briefly I just would like to point that the entropy indicator is not calculating actually the entropy.

It is the not the entropy but a computation of the probability of up movement and down movement based on the entropy mathematics.

And that is why it is intepreted as an oscillator.

Here are the real links.

http://www.johncon.com/john/correspo...935.21840.html

http://www.johncon.com/john/correspo...563.22218.html

Have a look at this. //by the way the numbers in our mt4 code do not seem right/

The indicator gives us (g) and not the entropy. And g is
"average multiplicative gain per iteration of the game, i.e., after t many iterations, the gambler's capital would have increased by a factor of g^t."
If g goes up uou bet to buy. Ig g goes down you bet to sell.
If there is a low reading of (g) the probabilities are low.

I made a trial to calculate p instead of g. I hope I did right.
And p is The Shannon Probability


Subject: Quantitative Analysis of Non-Linear High Entropy Economic Systems I

If you want the best 101 on entropy go to Noxa analitics register and download their entropy indicators tutorial.

just tried to use the available code in order to compute the entropy function.
Of course consider it just as a trial.

But we need such an indicator.
I just drop a shot showing how you can use it. It is fairly simple provided the indicator is correct.

We look for a drop in the entropy function. The drop would confirm a technical break - out. The logic is the same as with the fractal break - out. This time we have an entropy break - out. Well the mathematics are a little complex but the technical use is fairly simple. I just missed that indicator and tried to do something. I am sure that in that way I could attract some coder attention for futher improvements.

Subject: Stock Market

H(p) is the entropy function, H(p) = -[p log p + (1 - p) log (1 -
p)].

This is the formula of the binary entropy function
Binary entropy function - Wikipedia, the free encyclopedia

As in the previous indicator the p was computed. I used this formula even if as far as I know the classic formula is different.
Information theory - Wikipedia, the free encyclopedia

It was just one line of code.

I hope this is correct.
So I will update and make the two versions. Comments are welcome.

The binary (entropy function.mt4) should be correct but the other is not because the implementation of formula is not correct.I need a help with the Sigma. However I have the surprise I = -log (p(x)).

Here I add the indicator.
 
Hi John,

I tried to verify your indicator compare to the price movement, it is difficult for me to get a clue how to use the indicator into a trading strategy. Some time the entropy function binary move as price but some time move in reverse.

Using entropy, we can bet that if entropy cross below zero for sell and cross above zero for buy.

Please advice If you have better way how to use entropy function binary indicator.

Thanks
 

Attachments

  • Chart1.png
    Chart1.png
    42.9 KB · Views: 503
Modify the entropy and adding its moving average can give earlier entry (even not always...)
 

Attachments

  • Chart2.png
    Chart2.png
    41.2 KB · Views: 409
Top