Скачать MetaTrader 5
Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий
Как протестировать программу перед покупкой?
midav
33
midav 2013.12.02 19:10 

Здравствуйте, вот у меня такая проблема: когда я списывал советник, списывал я с видео, и что то напортачил и вот он выдаёт такую ошибку... не могли бы вы помочь найти ошибку эту сам советник вот : //+------------------------------------------------------------------+

//| 21.mq4 |

//| Copyright 2013, MetaQuotes Software Corp. |

//| http://www.metaquotes.net |

//+------------------------------------------------------------------+

#property copyright "Copyright 2013, MetaQuotes Software Corp."

#property link "http://www.metaquotes.net"




extern double Lots = 0.1;

extern int TakeProfit = 50;

extern int Step = 50;

extern double Multiplier = 2;

extern int Slippage = 5;

extern int Magic = 123;


int ticket;

double price, TP, lastlot;

//+------------------------------------------------------------------+

//| expert initialization function |

//+------------------------------------------------------------------+

int init()

{

if (Digits == 3 || Digits == 5)

{

TakeProfit *= 10;

Step *= 10;

Slippage *= 10;

}

return(0);

}

//+------------------------------------------------------------------+

//| expert deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{


return(0);

}

//+------------------------------------------------------------------+

//| expert start function |

//+------------------------------------------------------------------+

int start()

{

if (CountTrades() == 0)

{

double ima = iMA(Symbol(), PERIOD_H1, 14, 0, MODE_SMA, PRICE_CLOSE, 1);

if (Ask > ima)

{

ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, "", Magic,0, Blue);

if(ticket > 0)

{

TP = NormalizeDouble(Ask + TakeProfit * Point, Digits);

OrderModify(ticket, OrderOpenPrice(), 0, TP, 0);

}

}

else if(Bid < ima)

{

ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0, "", Magic,0, Red);

if(ticket > 0)

{

TP = NormalizeDouble(Bid - TakeProfit * Point, Digits);

OrderModify(ticket, OrderOpenPrice(), 0, TP, 0);

}

}

}

else

{

int order_type = FindLastOrderType();

if (order_type == OP_BUY)

{

price = FindLastPrice(OP_BUY);

if(Ask <= price - Step * Point)

{

lastlot = FindLastLots(OP_BUY);

lastlot = NormalizeDouble(lastlot * Multiplier, 2);

ticket = OrderSend(Symbol(), OP_BUY, lastlot, Ask, Slippage, 0, 0, "", Magic, 0, Blue);

if (ticket > 0)

ModifyOrders(OP_BUY);

}

}

else if (order_type == OP_SELL)

{

price = FindLastPrice(OP_SELL);

if(Bid <= price + Step * Point)

{

lastlot = FindLastLots(OP_SELL);

lastlot = NormalizeDouble(lastlot * Multiplier, 2);

ticket = OrderSend(Symbol(), OP_SELL, lastlot, Bid, Slippage, 0, 0, "", Magic, 0, Red);

if (ticket > 0)

ModifyOrders(OP_SELL);

}

}

}

return(0);

}

//+------------------------------------------------------------------+

void ModifyOrders(int otype)

{

double avgprice = 0,

order_lots = 0;

price = 0;

for (int i=OrdersTotal-1; i>=0; i--)

{

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

{

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype)

{

price += OrderOpenPrice() * OrderLots();

order_lots += OrderLots();

}

}


}

avgprice = NormalizeDouble(price / order_lots, Digits);

if (otype == OP_BUY) TP = NormalizeDouble(avgprice + TakeProfit*Point, Digits);

if (otype == OP_SELL) TP = NormalizeDouble(avgprice - TakeProfit*Point, Digits);

for (i=OrdersTotal()-1; i>=0; i--)

{

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

{

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype)

OrderModify(OrderTicket(), OrderOpenPrice(), 0, TP, 0);

}

}

}

//+------------------------------------------------------------------+

double FindLastLots(int otype)

{

double oldlots;

int oldticket;

ticket = 0;

for(int i = OrdersTotal()-1; i>=0; i--)

{

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

{

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype)

{

oldticket = OrderTicket();

if(oldticket > ticket)

{

oldlots = OrderLots();

ticket = oldticket;

}

}

}

}

return(oldlots);

}

//+------------------------------------------------------------------+

double FindLastPrice (int otype)

{

double oldopenprice;

int oldticket;

ticket = 0;

for(int i=OrdersTotal()-1; i>=0; i--)

{

if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

{

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype)

{

oldticket = OrderTicket();

if(oldticket > ticket)

{

oldopenprice = OrderOpenPrice();

ticket = oldticket;

}

}

}

}

return(oldopenprice);

}

//+------------------------------------------------------------------+

int FindLastOrderType()

{

for (int i= OrdersTotal()-1; i>=0; i--)

{

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

{

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)

return(OrderType());

}

}

return(-1);

}

//+------------------------------------------------------------------+



int CountTrades()

{

int count = 0;

for (int i=OrdersTotal()-1; i>=0; i-- )

{

if(OrderSelect (i, SELECT_BY_POS, MODE_TRADES);

{

if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)

count++;

}

}


return(count);

}

Khizantsyan Arsentiy
73
Khizantsyan Arsentiy 2013.12.02 19:28  
int CountTrades()

{

int count = 0;

for (int i=OrdersTotal()-1; i>=0; i-- )

{

if(OrderSelect (i, SELECT_BY_POS, MODE_TRADES)) // в место " ; "

{

if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)

count++;

}

}


return(count);

}

и еще одна ошибка в коде отсуствует полное написание функции OrdersTotal надобно " () "

midav
33
midav 2013.12.03 15:13  
Спасибо большое!
Khizantsyan Arsentiy
73
Khizantsyan Arsentiy 2013.12.03 16:44  
midav:
Спасибо большое!

Да я сам новичке!! MQL4!! Удачи.
/
Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий