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

 
klycko DEAL_ENTRY_OUT 수정자를 사용해야 할 것 같습니다.
하지만 어떻게 사용하는지 알 수 없습니다.

제발 도와주세요.

진심으로, 알렉산더


올바른 방향으로 가고 있습니다. 하지만 충분히 세심하지 않습니다.


 
klycko DEAL_ENTRY_OUT 수정자를 사용해야 할 것 같습니다.
하지만 어떻게 사용하는지 알 수 없습니다.
void  OnTradeTransaction(
   const MqlTradeTransaction&    trans,   // структура торговой транзакции
   const MqlTradeRequest&        request, // структура запроса
   const MqlTradeResult&         result   // структура ответа
)
  {
   if(trans.type==TRADE_TRANSACTION_DEAL_ADD)
     {
      if(HistoryDealSelect(trans.deal) && HistoryDealGetInteger(trans.deal,DEAL_ENTRY)==DEAL_ENTRY_OUT)
        {

           //---

        }

안부, 블라디미르.

 
Alexey Viktorov #:

올바른 방향으로 가고 있습니다. 하지만 충분히 세심하지 못함

안녕하세요 Alexei, 프로그래밍 언어를 배우는 초보자를 지원하고 저희 같은 사람들을 지치지 않게 해주셔서 감사합니다. 정말 감사합니다!

초보자의 주요 문제는 무엇입니까? 저 자신에 대해서만 말씀드리겠습니다. 예, 실제로 MQL5 프로그래밍 언어가 제공하는 다양한 가능성을 적용하는 방법을 항상 이해하지 못합니다. 기본 교육이나 최상위 언어로 프로그래밍하는 연습 없이는이 주제에 들어가기가 매우 어렵습니다. 여러분과 같은 포럼 회원들만이 저를 도와줍니다. 많은 사람들이 갑자기 포럼에 등장한 초보자에게 끊임없이 질문을 던지는 것에 지쳐 있고 때로는 시간이나 인내심이 부족하다는 것을 알고 있습니다.

우리의 딜레마적인 질문에 응답 해 주신 모든 분들께 다시 한 번 감사의 말씀을 드리며 신이 모든 건강, 장수, 행운과 번영을 기원합니다!!!!

안부, 블라디미르.

 

안녕하세요.
마지막 막대가 닫힐 때 빨간색에 매도 신호를, 녹색에 매수 신호를 주도록 액셀러레이터 오실레이터 인디케이터를 추가하는 방법을 알려주세요.

고마워요

 
makssub 액셀러레이터 오실레이터 인디케이터를 조이는 방법을 알려주세요.

고마워요

인디케이터를 Expert Advisor에 연결하고 CopyBuffer() 를 통해 데이터를 가져옵니다. 색상 버퍼의 인덱스는 1이며 0은 녹색, 1은 빨간색입니다.
Документация по MQL5: Технические индикаторы / iAC
Документация по MQL5: Технические индикаторы / iAC
  • www.mql5.com
iAC - Технические индикаторы - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Artyom Trishkin #:
인디케이터를 Expert Advisor에 연결하고 CopyBuffer() 를 통해 데이터를 가져옵니다. 색상 버퍼의 인덱스는 1이며, 값 0은 녹색, 1은 빨간색입니다.

괜찮으시다면 예를 들어 설명해 주시겠어요?

MQL5는 MQL4 다음으로 어렵습니다.

 
makssub #:

큰 문제가 되지 않는다면요. 예를 들어 주시겠어요?

MQL4에 이어 MQL5도 저에게는 어렵습니다.

예제는 위의 게시물에 있는 링크에 있습니다.
 

안녕하세요.

코드베이스에 ADX 표시기가 있습니다. 여기에는 다음 코드가 포함되어 있습니다.

//--- set draw begin
   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ExtADXPeriod<<1);
   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,ExtADXPeriod);
   PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,ExtADXPeriod);

만약

ExtADXPeriod=14

이면 ExtADXPeriod<<1이 값 9와 같다는 것을 알 수 있습니다.

그렇다면 왜 이런 항목이 필요할까요? 비트 시프트 없이 작성할 수 없나요?

ExtADXPeriod<<1

아래 전체 표시기 코드


//+------------------------------------------------------------------+
//|                                                          ADX.mq5 |
//|                             Copyright 2000-2023, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright   "Copyright 2000-2023, MetaQuotes Ltd."
#property link        "https://www.mql5.com"
#property description "Average Directional Movement Index"
#include <MovingAverages.mqh>

#property indicator_separate_window
#property indicator_buffers 6
#property indicator_plots   3
#property indicator_type1   DRAW_LINE
#property indicator_color1  LightSeaGreen
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
#property indicator_type2   DRAW_LINE
#property indicator_color2  YellowGreen
#property indicator_style2  STYLE_DOT
#property indicator_width2  1
#property indicator_type3   DRAW_LINE
#property indicator_color3  Wheat
#property indicator_style3  STYLE_DOT
#property indicator_width3  1
#property indicator_label1  "ADX"
#property indicator_label2  "+DI"
#property indicator_label3  "-DI"
//--- input parameters
input int InpPeriodADX=14; // Period ADX
//--- indicator buffers
double    ExtADXBuffer[];
double    ExtPDIBuffer[];
double    ExtNDIBuffer[];
double    ExtPDBuffer[];
double    ExtNDBuffer[];
double    ExtTmpBuffer[];

