초보자의 질문 MQL5 MT5 MetaTrader 5 - 페이지 1121

 

모두들 좋은 하루 되시고 큰 수익!

VQL5 Wizard를 사용하여 간단한 Expert Advisor를 생성했습니다. 코드는 아래와 같습니다. "대기 주문 만료(막대 단위)" 기능이 작동하지 않는 이유를 이해하도록 도와주세요. "대기 주문 만료(막대 단위)"로 번역됩니다. Signal_Expiration 값을 1에서 1000까지 설정했지만 여전히 보류 중인 주문은 하나의 막대 동안만 존재합니다. 설정도 첨부합니다.

테스트를 위해 Metatrader 5 터미널 빌드 2136의 데모 계정을 사용합니다.

안부 인사를 전합니다. 블라디미르.

 //+------------------------------------------------------------------+
//|                                                EA_MasterMQL5.mq5 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link        "https://www.mql5.com"
#property version    "1.00"
//+------------------------------------------------------------------+
//| Include                                                          |
//+------------------------------------------------------------------+
#include <Expert\Expert.mqh>
//--- available signals
#include <Expert\Signal\SignalITF.mqh>
//--- available trailing
#include <Expert\Trailing\TrailingNone.mqh>
//--- available money management
#include <Expert\Money\MoneyFixedRisk.mqh>
//+------------------------------------------------------------------+
//| Inputs                                                           |
//+------------------------------------------------------------------+
//--- inputs for expert
input string Expert_Title            = "EA_MB_MasterMQL5" ; // Document name
ulong         Expert_MagicNumber      = 1473 ;               //
bool          Expert_EveryTick        = false ;               //
//--- inputs for main signal
input int     Signal_ThresholdOpen    = 0 ;                 // Signal threshold value to open [0...100]
input int     Signal_ThresholdClose   = 0 ;                 // Signal threshold value to close [0...100]
input double Signal_PriceLevel       = 0.0 ;                 // Price level to execute a deal
input double Signal_StopLevel        = 50.0 ;               // Stop Loss level (in points)
input double Signal_TakeLevel        = 50.0 ;               // Take Profit level (in points)
input int     Signal_Expiration       = 4 ;                   // Expiration of pending orders (in bars)
input int     Signal_ITF_GoodHourOfDay=- 1 ;                 // IntradayTimeFilter(-1,...) Good hour
input int     Signal_ITF_BadHoursOfDay= 8389119 ;             // IntradayTimeFilter(-1,...) Bad hours (bit-map)
input int     Signal_ITF_GoodDayOfWeek=- 1 ;                 // IntradayTimeFilter(-1,...) Good day of week
input int     Signal_ITF_BadDaysOfWeek= 0 ;                   // IntradayTimeFilter(-1,...) Bad days of week (bit-map)
input double Signal_ITF_Weight       = 1.0 ;                 // IntradayTimeFilter(-1,...) Weight [0...1.0]
//--- inputs for money
input double Money_FixRisk_Percent   = 10.0 ;               // Risk percentage
//+------------------------------------------------------------------+
//| Global expert object                                             |
//+------------------------------------------------------------------+
CExpert ExtExpert;
//+------------------------------------------------------------------+
//| Initialization function of the expert                            |
//+------------------------------------------------------------------+
int OnInit ()
  {
//--- Initializing expert
   if (!ExtExpert.Init( Symbol (), Period (),Expert_EveryTick,Expert_MagicNumber))
     {
       //--- failed
       printf ( __FUNCTION__ + ": error initializing expert" );
      ExtExpert.Deinit();
       return ( INIT_FAILED );
     }
//--- Creating signal
   CExpertSignal *signal= new CExpertSignal;
   if (signal== NULL )
     {
       //--- failed
       printf ( __FUNCTION__ + ": error creating signal" );
      ExtExpert.Deinit();
       return ( INIT_FAILED );
     }
//---
   ExtExpert.InitSignal(signal);
   signal.ThresholdOpen(Signal_ThresholdOpen);
   signal.ThresholdClose(Signal_ThresholdClose);
   signal.PriceLevel(Signal_PriceLevel);
   signal.StopLevel(Signal_StopLevel);
   signal.TakeLevel(Signal_TakeLevel);
   signal.Expiration(Signal_Expiration);
//--- Creating filter CSignalITF
   CSignalITF *filter0= new CSignalITF;
   if (filter0== NULL )
     {
       //--- failed
       printf ( __FUNCTION__ + ": error creating filter0" );
      ExtExpert.Deinit();
       return ( INIT_FAILED );
     }
   signal.AddFilter(filter0);
//--- Set filter parameters
   filter0.GoodHourOfDay(Signal_ITF_GoodHourOfDay);
   filter0.BadHoursOfDay(Signal_ITF_BadHoursOfDay);
   filter0.GoodDayOfWeek(Signal_ITF_GoodDayOfWeek);
   filter0.BadDaysOfWeek(Signal_ITF_BadDaysOfWeek);
   filter0.Weight(Signal_ITF_Weight);
//--- Creation of trailing object
   CTrailingNone *trailing= new CTrailingNone;
   if (trailing== NULL )
     {
       //--- failed
       printf ( __FUNCTION__ + ": error creating trailing" );
      ExtExpert.Deinit();
       return ( INIT_FAILED );
     }
//--- Add trailing to expert (will be deleted automatically))
   if (!ExtExpert.InitTrailing(trailing))
     {
       //--- failed
       printf ( __FUNCTION__ + ": error initializing trailing" );
      ExtExpert.Deinit();
       return ( INIT_FAILED );
     }
//--- Set trailing parameters
//--- Creation of money object
   CMoneyFixedRisk *money= new CMoneyFixedRisk;
   if (money== NULL )
     {
       //--- failed
       printf ( __FUNCTION__ + ": error creating money" );
      ExtExpert.Deinit();
       return ( INIT_FAILED );
     }
//--- Add money to expert (will be deleted automatically))
   if (!ExtExpert.InitMoney(money))
     {
       //--- failed
       printf ( __FUNCTION__ + ": error initializing money" );
      ExtExpert.Deinit();
       return ( INIT_FAILED );
     }
//--- Set money parameters
   money.Percent(Money_FixRisk_Percent);
//--- Check all trading objects parameters
   if (!ExtExpert.ValidationSettings())
     {
       //--- failed
      ExtExpert.Deinit();
       return ( INIT_FAILED );
     }
//--- Tuning of all necessary indicators
   if (!ExtExpert.InitIndicators())
     {
       //--- failed
       printf ( __FUNCTION__ + ": error initializing indicators" );
      ExtExpert.Deinit();
       return ( INIT_FAILED );
     }
//--- ok
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Deinitialization function of the expert                          |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
  {
   ExtExpert.Deinit();
  }
//+------------------------------------------------------------------+
//| "Tick" event handler function                                    |
//+------------------------------------------------------------------+
void OnTick ()
  {
   ExtExpert. OnTick ();
  }
//+------------------------------------------------------------------+
//| "Trade" event handler function                                   |
//+------------------------------------------------------------------+
void OnTrade ()
  {
   ExtExpert. OnTrade ();
  }
//+------------------------------------------------------------------+
//| "Timer" event handler function                                   |
//+------------------------------------------------------------------+
void OnTimer ()
  {
   ExtExpert. OnTimer ();
  }
//+------------------------------------------------------------------+
 

OrderCloseTime() 대신 개발자가 작동합니까???

MQL5 체험은 4일째인데 벌써 만취!

OrderCloseTime() 함수를 반환합니다. 프로그래밍 방식으로 동일한 위치를 어떻게든 수행할 수 있습니다. .... - 주문 - 다음 거래 - 다음 위치, 아니면 기계로 위치를 계산하는 것이 그렇게 어렵습니까?

 //+------------------------------------------------------------------+
//| Check for close position conditions                              |
//+------------------------------------------------------------------+
// fxsaber

datetime TimCloseHisPos(){

datetime timCloseHisPos = 0 ;

if (!ticket1)
ticket1 = TradeClose.PositionOpen( _Symbol , ORDER_TYPE_BUY , 0.1 , Ask_, Ask_ - 100 * Point_, Ask_ + 100 * Point_) ? TradeClose.ResultOrder() : 0 ;
else if (! PositionSelectByTicket (ticket1) && HistorySelectByPosition (ticket1) && HistoryDealGetString (ticket1, DEAL_SYMBOL )== _Symbol )
{
ENUM_ORDER_TYPE cmd = ( ENUM_ORDER_TYPE ) HistoryOrderGetInteger ( HistoryOrderGetTicket ( HistoryOrdersTotal () - 1 ), ORDER_TYPE );
double open = cmd ? Bid_ : Ask_;
double tp = open - (cmd ? 1 : - 1 ) * 100 * Point_;
double sl = open + (cmd ? 1 : - 1 ) * 100 * Point_;
ticket1 = TradeClose.PositionOpen( _Symbol , cmd, 0.1 , open, sl, tp) ? TradeClose.ResultOrder() : 0 ;
}
// Pul-Adgi Mo-UlStan
if ( HistoryDealSelect (ticket1))
{
//--- время совершения сделки в миллисекундах от 01.01.1970
timCloseHisPos=( datetime ) HistoryDealGetInteger (ticket1, DEAL_TIME_MSC );
}
return (timCloseHisPos);
}
//+------------------------------------------------------------------+
 

좋은 오후에요 여러분!

아무에게도 방해가 되지 않는다면 ML5에서 작동하도록 MQL4 코드를 수정하십시오.

 int init()
   {

         info_init();                                                 // Вызов функции менеджера инициализации вывода информации на экран
         Fun_Label();                                                 // Вызов функции вывода информации на экран (чтобы сразу видно было)
    return(0);                                                        // Выход из init()
   }


int deinit()
   {
         info_deinit();                                               // Удаляем вывод информации на экран из блоков 1 - 8 
    return(0);                                                        // Выход из deinit()
   }


int start()
   {
         Fun_Label();                                                 // Ввод параметров для вывод информации на экран
    return(0);                                                        // Выход из start()
   }




void info_init()
   {
    info_init_1();  info(   0 , "." ,Tan, 8 ); // info( 10,".",Tan,8); info( 20,".",Tan,8); info( 30,".",Tan,8); // Tan - самое короткое название цвета
   }


void info_init_1()
   {
    for ( int row = 0 ; row <= 9 ; row ++)                                           // row - номер текстовой метки (строки сообщения)
        {             
         info_LabelCreate( StringConcatenate ( "InfoLabel_0" , row ), 1000 , 15 + 15 *row ); // Вызов функции _LabelCreate
        }           // Передаются      string _Name, int _XDistance, int _YDistance
    }


void info_LabelCreate( string _Name, int _XDist, int _YDist, int _Corner = 0 )       // Координаты: х = _XDist, у = _YDist, угол = _Corner.
   {
     int _GetLastError;

     if (! ObjectCreate (_Name, OBJ_LABEL , 0 , 0 , 0 ))           // Объекты с типом OBJ_LABEL игнорируют координаты, поэтому используем функцию ObjectSet()...
        {                                                   // ...  для установки свойств OBJPROP_XDISTANCE, OBJPROP_YDISTANCE и OBJPROP_CORNER
         _GetLastError = GetLastError ();
         if (_GetLastError != 4200 )                         // 4200 - Объект уже существует
             {
               Print ( "ObjectCreate(\"" , _Name, "\", OBJ_LABEL,0,0,0) - Error #" , _GetLastError);
             }
        }

     if (!ObjectSet(_Name, OBJPROP_XDISTANCE , _XDist))       // OBJPROP_XDISTANCE - Дистанция в пикселях по оси X от угла привязки
        {
         _GetLastError = GetLastError ();
         Print ( "ObjectSet( \"" , _Name, "\", OBJPROP_XDISTANCE, " , _XDist, ") - Error #" , _GetLastError);
        }
     if (!ObjectSet(_Name, OBJPROP_YDISTANCE , _YDist))       // OBJPROP_YDISTANCE - Дистанция в пикселях по оси Y от угла привязки
        {
         _GetLastError = GetLastError ();
         Print ( "ObjectSet( \"" , _Name, "\", OBJPROP_YDISTANCE, " , _YDist, ") - Error #" , _GetLastError);
        }
     if (!ObjectSet(_Name, OBJPROP_CORNER , _Corner))         // OBJPROP_CORNER - Угол графика для привязки графического объекта
        {
         _GetLastError = GetLastError ();
         Print ( "ObjectSet( \"" , _Name, "\", OBJPROP_CORNER, " , _Corner, ") - Error #" , _GetLastError);
        }

     if (!ObjectSetText(_Name, "" , 10 ))                     // Задаём размер шрифта (font_size)
        {
         _GetLastError = GetLastError ();
         Print ( "ObjectSetText( \"" , _Name, "\", \"\", 10 ) - Error #" , _GetLastError);
        }
   }


void info_deinit() // Удаление объектов, созданных функцией info_init() для блоков 1-8 
   {
    int _GetLastError;
    for ( int row = 0 ; row <= 9 ; row ++ )
        {

         if ( ! ObjectDelete ( StringConcatenate ( "InfoLabel_0" , row ) ) )
             {_GetLastError = GetLastError (); Print ( "ObjectDelete( \"" , StringConcatenate ( "InfoLabel_0" , row ), "\" ) - Error #" , _GetLastError ); }
        }
   }


void info( int LabelNumber, string Text, color Color = 17000000 , double FontSize = - 1.0 , string Font = "-1" )
   {
     //---- определяем имя объекта
     string LabelName;

     if ( LabelNumber <   10 )
         LabelName = StringConcatenate ( "InfoLabel_0" , LabelNumber );   // Обязательно "0" впереди перед ОДИНОЧНЫМИ цифрами

     color   lastusedColor    = Black;
     double lastusedFontSize = 9.0 ;
     string lastusedFont     = "Arial" ;

     //---- если значения дополнительных параметров не задавались, устанавливаем последние используемые значения
     if (Color == 17000000 ) Color    = lastusedColor;           // 0-чёрный, 16 777 215-белый, 17000000-цвета нет
     if (FontSize < 0 )      FontSize = lastusedFontSize;
     if (Font == "-1" )      Font     = lastusedFont;

     //---- запоминаем последние используемые значения
    lastusedColor    = Color;
    lastusedFontSize = FontSize;
    lastusedFont     = Font;

     //---- отображаем новый текст
     if (!ObjectSetText(LabelName, Text, FontSize, Font, Color))
        {
         int _GetLastError = GetLastError ();
         Print ( "ObjectSetText( \"" , LabelName, "\", \"" , Text, "\", " , FontSize, ", " , Font, ", " , Color, " ) - Error #" , _GetLastError);
        }
     //---- перерисовываем объекты
    ObjectsRedraw();
   }


void Fun_Label()                                                       // Ввод параметров для вывод информации на экран
   {
    info(   0 , "x" , Magenta, 8 );
    info(   1 , "x" , Magenta, 8 );
    info(   2 , "x" , Magenta, 8 );
    info(   3 , "x" , Magenta, 8 );
    info(   4 , "x" , Magenta, 8 );
    info(   5 , "x" , Magenta, 8 );
    info(   6 , "x" , Magenta, 8 );
    info(   7 , "x" , Magenta, 8 );
    info(   8 , "x" , Magenta, 8 );
    info(   9 , "x" , Magenta, 8 );
   }
 

플랫폼의 부자연스러운 동작을 관찰합니다.

1. ME5는 종료 당시의 인터페이스 설정을 저장하지 않습니다. 특히 설정 패널이 사라집니다. 복원할 수 있지만 켤 때마다 복원해야 합니다.

2. 지표 만들기. MT5에서 표시기 설정을 변경하면 일반적으로 실패로 이어집니다. 선 모양이 크게 변경되고 색상을 변경할 수 없는 등입니다.
또한 새로 설치된 표시기에서 설정을 변경하면 모든 것이 의도한 대로 작동합니다.

질문:

1. 저만 그런건가요 아니면 일반적인 문제인가요?
2. 제가 고려하지 않은 부분이나 잘못된 부분이 있으면 말씀해주세요.

 
이 주제와 관련이 없는 댓글은 " MQL4 MT4 MetaTrader 4 초보자의 질문 "으로 이동되었습니다.
 
Leo59 :

좋은 오후에요 여러분!

아무에게도 방해가 되지 않는다면 ML5에서 작동하도록 MQL4 코드를 수정하십시오.

먼저 시스템 기능을 올바르게 작성해야 합니다. 이를 수행하는 가장 쉬운 방법은 MetaEditor 5 메뉴 파일 - 새로 만들기 - Expert Advisor(템플릿)입니다. 내 코드와 비교:

 //+------------------------------------------------------------------+
//|                                                            1.mq5 |
//|                              Copyright © 2019, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2019, Vladimir Karputov"
#property link        "http://wmua.ru/slesar/"
#property version    "1.00"
//--- input parameters
input int       Input1= 9 ;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit ()
  {
//---
   
//---
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick ()
  {
//---
   
  }
//+------------------------------------------------------------------+
수정하면 계속 진행하겠습니다...
 
Pul-Adgi Mo-UlStan :

OrderCloseTime() 대신 개발자가 작동합니까???

MQL5 체험은 4일째인데 벌써 만취!

OrderCloseTime() 함수를 반환합니다. 프로그래밍 방식으로 동일한 위치를 어떻게든 수행할 수 있습니다. .... - 주문 - 다음 거래 - 다음 위치, 아니면 기계로 위치를 계산하는 것이 그렇게 어렵습니까?

정확히 무엇을 받고 싶습니까? 마지막 TRADE( TRADE 유형 "시장 출구")의 시간이 필요합니까? 아니면 거래 내역에서 일부 POSITION의 마감 시간을 알아야 합니까?

 
User_mt5 :

플랫폼의 부자연스러운 동작을 관찰합니다.

1. ME5는 종료 당시의 인터페이스 설정을 저장하지 않습니다. 특히 설정 패널이 사라집니다. 복원할 수 있지만 켤 때마다 복원해야 합니다.


ME는 누구입니까? 설정 패널이란 무엇입니까?

 
Vladimir Karputov :

ME는 누구입니까? 설정 패널이란 무엇입니까?

ME = 메타에디터.

설정 패널은 내 주의 사항입니다. 컴파일을 비롯한 버튼이 있는 도구 모음을 나타냅니다.
(나는 관성에 의해 "설정"이라고 말했습니다 - 그것은 또한 표시기 매개변수의 설정 패널로 고통받는 MT5의 저입니다)

2019년 9월 6일부터 빌드 2138.
 
User_mt5 :

ME = 메타에디터.

설정 패널은 내 주의 사항입니다. 컴파일을 비롯한 버튼이 있는 도구 모음을 나타냅니다.
(나는 관성에 의해 "설정"이라고 말했습니다 - 그것은 또한 표시기 매개변수의 설정 패널로 고통받는 MT5의 저입니다)

2019년 9월 6일부터 빌드 2138.

어떤 장비에서 이런 일이 발생하는지 표시하십시오.

거래, 자동 거래 시스템 및 거래 전략 테스트에 관한 포럼

오류, 버그, 질문

블라디미르 카르푸토프 , 2019.07.31 12:12

다음 데이터를 지정합니다.

"저널" 탭에서 세 줄 복사(세 줄 선택 -> 마우스 오른쪽 버튼 클릭 -> 복사)


메시지를 붙여넣습니다. 다음과 같이 표시되어야 합니다.

 2019.07 . 31 11 : 53 : 10.681 MetaTrader 5 x64 build 2093 started (MetaQuotes Software Corp.)
2019.07 . 31 11 : 53 : 10.685 Windows 10 (build 18362 ) x64, IE 11 , UAC, Intel Core i3- 3120 M  @ 2.50 GHz, Memory: 3188 / 8077 Mb, Disk: 99 / 415 Gb, GMT+ 2
2019.07 . 31 11 : 53 : 10.685 C:\Users\barab\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075

그런 다음 단계적으로 그리고 스크린샷으로 정확히 당신에게 무슨 일이 일어나고 있는지 설명하십시오.
사유: