新人对MQL4和MQL5的任何问题,对算法和代码的帮助和讨论 - 页 1374

 
Andrey Sokolov:

它是一个外汇经纪人还是什么?

它是一个银行。
 
MakarFX:
这就是BANK。

不太清楚,但还行。

他们写道,这在MICEX(FORTS) 上是可用的,Alpari也说他们 竞争账户

也许有 "只有"、"总是 " 的表达。"从来没有"、"没有人,但是 "之类的说法应该更加谨慎。

你能告诉我,在普通的交易账户中,经纪人关闭一个未结头寸,然后重新打开它时?
 
Andrey Sokolov:

不太清楚,但还行。

他们写道,这在MICEX(FORTS) 上是可用的,Alpari也说他们 竞争账户

也许有 "只有"、"总是 " 的表达。"从来没有"、"没有人,但是 "之类的说法应该更加谨慎。

你能告诉我,在普通的交易账户中是否 存在经纪人关闭了未结头寸 又重新开仓的情况?
这是一种个别情况,在乌克兰,法律要求银行在当日(为报告目的)关闭外汇市场的交易。
 
亲爱的专业人士。我们需要一些帮助。例如,我们有一个MACD指标。其结构为iMACD(NULL,0,InpFastEMA,InpSlowEMA,InpSignalSMA,PRICE_CLOSE,MODE_MAIN,0)。我怎样才能改变NULL,以获得不是这个货币对的计算,而是同一货币对图表上的另一个货币对的计算?我把iMACD("USDJPY",0,InpFastEMA,InpSlowEMA,InpSignalSMA,PRICE_CLOSE,MODE_MAIN,0),但它没有给我带来什么。所有的计算结果都是空的。它有什么问题?
 
Michail_David:
亲爱的专业人士。我需要一些帮助。例如,我们有一个MACD指标。其结构为iMACD(NULL,0,InpFastEMA,InpSlowEMA,InpSignalSMA,PRICE_CLOSE,MODE_MAIN,0)。我怎样才能改变NULL,以获得不是这个货币对的计算,而是同一货币对图表上的另一个货币对的计算?我把iMACD("USDJPY",0,InpFastEMA,InpSlowEMA,InpSignalSMA,PRICE_CLOSE,MODE_MAIN,0),但它没有给我带来什么。所有的计算结果都是空的。它有什么问题?

在市场概览中是否有 "USDJPY "符号?

 
Michail_David:
亲爱的专业人士。我需要你的帮助。例如,我们有一个MACD指标。其结构为iMACD(NULL,0,InpFastEMA,InpSlowEMA,InpSignalSMA,PRICE_CLOSE,MODE_MAIN,0)。我怎样才能改变NULL,以获得不是这个货币对的计算,而是同一货币对图表上的另一个货币对的计算?我把iMACD("USDJPY",0,InpFastEMA,InpSlowEMA,InpSignalSMA,PRICE_CLOSE,MODE_MAIN,0),但它没有给我带来什么。所有的计算结果都是空的。它有什么问题?

如果你像这样作弊

GBPJPYH4

//+------------------------------------------------------------------+
//|                                                 ExamplesMACD.mq5 |
//|                   Copyright 2009-2020, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright   "2009-2020, MetaQuotes Software Corp."
#property link        "http://www.mql5.com"
#property description "Moving Average Convergence/Divergence"
#include <MovingAverages.mqh>
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_plots   2
#property indicator_type1   DRAW_HISTOGRAM
#property indicator_type2   DRAW_LINE
#property indicator_color1  Silver
#property indicator_color2  Red
#property indicator_width1  2
#property indicator_width2  1
#property indicator_label1  "Examples MACD"
#property indicator_label2  "Examples Signal"
//--- input parameters
input string             InpPara="USDJPY";            // Para
input int                InpFastEMA=12;               // Fast EMA period
input int                InpSlowEMA=26;               // Slow EMA period
input int                InpSignalSMA=9;              // Signal SMA period
input ENUM_APPLIED_PRICE InpAppliedPrice=PRICE_CLOSE; // Applied price
//--- indicator buffers
double ExtMacdBuffer[];
double ExtSignalBuffer[];
double ExtFastMaBuffer[];
double ExtSlowMaBuffer[];

int    ExtFastMaHandle;
int    ExtSlowMaHandle;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtMacdBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtSignalBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,ExtFastMaBuffer,INDICATOR_CALCULATIONS);
   SetIndexBuffer(3,ExtSlowMaBuffer,INDICATOR_CALCULATIONS);
//--- sets first bar from what index will be drawn
   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,InpSignalSMA-1);
//--- name for indicator subwindow label
   string short_name=StringFormat("ExamplesMACD(%d,%d,%d)",InpFastEMA,InpSlowEMA,InpSignalSMA);
   IndicatorSetString(INDICATOR_SHORTNAME,short_name);
//--- get MA handles
   ExtFastMaHandle=iMA(InpPara,0,InpFastEMA,0,MODE_EMA,InpAppliedPrice);
   ExtSlowMaHandle=iMA(InpPara,0,InpSlowEMA,0,MODE_EMA,InpAppliedPrice);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
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[])
  {
   if(rates_total<InpSignalSMA)
      return(0);
//--- not all data may be calculated
   int calculated=BarsCalculated(ExtFastMaHandle);
   if(calculated<rates_total)
     {
      Print("Not all data of ExtFastMaHandle is calculated (",calculated," bars). Error ",GetLastError());
      return(0);
     }
   calculated=BarsCalculated(ExtSlowMaHandle);
   if(calculated<rates_total)
     {
      Print("Not all data of ExtSlowMaHandle is calculated (",calculated," bars). Error ",GetLastError());
      return(0);
     }
//--- we can copy not all data
   int to_copy;
   if(prev_calculated>rates_total || prev_calculated<0)
      to_copy=rates_total;
   else
     {
      to_copy=rates_total-prev_calculated;
      if(prev_calculated>0)
         to_copy++;
     }
//--- get Fast EMA buffer
   if(IsStopped()) // checking for stop flag
      return(0);
   if(CopyBuffer(ExtFastMaHandle,0,0,to_copy,ExtFastMaBuffer)<=0)
     {
      Print("Getting fast EMA is failed! Error ",GetLastError());
      return(0);
     }
//--- get SlowSMA buffer
   if(IsStopped()) // checking for stop flag
      return(0);
   if(CopyBuffer(ExtSlowMaHandle,0,0,to_copy,ExtSlowMaBuffer)<=0)
     {
      Print("Getting slow SMA is failed! Error ",GetLastError());
      return(0);
     }
//---
   int start;
   if(prev_calculated==0)
      start=0;
   else
      start=prev_calculated-1;
//--- calculate MACD
   for(int i=start; i<rates_total && !IsStopped(); i++)
      ExtMacdBuffer[i]=ExtFastMaBuffer[i]-ExtSlowMaBuffer[i];
//--- calculate Signal
   SimpleMAOnBuffer(rates_total,prev_calculated,0,InpSignalSMA,ExtMacdBuffer,ExtSignalBuffer);
//--- OnCalculate done. Return new prev_calculated.
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Alexey Viktorov:

符号 "USDJPY "是否出现在市场概览中?

是的,就是这样,维克多。

 
SanAlex:

而如果你这样作弊。

亚历克斯,这行不通。该指标应该是为两个货币对同时绘制两个MACD。然而,有了这段代码,就不可能变得臃肿。我还想增加相关性的计算。但是,感谢你对如何指定货币对的提示。

 

如果我理解正确的话,货币对在任何指标中都应指定为 "EURUSD"。在这方面,我的问题是


void OnInit()

  {
input string Currency = "JPY"; //Выбор валютной пары
input string Major_pair = "USD"; // Выбор валюты для корреляции
input bool Direct_correlation = true; // Выбор прямой и обратной корреляции
string Major_currpair = Symbol();
string two_pair;
//--------------------------------------------------------------------
int position =StringFind(Major_currpair,Major_pair,0);
   if(position == -1)
      Print("Не верно указана валюта корреляции");
   if(Direct_correlation == true)
      two_pair =StringConcatenate(Currency,Major_pair);
   else
      two_pair =StringConcatenate(Major_pair,Currency);
   Print("Two_pair = ", two_pair);
   Print("Major_currpair = ",Major_currpair);
}

如何在字符串中插入符号"?因为该货币对在日记中被打印为USDJPY,而不是 "USDJPY"。

 
Michail_David:

我怎样才能在行中插入""符号?因为杂志上的货币对被印成USDJPY,而不是 "USDJPY"。

https://www.mql5.com/ru/docs/basis/types/stringconst

https://www.mql5.com/ru/docs/basis/types/integer/symbolconstants

原因: