Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 471

 
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?

 
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.
 
Close[0] - The closing price of the candle at the current time, as well as all other parameters high, low...
 
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...

 
evillive:

don't do this... doesn't exist...

"There is no spoon" )))

Close[0]=Bid, here...



You should ask the Metakwots, not me:)
 
I would inexperiencedly use any reference to a quote that has not yet been made to disrupt an appeal.
 

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

SL = NormalizeDouble(Ask-StopLoss*Point, Digits);

 SL = NormalizeDouble(Ask+TakeProfit*Point, Digits);
In the second case it should be TP
 

Oh, man...

Thank you, Roger!

 
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);     И здесь
Reason: