Discussing the article: "Build Self Optmising Expert Advisors in MQL5" - page 2

 

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

  • how to put a Magic Number and a Comment to track the EA?
  • how to modify the LotSize (even better, how to implement a money management)?

thank you

have a great time

 
Gamuchirai Zororo Ndawana #:
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?

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.
 
Giulio Braga #:

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

  • how to put a Magic Number and a Comment to track the EA?
  • how to modify the LotSize (even better, how to implement a money management)?

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.

Documentation on MQL5: Standard Library / Trade Classes / CTrade / PositionOpen
Documentation on MQL5: Standard Library / Trade Classes / CTrade / PositionOpen
  • www.mql5.com
Opens a position with the specified parameters. Parameters symbol [in]  Name of trade instrument, by which it is intended to open position...
 
Gunnar Forsgren #:
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.
It's good to hear back from you Gunnar.

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.
134 - What are Optimizers in deep learning? (Keras & TensorFlow)
134 - What are Optimizers in deep learning? (Keras & TensorFlow)
  • 2020.06.18
  • www.youtube.com
microscopy, python, image processing
Reason: