
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
Greetings all.
Question - I want to use methods of CTrade class in my EA. What commands should I add to the code for that?
I've tried a lot with #include, #import... Nothing comes out yet :(
Greetings all.
Question - I want to use methods of CTrade class in my EA. What commands should I add to the code for that?
I tried a lot with #include, #import... Nothing works so far :(
The MACD Sample Expert Advisor example helps you.
Connect the module in the following way
#include <Trade\Trade.mqh>
Declare a variable in one of two ways (depending on the algorithm and the need for certain implementation features)
This can be done as an independent object, or as part of the main class.
An example of closing a position (in detail in the code).
m_trade.PositionClose(Symbol())
Example of modifying a position (see details in the code).
m_trade.PositionModify(Symbol(),sl,tp)
PS
You can also study the CExpert stuffing in detail.
What's it mean?
2011.07.15 13:30:35 2011.07.08 00:00:01 Infinite Sleep loop detected while testing.
What it means?
Theoretically, this is a reason to disqualify a championship participant (at least, problems during automatic testing of the EA), but in fact, it is incorrect work with sleep().
I advise to study this article (and perhaps others) in more detail.
Regarding your question, here is the quote from the article:
Sleep() function in the tester
The Sleep() function allows you to suspend execution of an mql5 program for some time during work on a chart in an Expert Advisor or script. This can be necessary when requesting some data, which at the time of the request are not ready and you need to wait until they are ready. A detailed example of Sleep() function use can be found in Data access organization section.
In the tester, calls of Sleep() do not delay the testing process. When Sleep() is called, the generated ticks are "played" within the specified delay, as a result of which pending orders, stops can trigger, etc. After Sleep() has been called, the time simulated in the tester is increased by the interval specified in the Sleep function parameter.
If, as a result of Sleep() execution the current time in the tester exceeds the end of the testing period, an error "infinite loop in Sleep" will be received. If such an error occurs, testing results are not discarded, all calculations are completed (number of trades, drawdown, etc.) and the results are passed to the terminal.
Function Sleep() will not work in OnDeinit() because after its call the tester time is guaranteed to be beyond the testing interval.
Comrades!
I'm going to add a history analysis to the Expert Advisor. Can you tell me how to organise the data output?
Let's say, the longest bar in a year of history. How to get the value is clear, but where to output? It would be more convenient to output it directly to the chart. Or using the Print function in the journal, but I do not know how it would work? Will it continuously reprint values? Would I need to set some tricky condition for printing? What would be your general recommendation?
Comrades!
I'm going to add a history analysis to the Expert Advisor. Can you tell me how to organise the data output?
Let's say, the longest bar in a year of history. How to get the value is clear, but where to output? It would be more convenient to output it directly to the chart. Or using the Print function in the journal, but I do not know how it would work? Will it continuously reprint values? Would I need to set some tricky condition for printing? What would be your general recommendation?
Try using the Comment() function. It places the text in the upper left corner of the chart.
There you may also use "\n" symbol to pass to the next line. Unfortunately, "\t" doesn't work.
Try using the Comment() function. It places the text in the top left corner of the chart.
You can also use "\n" to move to the next line. Unfortunately, "\t" does not work.
Can you tell me how much data can be crammed into one array? Array of MqlRates structure, I'm going to put all the history of hourly bars since 2009, will it fit?
p.s. Something else with the strategy tester, it does not work on weekends because the server is unavailable or something glitched at me? It seemed to work properly on Friday))
1. The whole thing seems to be. If there is a limit, it is at the int or long threshold level. There is not so much RAM in the computer. =)
2. describe the problem with the tester not working more precisely. Error codes, screenshots...