新人对MQL4和MQL5的任何问题,对算法和代码的帮助和讨论 - 页 883 1...876877878879880881882883884885886887888889890...1953 新评论 Konstantin Seredkin 2019.06.10 14:26 #8821 Alexey Viktorov:在mql5中也是如此。它甚至还略有延伸。这不正是我们所需要的吗? 符号_交易_刻度线_值 SYMBOL_TRADE_TICK_VALUE_PROFIT值 双 符号_交易_点值_利润 计算出的获利头寸的tick值 双 符号_交易_点值_损失 亏损头寸的计算值为一个刻度 双 符号_交易_刻度线大小 最低价格变化 双 该死的,我太笨了,我把TICK_SIZE 而不是TICK_VALUE放进去了......我应该去睡觉 了。 Павел Псардиев 2019.06.10 14:46 #8822 伙计们,这里有什么问题,帮帮我吧!? Sergey Voytsekhovsky 2019.06.10 19:56 #8823 Alexey Viktorov: 吸引我注意的第一件事是缓冲器的顺序。 构建缓冲区必须始终按顺序运行。也就是说,如果数据缓冲区是2号和3号,那么颜色缓冲区 就必须是4号。 如果这不是唯一的错误,我们将进一步调查。好的,在说明中确实找到了这样一个功能,在这里。 MQL5参考指南 / 自定义指标 / SetIndexBuffer".....boolSetIndexBuffer( 䵮䵮index,// 缓冲区的索引doublebuffer[],// arrayENUM_INDEXBUFFER_TYPEdata_type//将被存储的内容);参数指数[in] 指示器缓冲区编号。编号从0开始。这个数字必须小于#property indicator_buffers 中声明的值。缓冲区[] [in] 在自定义指标程序中声明的数组。数据类型 [in] 存储在指标阵列中的数据类型。默认为INDICATOR_DATA(计算指标的值)。也可以取INDICATOR_COLOR_INDEX 值,那么这个缓冲区是用来存储前一个指标缓冲区的颜色索引 的。在#property indicator_colorN 行中最多可以指定64种颜色。值INDICATOR_CALCULATIONS 意味着该缓冲区参与指标的中间计算,它不用于绘制。 Any questions from newcomers 自定义指标 - SetIndexBuffer 如何利用 MQL5 创建自定义指标(Heiken Ashi) Sergey Voytsekhovsky 2019.06.10 20:02 #8824 我试图重做,结果得到了更多的废话。直方图完全消失了,线条指示器 也变得很奇怪,至少可以这么说。信号部分在50以上就被切断了,主要部分则更低。代码中没有这样的截止点。 Sergey Voytsekhovsky 2019.06.10 20:11 #8825 Artyom Trishkin:我给了你一个链接,不是研究直方图,而是研究如何使用颜色缓冲器。从直方图中抽离出来,专注于你需要如何处理颜色。我研究了一下,但没有什么新东西,显然它是(对我来说是新的),当然,对所有入门者来说是显而易见的,不言而喻。我找不到任何新的东西,除了上面描述的在索引过程中相互安排缓冲区的特点。这一连串的尊重,得到了更多的cheesier图片。 图片如下,文件附后 //+------------------------------------------------------------------+ //| Stoch_HISTOGRAM_MQL5_4.mq5 | //| Copyright 2009-2017, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "2009-2017, MetaQuotes Software Corp." #property link "http://www.mql5.com" //--- indicator settings #property indicator_separate_window #property indicator_buffers 8 #property indicator_plots 3 #property indicator_type1 DRAW_COLOR_HISTOGRAM2 #property indicator_color1 clrGreen,clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 1 #property indicator_type1 DRAW_LINE // основная #property indicator_color1 clrLightSeaGreen #property indicator_style1 STYLE_SOLID #property indicator_width2 3 #property indicator_type2 DRAW_LINE // сигнальная #property indicator_color2 clrYellow #property indicator_style2 STYLE_SOLID #property indicator_width3 2 //--- input parameters input int InpKPeriod=5; // K period input int InpDPeriod=3; // D period input int InpSlowing=3; // Slowing //--- indicator buffers double ColorHistogram_2Buffer1[]; double ColorHistogram_2Buffer2[]; double ColorHistogram_2Colors[]; double ExtMainBuffer[]; double ExtSignalBuffer[]; double ExtHighesBuffer[]; double ExtLowesBuffer[]; color colors[]={clrRed,clrGreen}; int cl; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,ColorHistogram_2Buffer1,INDICATOR_DATA); SetIndexBuffer(1,ColorHistogram_2Buffer2,INDICATOR_DATA); SetIndexBuffer(2,ColorHistogram_2Colors,INDICATOR_COLOR_INDEX); SetIndexBuffer(3,ExtMainBuffer,INDICATOR_DATA); SetIndexBuffer(4,ExtSignalBuffer,INDICATOR_DATA); SetIndexBuffer(5,ExtHighesBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(6,ExtLowesBuffer,INDICATOR_CALCULATIONS); //ArraySetAsSeries(ExtMainBuffer,true); //ArraySetAsSeries(ExtSignalBuffer,true); //ArraySetAsSeries(ExtHighesBuffer,true); //ArraySetAsSeries(ExtLowesBuffer,true); //ArraySetAsSeries(ColorHistogram_2Buffer1,true); //ArraySetAsSeries(ColorHistogram_2Buffer2,true); //ArraySetAsSeries(ColorHistogram_2Colors,true); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0); //--- set accuracy IndicatorSetInteger(INDICATOR_DIGITS,2); //--- set levels IndicatorSetInteger(INDICATOR_LEVELS,3); IndicatorSetDouble(INDICATOR_LEVELVALUE,0,20); IndicatorSetDouble(INDICATOR_LEVELVALUE,1,50); IndicatorSetDouble(INDICATOR_LEVELVALUE,2,80); //--- set maximum and minimum for subwindow IndicatorSetDouble(INDICATOR_MINIMUM,0); IndicatorSetDouble(INDICATOR_MAXIMUM,100); //--- name for DataWindow and indicator subwindow label IndicatorSetString(INDICATOR_SHORTNAME,"Stoch_HISTOGRAM("+(string)InpKPeriod+","+(string)InpDPeriod+","+(string)InpSlowing+")"); PlotIndexSetString(3,PLOT_LABEL,"Main"); PlotIndexSetString(4,PLOT_LABEL,"Signal"); //PlotIndexSetString(2,PLOT_LABEL,"UP"); //PlotIndexSetString(3,PLOT_LABEL,"LOW"); //--- sets first bar from what index will be drawn PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,InpKPeriod+InpSlowing-2); PlotIndexSetInteger(4,PLOT_DRAW_BEGIN,InpKPeriod+InpDPeriod); PlotIndexSetInteger(5,PLOT_DRAW_BEGIN,InpKPeriod+InpSlowing-2); PlotIndexSetInteger(6,PLOT_DRAW_BEGIN,InpKPeriod+InpSlowing-2); //--- initialization done } //+------------------------------------------------------------------+ //| Stochastic Oscillator | //+------------------------------------------------------------------+ 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[]) { int i,k,start; //--- check for bars count if(rates_total<=InpKPeriod+InpDPeriod+InpSlowing) return(0); //--- start=InpKPeriod-1; if(start+1<prev_calculated) start=prev_calculated-2; else { for(i=0;i<start;i++) { ExtLowesBuffer[i]=0.0; ExtHighesBuffer[i]=0.0; } } //--- calculate HighesBuffer[] and ExtHighesBuffer[] for(i=start;i<rates_total && !IsStopped();i++) { double dmin=1000000.0; double dmax=-1000000.0; for(k=i-InpKPeriod+1;k<=i;k++) { if(dmin>low[k]) dmin=low[k]; if(dmax<high[k]) dmax=high[k]; } ExtLowesBuffer[i]=dmin; ExtHighesBuffer[i]=dmax; } //--- %K start=InpKPeriod-1+InpSlowing-1; if(start+1<prev_calculated) start=prev_calculated-2; else { for(i=0;i<start;i++) ExtMainBuffer[i]=0.0; } //--- main cycle for(i=start;i<rates_total && !IsStopped();i++) { double sumlow=0.0; double sumhigh=0.0; for(k=(i-InpSlowing+1);k<=i;k++) { sumlow +=(close[k]-ExtLowesBuffer[k]); sumhigh+=(ExtHighesBuffer[k]-ExtLowesBuffer[k]); } if(sumhigh==0.0) ExtMainBuffer[i]=100.0; else ExtMainBuffer[i]=sumlow/sumhigh*100; if(ExtMainBuffer[i]>50){ cl=1; ColorHistogram_2Buffer1[i]=50; ColorHistogram_2Buffer2[i]=ExtMainBuffer[i]; ColorHistogram_2Colors[i]=colors[cl]; Print("ExtMainBuffer[i]=",ExtMainBuffer[i], " cl=",cl, " ColorHistogram_2Buffer1[i]=",ColorHistogram_2Buffer1[i], " ColorHistogram_2Buffer2[i]=",ColorHistogram_2Buffer2[i], " ColorHistogram_2Colors[i]=",ColorHistogram_2Colors[i]); } if(ExtMainBuffer[i]<50){ cl=0; ColorHistogram_2Buffer1[i]=ExtMainBuffer[i]; ColorHistogram_2Buffer2[i]=50; ColorHistogram_2Colors[i]=colors[cl]; Print("ExtMainBuffer[i]=",ExtMainBuffer[i], " cl=",cl, " ColorHistogram_2Buffer1[i]=",ColorHistogram_2Buffer1[i], " ColorHistogram_2Buffer2[i]=",ColorHistogram_2Buffer2[i], " ColorHistogram_2Colors[i]=",ColorHistogram_2Colors[i]); } } //--- signal start=InpDPeriod-1; if(start+1<prev_calculated) start=prev_calculated-2; else { for(i=0;i<start;i++) ExtSignalBuffer[i]=0.0; } for(i=start;i<rates_total && !IsStopped();i++) { double sum=0.0; for(k=0;k<InpDPeriod;k++) sum+=ExtMainBuffer[i-k]; ExtSignalBuffer[i]=sum/InpDPeriod; } //--- OnCalculate done. Return new prev_calculated. return(rates_total); } //+------------------------------------------------------------------+ 附加的文件: Stoch_HISTOGRAM_MQL5_5.mq5 15 kb klok79 2019.06.10 20:58 #8826 你好。你能告诉我在哪里可以找到 "可靠 "的开单算法吗(到目前为止,我只对市场订单感兴趣),因为我被难住了。问题是,在我的账户(Alpari)中,StopLevel和FreezeLevel水平为零,如果我只使用这些https://book.mql4.com/ru/appendix/limits 限制,这意味着买入时的StopLoss可以设置在Bid水平,卖出时可以设置在Ask水平,但事实并非如此。在这种情况下,OrderSend返回一个 "无价格 "的错误(ERR_OFF_QUOTES,代码136)。同时,没有止损的交易或止损50点以上的交易都能顺利打开。我通过经验发现,最小的SlopLoss是19点。我不知道如何以编程方式确定这个幅度。 Alexandr Sokolov 2019.06.10 21:13 #8827 这些水平应该从订单的收盘价开始设置,而不是从开盘价 开始。而设置这些水平时的收盘价必须不等于设置的值 Sergey Voytsekhovsky 2019.06.10 21:34 #8828 klok79:你好。你能告诉我在哪里可以找到 "可靠 "的开单算法吗(到目前为止,我只对市场订单感兴趣),因为我被难住了。问题是,在我的账户(Alpari)中,StopLevel和FreezeLevel水平为零,如果我只使用这些https://book.mql4.com/ru/appendix/limits 限制,这意味着买入时的StopLoss可以设置在Bid水平,卖出时可以设置在Ask水平,但事实并非如此。在这种情况下,OrderSend返回一个 "无价格 "的错误(ERR_OFF_QUOTES,代码136)。同时,没有止损的交易或止损50点以上的交易都能顺利打开。我通过经验发现,最小的SlopLoss是19点。我不知道如何以编程方式确定这个幅度。尝试minStopLoss=当前价格+/-(MaxValue(2*Spread, StopLoss))。 leonerd 2019.06.11 02:02 #8829 为什么在停止调试时对象没有被销毁?我知道OnDeinit()根本就没有被调用。调试停止后,我每次都要杀死终端。 Vladimir Kutenkov 2019.06.11 03:38 #8830 下午好,下面的代码问题是经常更新数组adx_sig[9]。我想及时获得数据更新的依赖性。但有些事情出了差错。 //+------------------------------------------------------------------+ //| 123.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" //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ input int ADX_adx_period = 14; // adx period ADX input int ADX_lower_level = 20; // Lower level ADX int h_adx[9]; double adx1_buffer[3]; double adx2_buffer[3]; double adx3_buffer[3]; ENUM_TIMEFRAMES handle_period[9]={PERIOD_CURRENT,PERIOD_M1,PERIOD_M5,PERIOD_M15,PERIOD_M30,PERIOD_H1,PERIOD_H4,PERIOD_D1,PERIOD_W1}; int adx_sig[9]; int OnInit() { //--- for(int i=0; i<ArraySize(handle_period); i++) { //--- Установим хэндлы для индикаторов h_adx[i]=iADX(_Symbol,handle_period[i],ADX_adx_period); if(h_adx[i]<0) { Alert("Ошибка при создании индикаторов - : ",GetLastError(),"!!"); } } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- for(int i=0; i<ArraySize(handle_period); i++) { //--- Удаляем хэндлы для индикаторов IndicatorRelease(h_adx[i]); } //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- for(int i_sig=0; i_sig<ArraySize(handle_period); i_sig++) { if(CopyBuffer(h_adx[i_sig],0,0,3,adx1_buffer)<3)Print("CopyBuffer adx1_buffer ",GetLastError()); if(CopyBuffer(h_adx[i_sig],1,0,3,adx2_buffer)<3)Print("CopyBuffer adx2_buffer ",GetLastError()); if(CopyBuffer(h_adx[i_sig],2,0,3,adx3_buffer)<3)Print("CopyBuffer adx3_buffer ",GetLastError()); if(adx3_buffer[1]<adx2_buffer[1] && adx3_buffer[1]>=ADX_lower_level && adx3_buffer[1]>adx3_buffer[2])adx_sig[i_sig]=1; else if(adx3_buffer[1]>adx2_buffer[1] && adx3_buffer[1]>=ADX_lower_level && adx3_buffer[1]<adx3_buffer[2])adx_sig[i_sig]=-1; else adx_sig[i_sig]=0; } PrintFormat("ADX sig0=%i sig1=%i sig2=%i sig3=%i sig4=%i sig5=%i sig6=%i sig7=%i sig8=%i",adx_sig[0],adx_sig[1],adx_sig[2],adx_sig[3],adx_sig[4],adx_sig[5],adx_sig[6],adx_sig[7],adx_sig[8]); } 1...876877878879880881882883884885886887888889890...1953 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
在mql5中也是如此。它甚至还略有延伸。这不正是我们所需要的吗?
符号_交易_刻度线_值
SYMBOL_TRADE_TICK_VALUE_PROFIT值
双
符号_交易_点值_利润
计算出的获利头寸的tick值
双
符号_交易_点值_损失
亏损头寸的计算值为一个刻度
双
符号_交易_刻度线大小
最低价格变化
双
吸引我注意的第一件事是缓冲器的顺序。
构建缓冲区必须始终按顺序运行。也就是说,如果数据缓冲区是2号和3号,那么颜色缓冲区 就必须是4号。
如果这不是唯一的错误,我们将进一步调查。
好的,在说明中确实找到了这样一个功能,在这里。
".....
boolSetIndexBuffer(
䵮䵮index,// 缓冲区的索引
doublebuffer[],// array
ENUM_INDEXBUFFER_TYPEdata_type//将被存储的内容
);
参数
指数
[in] 指示器缓冲区编号。编号从0开始。这个数字必须小于#property indicator_buffers 中声明的值。
缓冲区[]
[in] 在自定义指标程序中声明的数组。
数据类型
[in] 存储在指标阵列中的数据类型。默认为INDICATOR_DATA(计算指标的值)。也可以取INDICATOR_COLOR_INDEX 值,那么这个缓冲区是用来存储前一个指标缓冲区的颜色索引 的。在#property indicator_colorN 行中最多可以指定64种颜色。值INDICATOR_CALCULATIONS 意味着该缓冲区参与指标的中间计算,它不用于绘制。
我试图重做,结果得到了更多的废话。直方图完全消失了,线条指示器 也变得很奇怪,至少可以这么说。信号部分在50以上就被切断了,主要部分则更低。代码中没有这样的截止点。
我给了你一个链接,不是研究直方图,而是研究如何使用颜色缓冲器。从直方图中抽离出来,专注于你需要如何处理颜色。
我研究了一下,但没有什么新东西,显然它是(对我来说是新的),当然,对所有入门者来说是显而易见的,不言而喻。我找不到任何新的东西,除了上面描述的在索引过程中相互安排缓冲区的特点。这一连串的尊重,得到了更多的cheesier图片。
图片如下,文件附后
你好。
你能告诉我在哪里可以找到 "可靠 "的开单算法吗(到目前为止,我只对市场订单感兴趣),因为我被难住了。
问题是,在我的账户(Alpari)中,StopLevel和FreezeLevel水平为零,如果我只使用这些https://book.mql4.com/ru/appendix/limits 限制,这意味着买入时的StopLoss可以设置在Bid水平,卖出时可以设置在Ask水平,但事实并非如此。在这种情况下,OrderSend返回一个 "无价格 "的错误(ERR_OFF_QUOTES,代码136)。
同时,没有止损的交易或止损50点以上的交易都能顺利打开。
我通过经验发现,最小的SlopLoss是19点。我不知道如何以编程方式确定这个幅度。
你好。
你能告诉我在哪里可以找到 "可靠 "的开单算法吗(到目前为止,我只对市场订单感兴趣),因为我被难住了。
问题是,在我的账户(Alpari)中,StopLevel和FreezeLevel水平为零,如果我只使用这些https://book.mql4.com/ru/appendix/limits 限制,这意味着买入时的StopLoss可以设置在Bid水平,卖出时可以设置在Ask水平,但事实并非如此。在这种情况下,OrderSend返回一个 "无价格 "的错误(ERR_OFF_QUOTES,代码136)。
同时,没有止损的交易或止损50点以上的交易都能顺利打开。
我通过经验发现,最小的SlopLoss是19点。我不知道如何以编程方式确定这个幅度。
尝试minStopLoss=当前价格+/-(MaxValue(2*Spread, StopLoss))。
下午好,下面的代码问题是经常更新数组adx_sig[9]。我想及时获得数据更新的依赖性。但有些事情出了差错。