![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thank you for your valuable commitment, especially for the opportunity to open our minds to new horizons - which is the most important thing I think.
I have practical and maybe naive questions
thank you
have a great time
I love your proactive approach. You're right, there are several exceptions that may get raised when trying to fetch historical data. For example, if you try to change time frames in the middle of a trading session, the "-nan" issue may be observed yet again.
There was an inherent tradeoff between keeping the message easy to follow and fixing all the bugs I observed. If I went for the latter, the code may have been necessarily more complex and not as easy to follow as it is. So I decided to keep it easy to follow, with the intentions that you would be able to rapidly extend it.
Your solution sounds very promising, how is it turning out?
I have tried running the LinearRegressionEA and find it an exciting concept. I trade mostly GOLD CFDs and established a liking for the WPR indicator in this example.
Sometimes I get incorrect Prediction prices that are way out of range with a factor 100, but sometimes correct !
If someone figure that issue out I would appreciate that a lot. Debugging linear regression code is not my expertise.
I did not see if you wrote anything about preferred Period for trading, I have it set at 30 Minutes.
In that scenario,
if there is not yet a trade
and the EA runs its 'analyse_indicators()' function,
this is done once per bar, so in my case once every 30 minutes.
So it means if the indicators does not line up for a trade decision this is not attempted again until next bar, in my case 30 minutes later.
IMO this is too far between for establishing the initial trade,
so I added a Timer task that runs the analyse step every 10 seconds until indicators are in favor for a trade;
I establish the Buy or Sell order and then return to the regular per bar processing of the manage_position() function.
Thank you for your valuable commitment, especially for the opportunity to open our minds to new horizons - which is the most important thing I think.
I have practical and maybe naive questions
thank you
have a great time
Hey Giulio.
To setup a magic number and a custom comment, you would simply extend the code by calling the appropriate function instead.
I think the PositionOpen may be what you're looking for, you can check the documentation with this link.
If that doesn't satisfy what you need, try this YouTube tutorial using this link.
If none of these resources are able to help you, then I have a channel where I post more helpful articles like these. You can find it using this link.
Hello again I had to create my account again to login. Anyway,
I have tried running the LinearRegressionEA and find it an exciting concept. I trade mostly GOLD CFDs and established a liking for the WPR indicator in this example.
Sometimes I get incorrect Prediction prices that are way out of range with a factor 100, but sometimes correct !
If someone figure that issue out I would appreciate that a lot. Debugging linear regression code is not my expertise.
I did not see if you wrote anything about preferred Period for trading, I have it set at 30 Minutes.
In that scenario,
if there is not yet a trade
and the EA runs its 'analyse_indicators()' function,
this is done once per bar, so in my case once every 30 minutes.
So it means if the indicators does not line up for a trade decision this is not attempted again until next bar, in my case 30 minutes later.
IMO this is too far between for establishing the initial trade,
so I added a Timer task that runs the analyse step every 10 seconds until indicators are in favor for a trade;
I establish the Buy or Sell order and then return to the regular per bar processing of the manage_position() function.
I'm sorry to hear you were experiencing difficulties logging in, I trust you've gotten that fixed by now.
You are correct, the predictions given by our current model may at times be out of the acceptable range by a wide margin, but there is no bug in the code.
Let me explain why we can expect this to happen.
We are using a simple implementation of the Gradient Descent algorithm to optimise our model coefficients. Unfortunately, Gradient Descent can be sensitive to the starting positions of our coefficients. To remedy this, the Stochastic Gradient Descent (SGD) algorithm was developed. SGD performs optimisations by changing the starting coefficients each time to maximise the probability of finding optimal coefficients. For simplicity, we kept our coeffiecients fixed and this may cause the model to get stuck in dismal states. This youtube video may be helpful, use this link.
Yes you are right, I intentionally called for calculations to be performed on every candle. This was done to speed up backtests, to turn this feature off simply delete the condition check "if(timestamp != current_time)".
Furthermore, there are ways we can build our model such that it customises itself to the data we have at hand, you can find that information using this link.
Hi, it's amazing! Thanks!
I get this lines:
How can I fix this?
does any one have also this problem?
Hi, it's amazing! Thanks!
I get this lines:
How can I fix this?
does any one have also this problem?
Hey Javier, Could you upload more of the output from the terminal?
Because what you shared seems normal, I would expect output like that.
However, the problem I'm noticing with your output is the "0.0" at the end. Getting an error of 0.0 implies the model is perfect, which isn't realistically possible.