Petiyashaket: I need a buy stop trailed (modified) by price fractals until it triggers and a sell stop in the same way.
So the question in your code, highlighted in red.
if(Up>0&&Down==0&&Volume[0]<2) //если верхний фрактал есть а нижнего нету и прошло не больше 2х тиков то:
{
if((High[3]+5*Point-Ask)/Point>MarketInfo(Symbol(),MODE_STOPLEVEL)) //если расстояние 0 бара от хая фрактала позволяет то:OrderSend(Symbol(),OP_BUYSTOP,Lot,High[3]+5*Point,20,High[3]-sl,High[3]+tp,NULL,Magic,0,Green);//выставляем отложенный на покупкуelse {BS=High[3]+5*Point; Print("Виртуальный BS:",BS);} // а ели нет то запоминаем(позже будет добавлен вход с рынка){ // К чему относится эта скобка???
for (int pos=0;pos==OrdersTotal();pos++)
OrderSelect(pos,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol()&&OrderType()==OP_BUYSTOP)
{
OrderModify(OrderTicket(),Up+5*Point,High[3]-sl,High[3]+tp,0,CLR_NONE);
}
} // это пара к той...}
You still haven't answered. I don't know what to do with it, but the result of code execution will be different.
Sometimes there are a bunch of them in one tick. And on this bar the condition will not work anymore
Victor, this question is not for me. I use this function.
bool NewBar()
{
staticdatetime lastbar = iTime(_Symbol, PERIOD_H1, 0); // Период можно менять по желанию
datetime curbar = iTime(_Symbol, PERIOD_H1, 0); // и будет отсчитывать новый бар заданного периода на любом ТФ
if(lastbar != curbar)
{
lastbar = curbar;
return (true);
}
elsereturn(false);
}//******************************************************************|
I copied a piece of code to ask a question about brackets.
Petiyashaket: This is what Oleg Remizov teaches on YouTube, this condition restricts trading on the news and catching moose :)
I have nothing to say about Remizov. But don't be offended if your code will miss bars. All right, if you have a minute code (on what timeframe, of course), but if you're going to run on an hour or more - there will only be pity for you.
Petiyashaket: I have experimented with brackets in different ways, I have removed and added them, the result is the same
You don't need to experiment, you need to understand the meaning of these brackets and how to apply them. It's written in the documentation, I won't read a lecture about it.
if(Up>0&&Down==0&&Volume[0]<2) //если верхний фрактал есть а нижнего нету и прошло не больше 2х тиков то:
{
if((High[3]+5*Point-Ask)/Point>MarketInfo(Symbol(),MODE_STOPLEVEL)) //если расстояние 0 бара от хая фрактала позволяет то:OrderSend(Symbol(),OP_BUYSTOP,Lot,High[3]+5*Point,20,High[3]-sl,High[3]+tp,NULL,Magic,0,Green);//выставляем отложенный на покупкуelse {BS=High[3]+5*Point; Print("Виртуальный BS:",BS);} // а ели нет то запоминаем(позже будет добавлен вход с рынка)for (int pos=0;pos==OrdersTotal();pos++)
{ // наверное сюда её надо
OrderSelect(pos,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol()&&OrderType()==OP_BUYSTOP)
{
OrderModify(OrderTicket(),Up+5*Point,High[3]-sl,High[3]+tp,0,CLR_NONE);
}
} // это пара к той...}
But this is only part of the code. There is a similar problem further on.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I withdraw the question, I've figured it out myself.
I need a buy stop trailed (modified) by price fractals until it triggers and a sell stop in the same way.
So the question in your code, highlighted in red.
You still haven't answered. I don't know what to do with it, but the result of code execution will be different.
So the question in your code, highlighted in red.
You still haven't answered. And from this the result of code execution will be different.
Why do you useVolume[0]<2 in the condition?
Sometimes in one tick there is a bunch of them. And on this bar the condition won't work anymore.
Why do you useVolume[0]<2 in the condition?
Sometimes there are a bunch of them in one tick. And on this bar the condition will not work anymore
Victor, this question is not for me. I use this function.
I copied a piece of code to ask a question about brackets.
Why do you useVolume[0]<2 in the condition?
Sometimes there are a bunch of them in one tick. And on this bar the condition will not work anymore
This is what Oleg Remizov teaches on YouTube, this condition restricts trading on the news and catching moose :)
So the question in your code, highlighted in red.
has never been answered. And that will make the result of code execution different, too.
I have experimented with brackets in different ways, I have removed and added them, the result is the same
You don't need to experiment, you need to understand the meaning of these brackets and how to apply them. It's written in the documentation, I won't read a lecture about it.
But this is only part of the code. There is a similar problem further on.This formula is quite easy to adjust to the requirements. You just have to take into account the minimum lot
This looks a little different
Where X - Balance for opening the minimum lot,
But we still need to check for the minimum lot.
Why do we need all these complexities, X that must be calculated separately? Besides, we'll need additional checking...
Wouldn't it be easier to directly and honestly check validity and acceptability of all values of the formula, and then just honestly calculate it?
By the way, MathRound() rounds to the nearest integer, that is, it can easily overestimate wrongly, which may cause additional consequences.