Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 471
![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
I can only assume: because the object has not yet been formed.
No, there must be a mistake, it should be like in 5, or am I confused?
No, there must be a mistake, it should be like the 5, or am I confused?
Don't forget that Close[0] doesn't exist, it's just that we're used to it differently.
don't do this... doesn't exist...
"There is no spoon" (c) )))
Close[0]=Bid, so...
don't do this... doesn't exist...
"There is no spoon" )))
Close[0]=Bid, here...
You should ask the Metakwots, not me:)
Hello, I have the following problem. The log gives an OrderModify of 130 when tested, help me find a way out. Here is the code of advisor:
//+------------------------------------------------------------------+
//| Test3.mq4
//| Popov Vladimir |
//| http://vk.com/id143715412 |
//+------------------------------------------------------------------+
#property copyright "Popov Vladimir"
#property link "http://vk.com/id143715412"
extern double Lots = 0.1;
extern int TakeProfit = 250;
extern int StopLoss = 100;
extern int Slippage = 10;
extern string comment = "Tma bot";
extern int Magic = 123;
extern string Indi = "Indicator data";
extern string TimeFrame = "current time frame";
extern int HalfLength = 20;
extern int Price = PRICE_CLOSE;
extern double ATRMultiplier = 2.0;
extern inttern ATRPeriod = 100;
extern bool Interpolate = true;
double PriceHigh, PriceLow, SL, TP;
int ticket;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
if (Digits == 3 || Digits == 5)
{
TakeProfit *= 10;
StopLoss *= 10;
Slippage *= 10;
}
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
PriceHigh = iCustom (Symbol (), 0, "Time", TimeFrame, HalfLength, Price, ATRMultiplier, ATRPeriod, Interpolate, 1, 0);
PriceLow = iCustom (Symbol (), 0, "Time", TimeFrame, HalfLength, Price, ATRMultiplier, ATRPeriod, Interpolate, 2, 0);
if (Bid >= PriceHigh && CountSell() == 0)
{
SL = NormalizeDouble(Bid+StopLoss*Point, Digits);
SL = NormalizeDouble(Bid-TakeProfit*Point, Digits);
ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0, comment, Magic, 0, Red);
if (ticket > 0)
{
if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES) == true)
OrderModify(ticket, OrderOpenPrice(), SL, TP, 0);
}
}
if(Ask <= PriceLow && CountBuy() == 0)
{
SL = NormalizeDouble(Ask-StopLoss*Point, Digits);
SL = NormalizeDouble(Ask+TakeProfit*Point, Digits);
ticket = OrderSend(Symbol(), OP_BUY, Lots, Bid, Slippage, 0, 0, comment, Magic, 0, Blue);
if (ticket > 0)
{
if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES) == true)
OrderModify(ticket, OrderOpenPrice(), SL, TP, 0);
}
}
if (Ask <= PriceLow && CountSell() > 0)
{
for(int i=OrdersTotal()-1; i >=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == true)
{
if(OrderMagicNumber() == Magic && OrderType() == OP_SELL)
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Black);
}
}
}
if (Bid >= PriceLow && CountBuy() > 0)
{
for(i=OrdersTotal()-1; i >=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == true)
{
if(OrderMagicNumber() == Magic && OrderType() == OP_BUY)
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Green);
}
}
}
return(0);
}
//+------------------------------------------------------------------+
int CountBuy()
{
int count = 0;
for (int tr = OrdersTotal()-1; tr >= 0; tr --)
{
OrderSelect(tr, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
{
if (OrderType() == OP_BUY)
count++;
}
}
return (count);
}
//+------------------------------------------------------------------+
int CountSell()
{
int count = 0;
for (int tr= OrdersTotal()-1; tr >= 0; tr --)
{
OrderSelect(tr, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
{
if (OrderType() == OP_SELL)
count++;
}
}
return (count);
}
Correct it here
In the second case it should be TPOh, man...
Thank you, Roger!
Hello, I have the following problem. The log gives an OrderModify of 130 when tested, help me find a way out. Here is the code of the EA: