[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 719
![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
But for some reason I end up with an error EURUSD,: zero divide - this error seems to say that there is a 0 in the variable somewhere, probably during a division type operation. Am I trying to implement it correctly at all ?
In the tester or on the demo?
In the tester the point on other symbols will be 0
Dear Sirs, please help me to solve this problem, if it can be solved under these conditions!
There is, for example, such an Expert Advisor (its PATTERN, to be exact), as the principle itself is interesting.
So, here it is:
extern double Lot = 0.1;
extern int TP = 100;
extern int SL = 100;
extern int ХХХ = 100; //like different variables
extern int ХХХ = 100; //like different variables
extern int int ХХХ = 100; //like different variables
// which orders are permitted ? :
extern int LET = 3; // 1 - only sell, 2 - only buy, 3 - both order types
int start()
//calculate the indicators:
int KUDA;
THE INDICATOR AND ITS WORKING CONDITIONS ARE INSERTED
// Check conditions for determining the order direction according to the indicator data:
if ( ХХХХХХХХХХХХХХХХХ ) // indicator condition for sal
KUDA = 1; // it means we will sell
if ( ХХХХХХХХХХХХХХХХХХХ) // indicator condition for buy
KUDA = 2; // it means we will buy
// placing orders :
if(OrdersTotal()>0) return (0); // allows the EA to work with only one order placed
WHICH CODE TO INSERT HERE, SO THAT WHEN A DEALER CLOSES A SELL, IS ALLOWED TO PLACE ONLY A BUY ORDER,
and when a loser closes a buy is only allowed to place a sell?
AND SO ON AND SO ON!!!
{
if (LET == 1 || LET == 3) // according to the variable only works for sell (ignores buy) or both
if (KUDA == 1 && ticketsell < 1) // set sell
{
HERE IS THE CODE FOR PLACING SELL ORDERS
}
if (LET == 2 || LET == 3) // according to the variable only works for buy (sell ignores) or both order types
if (KUDA == 2 && ticketbuy < 1) // expose buy
{
HERE IS THE CODE FOR PLACING BUY ORDERS
}
}
return(0);
}
Thank you!
So, in order.
If you only want the last data, then why save the previous data? ("pre-write" happens with a combination of FILE_READ|FILE_WRITE modes).
Therefore it is more logical to use FILE_CSV|FILE_WRITE mode, where previous records are deleted before writing new data.
Start writing the 4 variables to the file.
The main thing is to remember the order in which the variables are written, because this is the order in which we will read them.
Start reading data into the variables from the file.
Using the FileReadNumber() function, we read in sequence, number by number, in the order in which we have written it.
That's all there is to it, nothing complicated :)
Help me solve this problem programmatically:
1. First, we find the first fractal upwards - this is simple and clear;
2. Then we need to find a fractal higher than the first one - this is already a problem :(
Ok, if it is the previous fractal. But what if it's the one before that? Or three or four fractals ago?
How do I make a function to search for such fractals?
I'm attaching a picture just in case.
try again
Help me solve this problem programmatically:
1. First, we find the first fractal upwards - this is simple and clear;
2. Then we need to find a fractal higher than the first one - this is already a problem :(
Ok, if it is the previous fractal. But what if it's the one before that? Or three or four fractals ago?
How do I make a function to search for such fractals?
I'm attaching a picture just in case.
And if there is no such fractal at all
And if there is no such fractal at all
Help me solve this problem programmatically:
1. First, we find the first fractal upwards - this is simple and clear;
2. Then we need to find a fractal higher than the first one - this is already a problem :(
Ok, if it is the previous fractal. But what if it's the one before that? Or three or four fractals before?
How to formulate the search for such fractals as a function?
Just in case, I'm attaching a picture...
If it can't be found in the loop - then you have to wait for new fractal to appear (instead of the first remembered one). As soon as the new fractal appears we again look for the needed second fractal in the loop (most likely it will be the first one remembered at the very beginning). Thus we find two needed fractals and avoid the situation rightly hinted at by Victor in the post above. Although theoretically it is possible that the second fractal will never be formed... An apocalypse for example... :)
So, if, for example, there is no fractal at 300 bars ago, we wait for a new fractal to appear before resuming the search