Работа завершена
Время выполнения 2 часа
Техническое задание
Здравствуйте уважаемые программисты и трейдеры. Требуется переписать советник с MQL4 на MQL5.
//+------------------------------------------------------------------+ //| H1.mq4 | //| Hoffmann Willi | //| | //+------------------------------------------------------------------+ #property copyright "Hoffmann Willi" #property link "" #property version "1.00" #property strict // Folgende Parameter sollen beim Start abgefragt werden: extern int Magic_Buy = 19251; // Magic Nr. Buy extern int Magic_Sell = 19252; // Magic Nr. Sell extern double Kauf_Lots = 0.1; extern ENUM_TIMEFRAMES timeFrame = PERIOD_H1; // Zeitfenster extern int SL_A = 50; // SL Abstand extern int TP_A = 50; // min TP extern int Start_2 = 10; // Handelszeit Start nach 0 Uhr extern int Ende_2 = 11; // Handelszeit Start nach 0 Uhr extern int Start_1 = 15; // Handelszeit Start vor 0 Uhr extern int Ende_1 = 20; // Handelszeit Ende vor 0 Uhr extern int max_Spread = 30; // Maximaler Spread extern int Slippage = 3; // Slippage double spread, Poin; int n_digits = 0; double divider = 1; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { if(Digits == 3 || Digits == 5) { Slippage *= 10; } return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //Checking for unconvetional Point digits number if (Point == 0.00001) Poin = 0.0001; //5 digits else if (Point == 0.001) Poin = 0.01; //3 digits else Poin = Point; //Normal if ((Poin > Point) && (false)) { divider = 10.0; n_digits = 1; } spread = (Ask - Bid) / Point; //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Buy öffnen if ((TimeHour(TimeCurrent()) >= Start_1 && TimeHour(TimeCurrent()) < Ende_1) || (TimeHour(TimeCurrent()) >= Start_2 && TimeHour(TimeCurrent()) < Ende_2)) { if (Anzahl_Buy_Order() == 0 && Anzahl_g_Buy_Order() == 0 && DoubleToStr(NormalizeDouble(spread / divider, 1), n_digits) < max_Spread) { int tiket = OrderSend(Symbol(),OP_BUY,Kauf_Lots,Ask,Slippage,NormalizeDouble(Ask - SL_A * Point, Digits),NormalizeDouble(Ask + TP_A * Point, Digits),"",Magic_Buy,0,0); if (tiket > 0) { Alert (Symbol()," Buy open, Lot: ", Kauf_Lots); } else { Print ("Buy Order konnte nicht ausgeführt werden"); } } } // Sell öffnen if ((TimeHour(TimeCurrent()) >= Start_1 && TimeHour(TimeCurrent()) < Ende_1) || (TimeHour(TimeCurrent()) >= Start_2 && TimeHour(TimeCurrent()) < Ende_2)) { if (Anzahl_Sell_Order() == 0 && Anzahl_g_Sell_Order() == 0 && DoubleToStr(NormalizeDouble(spread / divider, 1), n_digits) < max_Spread) { int tiket = OrderSend(Symbol(),OP_SELL,Kauf_Lots,Bid,Slippage,NormalizeDouble(Bid + SL_A * Point, Digits),NormalizeDouble(Bid - TP_A * Point, Digits),"",Magic_Sell,0,0); if (tiket > 0) { Alert (Symbol()," Sell open, Lot: ", Kauf_Lots); } else { Print ("Sell Order konnte nicht ausgeführt werden"); } } } //+------------------------------------------------------------------+ } //+------------------------------------------------------------------+ // Anzahl vorhandenen Buy_Order int Anzahl_Buy_Order() { int count = 0; for(int i=OrdersTotal()-1; i>=0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == true && OrderSymbol() == Symbol() && OrderType() == OP_BUY && OrderMagicNumber() == Magic_Buy) { count++; } } return(count); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Anzahl vorhandenen Sell_Order int Anzahl_Sell_Order() { int count = 0; for(int i=OrdersTotal()-1; i>=0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == true && OrderSymbol() == Symbol() && OrderType() == OP_SELL && OrderMagicNumber() == Magic_Sell) { count++; } } return(count); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Anzahl in letzten Bar geschlossenen Buy_Order int Anzahl_g_Buy_Order() { int count = 0; for(int i=OrdersHistoryTotal()-1; i>=0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) == true && OrderSymbol() == Symbol() && OrderType() == OP_BUY && OrderMagicNumber() == Magic_Buy && OrderCloseTime() > iTime(NULL,timeFrame,0)) { count++; } } return(count); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Anzahl in letzten Bar geschlossenen Sell_Order int Anzahl_g_Sell_Order() { int count = 0; for(int i=OrdersHistoryTotal()-1; i>=0; i--) { if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) == true && OrderSymbol() == Symbol() && OrderType() == OP_SELL && OrderMagicNumber() == Magic_Sell && OrderCloseTime() > iTime(NULL,timeFrame,0)) { count++; } } return(count); } //+---------------------------------------------------------------------+
Откликнулись
1
Оценка
Проекты
650
28%
Арбитраж
111
19%
/
61%
Просрочено
319
49%
Свободен
2
Оценка
Проекты
240
60%
Арбитраж
3
67%
/
0%
Просрочено
6
3%
Работает
3
Оценка
Проекты
8
88%
Арбитраж
0
Просрочено
0
Свободен
Информация о проекте
Бюджет
30+ USD
VAT (19%):
5.7
USD
Итого:
35.7
USD
Исполнителю
27
USD