Questions from Beginners MQL5 MT5 MetaTrader 5 - page 646
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
There are two MT5 terminals. Problem: can I write scripts to allow only long trades in one terminal and only short trades in the other?
#define ORDER_TYPE_SELL ORDER_TYPE_SELL_STOP // поставить в самом начале советника, если нужно отказаться от SELL-сделок
There are two MT5 terminals. Task: Is it possible to write scripts to allow only long trades in one terminal and only short trades in the other?
Simply enter an input parameter into your EA and depending on the value assigned to it when you start, you will either only buy or only sell:
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
...
void OnTick()
{
if(!Long)
trade.Sell(0.01);
if(Long)
trade.Buy(0.01);
}
In order to know if it is a new top or bottom, you need to remember the time of the last top/top you found, and compare it with what you have found so far.
Thank you, it's clear with the buffer.
In order to remember the time of the last vertex found, you need to know it somehow.
How to do it, how to know the time of the last vertex found?
Thank you, the buffer is clear.
In order to remember the time of the last vertex found, you need to know it somehow.
How to do this, how to know the time of the last vertex found?
You declare a static variable to store the time of the previous extremum of the zigzag and initialize it with zero.
2. Find a vertex and if its time is not equal to the time in the static variable, consider that you have found the required extremum and memorize the new time in this variable.
3. GoTo(2);
Comrade programmers!
Recommend a way to find out if the spread has increased.
The problem is the following: during the transition to a new day brokerage company widens spread, and sometimes it is crazy for some pairs - it exceeds by 3-5 times the normal value. Daylight-saving spreads are different in brokerage companies with time change from 23 to 59 and from 20 to 59 and so on.
For some guys the spread does not change much, so we cannot cut off the "Working by time" robot because if the spread does not change, we will not have to prohibit trading.
The main question is how to detect that the spread is too large and therefore prohibit the robot from opening a position. I see a variant of storing spread sizes in a file for each new bar for the last 5-7 bars, then adding it all and dividing by the number, thus getting the average spread and multiplying by 1.2 - 1.4 (margin), but I don't think it is interesting to save and multiply files and I am not sure that it is the correct solution for calculation of the average spread size. If I manually enter the maximum allowable spread in the settings, it's very trivial and uninteresting in terms of bot operation.
Please advise the optimal solution for the question, that would not be afraid of rebooting the terminal, and emergency shutdown in case of power outage. Also, preferably a solution that minimizes the load on the program, so it does not recalculate on every tick.
Thank you!
Comrade programmers!
Recommend a way to find out if the spread has increased.
The problem is the following: during the transition to a new day brokerage company widens spread, and sometimes it is crazy for some pairs - it exceeds by 3-5 times the normal value. Daylight-saving spreads are different in brokerage companies with time change from 23 to 59 and from 20 to 59 and so on.
For some guys the spread does not change much, so we cannot cut off the "Working by time" robot because if the spread does not change, we will not have to prohibit trading.
The main question is how to detect that the spread is too large and thus prohibit the robot from opening a position. I see a variant of storing spread sizes in a file for each new bar for the last 5-7 bars, then adding it all and dividing by the number and thus getting the average spread and multiplying by 1.2 - 1.4 (margin), but it is not interesting to save and multiply files. If I manually enter the maximum allowable spread in settings, it's very trivial and uninteresting in terms of bot operation.
Please advise what would be the best solution to this question. Thank you!
What kind of TS-logic is this spread-dependent?!
OK, let's put it this way. Here, for example, the spread widens not even three times, but more, and if you enter the market with a spread of 20pp, while the normal spread is 4-6pp, then it is not normal, and we need to cut off these moments.
OK, let's put it this way. For example, the spread here is not even three times wider, but more, and if you enter the market with a spread of 20pp, while the normal spread is 4-6pp, this is not normal, and we need to cut these points off.
OK, let's put it this way. For example, the spread here is not even three times wider, but more, and if you enter the market with a spread of 20pp, while the normal spread is 4-6pp, this is not normal, and we need to cut these points off.