Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 471 1...464465466467468469470471472473474475476477478...1177 New comment Oleg 2014.02.09 21:49 #4701 tara: 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? Алексей Тарабанов 2014.02.09 22:00 #4702 beginner: 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. Oleg 2014.02.09 22:03 #4703 Close[0] - The closing price of the candle at the current time, as well as all other parameters high, low... Vitalie Postolache 2014.02.09 22:06 #4704 tara: 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... Алексей Тарабанов 2014.02.09 22:09 #4705 evillive: don't do this... doesn't exist... "There is no spoon" ))) Close[0]=Bid, here... You should ask the Metakwots, not me:) Алексей Тарабанов 2014.02.09 22:21 #4706 I would inexperiencedly use any reference to a quote that has not yet been made to disrupt an appeal. Pr0t0ip 2014.02.10 18:31 #4707 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); } Questions from Beginners MQL5 Any questions from newcomers I will write a Alexander 2014.02.10 18:40 #4708 Correct it here SL = NormalizeDouble(Ask-StopLoss*Point, Digits); SL = NormalizeDouble(Ask+TakeProfit*Point, Digits); In the second case it should be TP Pr0t0ip 2014.02.10 18:43 #4709 Oh, man... Thank you, Roger! Alekseu Fedotov 2014.02.10 18:51 #4710 Pr0t0tip: 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: SL = NormalizeDouble(Bid+StopLoss*Point, Digits); SL = NormalizeDouble(Bid-TakeProfit*Point, Digits); Здесь поменяй SL на TP SL = NormalizeDouble(Ask-StopLoss*Point, Digits); SL = NormalizeDouble(Ask+TakeProfit*Point, Digits); И здесь 1...464465466467468469470471472473474475476477478...1177 New comment
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: