As I understand it, it is responsible for the EA delaying recalculation until a new bar appears. Until the zero bar open time changes, the recalculation stops.
Accordingly, if I open an EA on minutes, it will be recalculated with every new minute. And if I open it on H4, it will be recalculated every 4 hours.
How to write this line correctly, so that the EA will not take the opening time of the current bar, ie, the bar at which the terminal is open, but the one that I will specify in the settings? That is, I place the EA on H4, for example, and it will recalculate every 5 minutes, because I have set it so. Or every minute.
evillive: What is it complaining about in the modification log? "Stupidly opens new pending orders" because there is no limit, but there is an OrderSend.
1) Any strategy must be defined by the number of orders open at the same time. Accordingly, before opening the next order, we should check how many are already open.
2) On one bar, there cannot be UPPER and LOWER fractals at the same time, respectively, the check is classified as
belongs to the category of programmer's idiocy.
3) Before writing the conditions for returning buffer indicator values, you need to know exactly what value is "empty" for it? Have you checked that it is 0?
4) The construct.
Although it will work (in most cases), but is unnatural, because it is a "free-will" idea of the developer, and is uninformative for the trader. An alternative - the tracking of a new bar.
5) You have to start from the basics, because this:
Indicates that you don't understand what you're writing at all.
The best way to understand is to study how other people's codes work and modify them for your own purposes. Good luck.
He displays them as written, point by point. He does not modify them, which you have not said a word about. Here is the full code:
//+------------------------------------------------------------------+//| Strategy 3.mq4 |//| |//| |//+------------------------------------------------------------------+#property copyright""#property link""#include <Library1.mqh>
externint Magic=111;
externint TP=20;
externint SL=30;
externint Trall_dist=10;
externint Shag=10;
externbool Isp_shag=false;
externbool Isp_bezubitok=false;
externdouble Lot=0.1;
double SS=0,BS=0;
//+------------------------------------------------------------------+//| expert initialization function |//+------------------------------------------------------------------+int init()
{
//----//----return(0);
}
//+------------------------------------------------------------------+//| expert deinitialization function |//+------------------------------------------------------------------+int deinit()
{
//----//----return(0);
}
//+------------------------------------------------------------------+//| expert start function |//+------------------------------------------------------------------+int start()
{
double tp,sl;
if(Digits==3||Digits==5) {tp=TP*10*Point;sl=SL*10*Point;} // условие для пятизнака
elseif(Digits==2||Digits==4) {tp=TP*Point;sl=SL*Point;} // условие для четырехзнака
double Up=iFractals(Symbol(),0,MODE_UPPER,3); //верхний фрактал,формируется на третьей свече
double Down=iFractals(Symbol(),0,MODE_LOWER,3); //нижний фрактал,формируется на третьей свече
//----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);
}
}
}
elseif(Up==0&&Down>0&&Volume[0]<2)
{
if((Bid-Low[3]-5*Point)/Point>MarketInfo(Symbol(),MODE_STOPLEVEL))
OrderSend(Symbol(),OP_SELLSTOP,Lot,Low[3]-5*Point,20,Low[3]+sl,Low[3]-tp,NULL,Magic,0,Red);
else {SS=Low[3]-5*Point; Print("Виртуальный SS:",SS);}
{
for (pos=1;pos==OrdersTotal();pos++)
{
OrderSelect(pos,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol()&&OrderType()==OP_SELLSTOP)
{
OrderModify(OrderTicket(),Down-5*Point,Low[3]+sl,Low[3]-tp,0,CLR_NONE);
}
}
}
if(OrdersTotal()>0)
Trailing_stop(Magic,Symbol(),Trall_dist,Shag,Isp_shag,Isp_bezubitok);
return(0);
}}
//+------------------------------------------------------------------+
I'm trying to write as I've read, looked, understood. Your critique reminds me of an MQL4 manual - I understand it only if somebody explains it to me.
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);
}
} // это пара к той...
}
And this code
if(Digits==3||Digits==5) {tp=TP*10*Point;sl=SL*10*Point;} // условие для пятизнакаelseif(Digits==2||Digits==4) {tp=TP*Point;sl=SL*Point;} // условие для четырехзнака
it is better to write in init() and better not like this
double point; // на уровне глобальных переменныхintOnInit()
{
point = Digits%2 == 0 ? _Point : _Point * 10;
}
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.
2) There cannot be UPPER and LOWER fractals on the same bar at the same time, respectively, check
belongs to the category of programmer idiocy.
Both fractals can be on the same bar
he meant minutes, but forgot about months
What's the difference between minutes and months?
What is it complaining about in the modification log? "Stupidly opens new pending orders" because there is no limit, but there is an OrderSend.
What's the difference between minutes and months?
1) Any strategy must be defined by the number of orders open at the same time. Accordingly, before opening the next order, we should check how many are already open.
2) On one bar, there cannot be UPPER and LOWER fractals at the same time, respectively, the check is classified as
belongs to the category of programmer's idiocy.
3) Before writing the conditions for returning buffer indicator values, you need to know exactly what value is "empty" for it? Have you checked that it is 0?
4) The construct.
Although it will work (in most cases), but is unnatural, because it is a "free-will" idea of the developer, and is uninformative for the trader. An alternative - the tracking of a new bar.
5) You have to start from the basics, because this:
Indicates that you don't understand what you're writing at all.
The best way to understand is to study how other people's codes work and modify them for your own purposes. Good luck.
And this code
it is better to write in init() and better not like this
and then in start()
tp = High[3]+TP*point;And this code
it is better to write in init() and better not like this
and then in start()