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

 
Vladimir Pastushak :
계정 유형을 프로그래밍 방식으로 이해하는 방법은 무엇입니까? 헤지 또는 그물?
   if (m_account.MarginMode()!= ACCOUNT_MARGIN_MODE_RETAIL_HEDGING )
     {
       Alert ( "Only Hedging!" );
       return ( INIT_FAILED );
     }
 

아니면 이렇게

계정정보샘플

   m_label_info[ 3 ].Description(m_account.MarginModeDescription());

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\

 //+------------------------------------------------------------------+
//|                                        MarginModeDescription.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link        "https://www.mql5.com"
#property version    "1.00"
#include <Trade\AccountInfo.mqh>
CAccountInfo      m_account;     // account info wrapper
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart ()
  {
//---
   string Pr= m_account.MarginModeDescription();
   Alert (Pr);
  }
//+------------------------------------------------------------------+
 
주어진 매개변수로 가상 지연 그리드를 넣거나 주어진 테이크로 설정한 방향으로 (순서대로) 주문을 여는 어드바이저(스크립트)를 찾도록 도와주세요.
 

오류가 어디에 있는지 알려주십시오.

      for ( int s= OrdersTotal ()- 1 ; s>= 0 ; s--)          
         {
           if (o_orderInfo.SelectByIndex(s)) 
           if (o_orderInfo.OrderType()== ORDER_TYPE_SELL_STOP )
             {                 
               count_sell_stop++;
             }
         }  

       for ( int s1= PositionsTotal ()- 1 ; s1>= 0 ; s1--)          
         {
           if (o_orderInfo.SelectByIndex(s1)) 
           if (o_orderInfo.OrderType()== ORDER_TYPE_SELL )
             {                 
               count_sell++;
             }
         }  
         
       if (count_sell == 0 && count_sell_stop == 0 )
         {
            sellstop_req3.action       = TRADE_ACTION_PENDING ;
            sellstop_req3.symbol       = _Symbol ;
            sellstop_req3.volume       = NormalizeDouble (lot_v, 2 );
            sellstop_req3.price        = SymbolInfoDouble (sellstop_req3.symbol, SYMBOL_ASK ) - 100 * _Point ;
            sellstop_req3.sl           = sellstop_req3.price + 110 * _Point ;
            sellstop_req3.type         = ORDER_TYPE_SELL_STOP ;
            sellstop_req3.type_filling = ORDER_FILLING_RETURN ;
            sellstop_req3.expiration   = ORDER_TIME_GTC ;
            
             OrderSend (sellstop_req3, sellstop_res3);
         }
SELL_STOP - 주문이 계산되지만 SELL은 어떤 식으로든 원하지 않습니다. 알고리즘에 따르면 - 주문이 없으면 SELL_STOP 주문이 이루어지고, 그 중 하나 이상이 있으면 주문이 이루어지지 않습니다.
 
Fergert Фергерт :

오류가 어디에 있는지 알려주십시오.

SELL_STOP - 주문이 계산되지만 SELL은 어떤 식으로든 원하지 않습니다. 알고리즘에 따르면 - 주문이 없으면 SELL_STOP 주문이 이루어지고, 그 중 하나 이상이 있으면 주문이 이루어지지 않습니다.

PENDING ORDERPOSITION 을 혼동하지 마십시오.

 //+------------------------------------------------------------------+
//|                                                     Script 1.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link        "https://www.mql5.com"
#property version    "1.00"
//---
#include <Trade\PositionInfo.mqh>
#include <Trade\OrderInfo.mqh>
//---
CPositionInfo  m_position ;                   // object of CPositionInfo class
COrderInfo     m_order ;                       // object of COrderInfo class
//---
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart ()
  {
   int count_buys          = 0.0 ;
   int count_sells         = 0.0 ;
   int count_buy_limits    = 0.0 ;
   int count_sell_limits   = 0.0 ;
   int count_buy_stops     = 0.0 ;
   int count_sell_stops    = 0.0 ;
//---
   for ( int i= PositionsTotal ()- 1 ; i>= 0 ; i--)
       if ( m_position .SelectByIndex(i)) // selects the position by index for further access to its properties
        {
         if ( m_position .PositionType()== POSITION_TYPE_BUY )
            count_buys++;
         else
             if ( m_position .PositionType()== POSITION_TYPE_SELL )
               count_sells++;
        }
//---
   for ( int i= OrdersTotal ()- 1 ; i>= 0 ; i--) // returns the number of current orders
       if ( m_order .SelectByIndex(i)) // selects the pending order by index for further access to its properties
        {
         if ( m_order .OrderType()== ORDER_TYPE_BUY_LIMIT )
            count_buy_limits++;
         else
             if ( m_order .OrderType()== ORDER_TYPE_SELL_LIMIT )
               count_sell_limits++;
             else
               if ( m_order .OrderType()== ORDER_TYPE_BUY_STOP )
                  count_buy_stops++;
               else
                   if ( m_order .OrderType()== ORDER_TYPE_SELL_STOP )
                     count_sell_stops++;
        }
//--- you code
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
파일:
Script_1.mq5  5 kb
 
Vladimir Karputov :

PENDING ORDERPOSITION 을 혼동하지 마십시오.

감사합니다)) 알았습니다...
 
onCalculate 함수 의 두 번째 버전에서 시작 매개변수가 무엇을 담당하는지 이해하지 못합니다.
onCalculate 함수가 호출될 때마다 0과 같습니다.
인쇄 기능을 통해 시작 값을 출력했습니다.
매뉴얼은 시작이 "의미 있는 데이터가 시작되는 곳"이라고 말합니다. 이것은 나에게 아무 말도하지 않습니다.
 
MisterRight :
onCalculate 함수 의 두 번째 버전에서 시작 매개변수가 무엇을 담당하는지 이해하지 못합니다.
onCalculate 함수가 호출될 때마다 0과 같습니다.
인쇄 기능을 통해 시작 값을 출력했습니다.
매뉴얼은 시작이 "의미 있는 데이터가 시작되는 곳"이라고 말합니다. 이것은 나에게 아무 말도하지 않습니다.

예에서 표시기의 공개 코드를 보십시오.

 
Mikhail Mishanin :

예에서 표시기의 공개 코드를 보십시오.

내가 봤다. 항상 시작 = 0.

여기에서 AMA 표시기에서 코드 조각을 꺼냈습니다.

if(시작!=0)

PlotIndexSetInteger (0,PLOT_DRAW_BEGIN,ExtPeriodAMA+시작);


그리고 이 코드는 begin!=0 조건이 결코 참이 아닐 경우 나에게 무엇을 알려주어야 합니까?

 
기록에서 마감된 주문을 계산하는 데 사용할 방법을 알려주세요. 다음과 같이 시도했습니다.

 HistorySelect ( 0 , TimeCurrent ());

Alert ( "Количество ордеров в истории:  " , HistoryOrdersTotal ());
결국, 그것은 닫힌 명령보다 훨씬 더 많은 말도 안되는 소리를냅니다.
사유: