Questions from Beginners MQL4 MT4 MetaTrader 4 - page 5

You are missing trading opportunities:
- Free trading apps
- Free Forex VPS for 24 hours
- 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
MT4 Batter volum is also inadequate in the tester
Can you tell me why it opens on every tick?
{
Alert(Sborinfo(Magic));
if(Sborinfo(Magic)<=0)
{
MassivPrice(step);
tiket=OrderSend(Symbol(),OP_BUY,0.01,Ask,0,0,0,NULL,0,0,Blue);
if(tiket>=0)
LastPrice=Ask;
else LastPrice=-1;
}
MassivPrice(step);
tiket=OrderSend(Symbol(),OP_SELL,0.01,Bid,0,0,0,NULL,0,0,Red);
if(tiket>=0)
LastPrice=Bid;
else LastPrice=-1;
}
//+------------------------------------------------------------------+
int Sborinfo(int magic)
{
for(int i=0; i<OrdersTotal(); i++)
{
Print("колличество ордеров ",kol);
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderMagicNumber()==magic)
kol++;
}
Print("новые ордера ",kol);
return(kol);
}
Can you tell me why it opens on every tick?
Because I always test in this mode
{
Alert(Sborinfo(Magic));
if(Sborinfo(Magic)<=0)
{
MassivPrice(step);
tiket=OrderSend(Symbol(),OP_BUY,0.01,Ask,0,0,0,NULL,0,0,Blue);
if(tiket>=0)
LastPrice=Ask;
else LastPrice=-1;
}
MassivPrice(step);
tiket=OrderSend(Symbol(),OP_SELL,0.01,Bid,0,0,0,NULL,0,0,Red);
if(tiket>=0)
LastPrice=Bid;
else LastPrice=-1;
}
//+------------------------------------------------------------------+
int Sborinfo(int magic)
{
for(int i=0; i<OrdersTotal(); i++)
{
Print("колличество ордеров ",kol);
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderMagicNumber()==magic)
kol++;
}
Print("новые ордера ",kol);
return(kol);
}
Can you tell me why it opens on every tick?
Because that is how the code is written.
In simple terms, your algorithm looks like this: if there are no orders, open Buy, and at every tick, open Sell.
Because that's how the code is written.
In simple terms, your algorithm looks like this: if there are no orders, open a Buy, and at every tick, open a Sell.
// Closse(Magic);
if(Sborinfo(Magic)==0)
{
Print("количество ордеров ",Sborinfo(Magic));
MassivPrice(step);
if(OrdersTotal()<2)// без таких условий
tiket=OrderSend(Symbol(),OP_BUY,0.01,Ask,slippage,0,0,NULL,0,0,Green);
if(tiket>=0)
LastPrice=Ask;
}
MassivPrice(step);
if(OrdersTotal()<2)// без таких условий
tiket=OrderSend(Symbol(),OP_SELL,0.01,Bid,slippage,0,0,NULL,0,0,Red);
if(tiket>=0)
LastPrice=Bid;
}
//+------------------------------------------------------------------+
int Sborinfo(int magic)
{
kol=0;
for(int i=0; i<OrdersTotal(); i++)
{
Print(" чему ровно кол " , kol );
if(OrderSelect(i,SELECT_BY_POS) && OrderMagicNumber()==magic)
{
Print(" ордера после " , kol );
// kol++;
}
}
return(kol);
}
How do you change the code to work without additional conditions ?
But you can't, if you need both buy and sell and limit their number. Only I would not look atOrdersTotal(), and would count how much buy and how much sell.
And again, why do you need this "if(Sborinfo(Magic)==0)" if you then useOrdersTotal()?
But you can't, if you need both buy and sell and limit their number. Only I would not look atOrdersTotal(), and would count how much buy and how much sell.
And again, why do you need this "if(Sborinfo(Magic)==0)", if you then useOrdersTotal()?
CloseFirst(Magic);
int b=0;
int s=0;
for(int i=0; i<=OrdersTotal(); i++)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true && OrderMagicNumber()==Magic && OrderSymbol()==_Symbol )
{
if(OrderType()==OP_BUY)
b++;
if(OrderType()==OP_SELL)
s++;
}
if(b==0)
tiket=OrderSend(Symbol(),OP_BUY,0.01,Ask,slippage,0,0,NULL,Magic,0,Green);
if(s==0)
tiket=OrderSend(Symbol(),OP_SELL,0.01,Bid,slippage,0,0,NULL,Magic,0,Red);
}
Comrades! I have a question.
The Expert Advisor opens pending orders at 00:00 from the beginning of the day based on the previous day's extremums.
On weekdays, everything works fine, but with Monday's opening,the pending orders are not placed at Friday's extremes, but at Thursday's levels for some reason. How come?
currtime=TimeToStr(TimeCurrent(),TIME_MINUTES);
Format=Digits();
DH=NormalizeDouble(iHigh(NULL,PERIOD_D1,1),Format) ;
DL=NormalizeDouble(iLow(NULL,PERIOD_D1,1),Format);
if (currtime==OpenTime)
{
отложки
}
You mean like this? Are there any other options - simpler?
Yeah, that's about right. How much simpler?
Yeah, that's about right. How much easier could it be?