[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 81
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
extern bool BUY = true;
extern int Magic = 0;
extern double Lot = 0.1;
extern int takeprofit = 0;
extern int stoploss = 0;
extern int slippage = 3;
double SL,TP;
int init(){
return(0);
}
int start()
{
if (BUY)
{
if (takeprofit!=0) TP = NormalizeDouble(Ask + takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Ask - stoploss*Point,Digits); else SL=0;
BUY=false;
}
return(0);
}
void OPENORDER(string ord)
{
int error;
while (true)
{ error=true;
if (ord=="Buy") error=OrderSend(Symbol(),OP_BUY, Lot,NormalizeDouble(Ask,Digits),slippage,SL,TP,",Magic,0){BUY = false;}
}
return;
}
Please give me an example. I'm just learning, and haven't faced the task of setting up a flag yet. )
Please advise how to allow a single execution of a condition in an EA (e.g. opening an order), rather than repeating it with every tick. In this case, when closing a position, the EA should not open a new one. I have tried to do it, but it doesn't work as intended.
Thanks in advance.why did you name the variable where the order ticket will be saved error ?
if (ord=="Buy") error=OrderSend(Symbol(),OP_BUY, Lot,NormalizeDouble(Ask,Digits),slippage,SL,TP,"",Magic,0){BUY = false;}
Read about OrderSend(), I think the questions will go away, I would write it like this:
Maybe you read earlier I voiced my problem. They seem to have found a solution, but I can't find in the book how to work with string in mql(
how do I take the numbers out of the line by line?
Maybe you read earlier I voiced my problem. They seem to have found a solution, but I can't find in the book how to work with string in mql(
how do I take the numbers out of the line by line?
Create a script to experiment with MQL4 string functions - see here https://docs.mql4.com/ru/strings
ZERO
under what rules, for example?
Create a script that experiments with MQL4 string functions - see here https://docs.mql4.com/ru/strings/StringSubstr
Thank you!
Maybe you read a little earlier I voiced my problem. It seems to be a solution, but I can't find a way to work with strings in mql in the book (
how do I take a number out of a string of numbers?
to convert a number to a string https://docs.mql4.com/ru/convert/DoubleToStr
cut off a part of the string https://docs.mql4.com/ru/strings/StringSubstr from the beginning https://docs.mql4.com/ru/strings/StringLen
and convert it back to the real type https://docs.mql4.com/ru/convert/StrToDouble
that's all you need to do with strings, maybe StrToDouble() will be enough for you.
but this "ugly way" will cut off the number, not round it. Another way: multiply a real number to power of x by 10, and give the result to the int type - if I'm not mistaken, there will be no rounding, then divide int by 10 to power of x.
translate a number into the string https://docs.mql4.com/ru/convert/DoubleToStr
cut off a part of the string https://docs.mql4.com/ru/strings/StringSubstr from the beginning of https://docs.mql4.com/ru/strings/StringLen
and convert everything back to a real type https://docs.mql4.com/ru/convert/StrToDouble
that's all you need to do with strings, maybe StrToDouble() is enough for you.
but this "ugly way" will cut off the number, not round it. Another way: multiply a real number by 10 to the power of x, and give the result to the int type - if I'm not mistaken, there will be no rounding, then divide int by 10 to the power of x
at least *cut off*, as the number can only be taken out of the indicator to a string... thanks for the advice, I'll experiment)
IgorM:
NameLess :