int       ExtADXPeriod;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- check for input parameters
   if(InpPeriodADX>=100 || InpPeriodADX<=0)
     {
      ExtADXPeriod=14;
      PrintFormat("Incorrect value for input variable Period_ADX=%d. Indicator will use value=%d for calculations.",InpPeriodADX,ExtADXPeriod);
     }
   else
      ExtADXPeriod=InpPeriodADX;
//--- indicator buffers
   SetIndexBuffer(0,ExtADXBuffer);
   SetIndexBuffer(1,ExtPDIBuffer);
   SetIndexBuffer(2,ExtNDIBuffer);
   SetIndexBuffer(3,ExtPDBuffer,INDICATOR_CALCULATIONS);
   SetIndexBuffer(4,ExtNDBuffer,INDICATOR_CALCULATIONS);
   SetIndexBuffer(5,ExtTmpBuffer,INDICATOR_CALCULATIONS);
//--- indicator digits
   IndicatorSetInteger(INDICATOR_DIGITS,2);
//--- set draw begin
   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ExtADXPeriod<<1);
   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,ExtADXPeriod);
   PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,ExtADXPeriod);
//--- indicator short name
   string short_name="ADX("+string(ExtADXPeriod)+")";
   IndicatorSetString(INDICATOR_SHORTNAME,short_name);
   PlotIndexSetString(0,PLOT_LABEL,short_name);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//--- checking for bars count
   if(rates_total<ExtADXPeriod)
      return(0);
//--- detect start position
   int start;
   if(prev_calculated>1)
      start=prev_calculated-1;
   else
     {
      start=1;
      ExtPDIBuffer[0]=0.0;
      ExtNDIBuffer[0]=0.0;
      ExtADXBuffer[0]=0.0;
     }
//--- main cycle
   for(int i=start; i<rates_total && !IsStopped(); i++)
     {
      //--- get some data
      double high_price=high[i];
      double prev_high =high[i-1];
      double low_price =low[i];
      double prev_low  =low[i-1];
      double prev_close=close[i-1];
      //--- fill main positive and main negative buffers
      double tmp_pos=high_price-prev_high;
      double tmp_neg=prev_low-low_price;
      if(tmp_pos<0.0)
         tmp_pos=0.0;
      if(tmp_neg<0.0)
         tmp_neg=0.0;
      if(tmp_pos>tmp_neg)
         tmp_neg=0.0;
      else
        {
         if(tmp_pos<tmp_neg)
            tmp_pos=0.0;
         else
           {
            tmp_pos=0.0;
            tmp_neg=0.0;
           }
        }
      //--- define TR
      double tr=MathMax(MathMax(MathAbs(high_price-low_price),MathAbs(high_price-prev_close)),MathAbs(low_price-prev_close));
      if(tr!=0.0)
        {
         ExtPDBuffer[i]=100.0*tmp_pos/tr;
         ExtNDBuffer[i]=100.0*tmp_neg/tr;
        }
      else
        {
         ExtPDBuffer[i]=0.0;
         ExtNDBuffer[i]=0.0;
        }
      //--- fill smoothed positive and negative buffers
      ExtPDIBuffer[i]=ExponentialMA(i,ExtADXPeriod,ExtPDIBuffer[i-1],ExtPDBuffer);
      ExtNDIBuffer[i]=ExponentialMA(i,ExtADXPeriod,ExtNDIBuffer[i-1],ExtNDBuffer);
      //--- fill ADXTmp buffer
      double tmp=ExtPDIBuffer[i]+ExtNDIBuffer[i];
      if(tmp!=0.0)
         tmp=100.0*MathAbs((ExtPDIBuffer[i]-ExtNDIBuffer[i])/tmp);
      else
         tmp=0.0;
      ExtTmpBuffer[i]=tmp;
      //--- fill smoothed ADX buffer
      ExtADXBuffer[i]=ExponentialMA(i,ExtADXPeriod,ExtADXBuffer[i-1],ExtTmpBuffer);
     }
//--- OnCalculate done. Return new prev_calculated.
   return(rates_total);
  }
//+------------------------------------------------------------------+
Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2023.11.30
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 
Novichokkk #:

만약

ExtADXPeriod=14

인 경우ExtADXPeriod<<1은 값 9와 같습니다.

은 28과 같습니다(14<<1은 자릿수가 충분하다면 14*2와 같습니다).

어쨌든 컴파일러는 컴파일 시 const 표현식을 계산하므로 코드에 포함되지 않으니 신경 쓰지 마세요. 오직 그 결과만

는 조기 최적화이거나 작성자가 자신이 멋지다는 것을 보여주고 싶었을 수 있습니다.

 
Maxim Kuznetsov #:

은 28과 같습니다(14<<1은 14*2와 같습니다. 자릿수가 충분하다면).

컴파일러는 컴파일 시 알려진 const 표현식을 계산하고 코드에 포함되지 않으므로 신경 쓰지 마세요. 오직 그 결과만

는 조기 최적화이거나 작성자가 자신이 멋지다는 것을 보여주고 싶었을 수 있습니다.

1-왜 28일까요?

14는 2진수입니다. 1110입니다.

한 비트를 왼쪽으로 이동하면 0111이 되고, 다시 10진수로 변환하면 9가 됩니다. 1*1+1+1*2+1*4=7(9가 아닌 틀림)입니다.


2-이 경우에도 구체적인 예를 원합니다. 이러한 구조에ExtADXPeriod<<1 대신에 삽입하는 것이 더 올바른 것은 무엇입니까?

사유: