[存档]任何菜鸟问题,为了不使论坛变得杂乱无章。专业人士,不要与它擦肩而过。没有你,哪里都不能去 - 5. - 页 279 1...272273274275276277278279280281282283284285286...432 新评论 Viktar Dzemikhau 2013.04.11 10:24 #2781 我的函数在返回同一个数组的元素的值时出了问题。我将按顺序描述关于这个问题的一切。全局变量 是。extern int i_TF = 0; int g_maPeriod[3] = {6, 25, 150, 250}, // Периоды обрабатываемых МА g_singMa[3] = {1,2,3,4}; // признаки машек, добавляемые к основному мэйджику // Идентификаторы сигналов #define SIGNAL_BUY 0 // Сигнал на покупку #define SIGNAL_SELL 1 // Сигнал на продажу #define SIGNAL_NO -1 // Сигнала нет #define CROSS_UP 0 // Признак нахождения быстрой средней // ..над медленной #define CROSS_DN 1 // Признак нахождения медленной.. // ..средней над быстрой #define CROSS_NO -1 // Признак равенства двух среднихint crossDir[3];本计算中使用的函数。//+-------------------------------------------------------------------------------------+ //| Получение значений МА на двух соседних барах | //+-------------------------------------------------------------------------------------+ double GetCurAndPrevMA(int maPeriod, double& prevMA) { prevMA = iMA(NULL, i_TF, maPeriod, 0, MODE_EMA, MODE_CLOSE, 1); return (iMA(NULL, i_TF, maPeriod, 0, MODE_EMA, MODE_CLOSE, 0)); } //+-------------------------------------------------------------------------------------+ //| Получение положения машек между собой | //+-------------------------------------------------------------------------------------+ void GetStateMa(int& crossDir[]) { double ema365_1; double ema365_0 = GetCurAndPrevMA(365, ema365_1); Print("g_maPeriod[0] = ", g_maPeriod[0]); Print("g_maPeriod[1] = ", g_maPeriod[1]); Print("g_maPeriod[2] = ", g_maPeriod[2]); Print("g_maPeriod[3] = ", g_maPeriod[3]); for (int i=0; i<4; i++) { double ema1; double ema0 = GetCurAndPrevMA(g_maPeriod[i], ema1); crossDir[i] = CROSS_NO; Print("ema1 < 365_1 ", ema1 ," < ", ema365_1); if (ema1 < ema365_1 && ema0 > ema365_0) { Print("ema1 < 365_1 ", ema1 ," < ", ema365_1); crossDir[i] = CROSS_UP; } if (ema1 > ema365_1 && ema0 < ema365_0) { Print("ema1 > 365_1 ", ema1 ," > ", ema365_1); crossDir[i] = CROSS_DN; } } }我另外还打印了GetStateMa(int& crossDir[]) 函数返回的数组项的值。 Print("crossDir[0] = ", crossDir[0]); Print("crossDir[1] = ", crossDir[1]); Print("crossDir[2] = ", crossDir[2]); Print("crossDir[3] = ", crossDir[3]);这就是返回的内容。2013.04.11 15:08:48 2009.01.25 23:46 Base150_New EURUSD,H1: crossDir[3] = 0 2013.04.11 15:08:48 2009.01.25 23:46 Base150_New EURUSD,H1: crossDir[2] = -1 2013.04.11 15:08:48 2009.01.25 23:46 Base150_New EURUSD,H1: crossDir[1] = -1 2013.04.11 15:08:48 2009.01.25 23:46 Base150_New EURUSD,H1: crossDir[0] = -1 2013.04.11 15:08:48 2009.01.25 23:46 Base150_New EURUSD,H1: open #1 buy 0.10 EURUSD at 1.29654 ok 2013.04.11 15:08:48 2009.01.25 23:46 Base150_New EURUSD,H1: ema1 < 365_1 1.3129 < 1.3225 2013.04.11 15:08:48 2009.01.25 23:46 Base150_New EURUSD,H1: ema1 < 365_1 1.3017 < 1.3225 2013.04.11 15:08:48 2009.01.25 23:46 Base150_New EURUSD,H1: ema1 < 365_1 1.2886 < 1.3225 2013.04.11 15:08:48 2009.01.25 23:46 Base150_New EURUSD,H1: ema1 < 365_1 1.2916 < 1.3225 2013.04.11 15:08:48 2009.01.25 23:46 Base150_New EURUSD,H1: g_maPeriod[3] = 250 2013.04.11 15:08:48 2009.01.25 23:46 Base150_New EURUSD,H1: g_maPeriod[2] = 150 2013.04.11 15:08:48 2009.01.25 23:46 Base150_New EURUSD,H1: g_maPeriod[1] = 25 2013.04.11 15:08:48 2009.01.25 23:46 Base150_New EURUSD,H1: g_maPeriod[0] = 6 返回的数组元素crossDir[] 的值是不同的,尽管它们的值都应该是1。这可以从比较马赫4期和365期的表达式的未设置中看出。你能告诉我为什么返回的值不正确吗? Boris 2013.04.11 10:55 #2782 Ekburg: 谢谢你的具体说明,因为发给我的链接没有具体提到这些数组,而且我没有注意左边那一栏,因为我在工作。但没有人会吞下你吐出的一切,只有你自己;) 如果有的话,你是如何从暗示中学习的?只有积极的、充满好奇心的自学才会有成果!我把你嚼碎了,你却在 "回吐 "合理的建议!找个保姆来收拾你的烂摊子吧! [删除] 2013.04.11 12:53 #2783 大家晚上好,我从指标A 建立了指标B(通过iCustom) 。两个指标 都在图表上。当我改变指标A 的参数时,指标B 不会自动重建,需要强行重新编译。 为什么指标B 不会自动重建? 请告知我的错误是什么? TarasBY 2013.04.11 13:04 #2784 MK07: 大家晚上好,我从指标A 建立了指标B(通过iCustom) 。 两个指标都在图表上。 当我改变指标A的 参数时,指标B 不会自动重建,我需要强行重新编译。 为什么指标B 不会自动重建? 请告诉我我的错误是什么? 你调用指标A(通过iCustom)的一些特定设置是独立于指标A 的设置,这意味着终端同时计算指标A 的两个独立副本。 [删除] 2013.04.11 13:14 #2785 TarasBY: 你用某些设置调用指标A(通过iCustom),而这些设置并不取决于指标A 的设置,这意味着终端同时计算了指标A 的两个独立副本。 应该怎样做才能使终端计算出指标A 的第二个变体? TarasBY 2013.04.11 13:21 #2786 MK07: 应该怎样做才能使终端计算出指标A 的第二个版本? 对任务要更加具体。 [删除] 2013.04.11 14:10 #2787 borilunad: 如果你学会了,你是如何从提示中学习的?只有积极的、充满好奇心的自学才会有成果!我把你嚼碎了,你却吐出了合理的建议!找个保姆来收拾你的烂摊子吧! 缓和你的自负!我没有因为这个建议而反弹,我接受了它并感谢你,但我不认为是这样的!我以文明的方式询问并回答了问题。 Ivan Miheev 2013.04.11 14:40 #2788 你好!在EA中需要使用Point变量的 值。但它等于0。 据我所知,这是因为报价中的小数点后有5位数字。有什么方法可以确定这个值吗?谢谢你。 [删除] 2013.04.11 15:14 #2789 TarasBY: 请把你的任务说得更清楚。指标A-- 正常AO(My_AO)--图片中最上面的一个。指标B- AO指标(My_AO)的柱状图(+1/-1)--图中的中间一个。当你改变指标A (图片中最下面那个)的参数时,即使你重新编译,指标B 也不会改变。我同时展示了两个AO指标(My_AO),只是为了说明指标的情况,但在真实情况下,应该有一个AO(My_AO)。第一个代码是指标A。第二个代码--指标B。//---- indicator settings #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Black #property indicator_color2 Green #property indicator_color3 Red #property indicator_width2 2 #property indicator_width3 2 #property indicator_level1 0.0 //---- input parameters extern int FastPeriod =5; extern int LowPeriod =34; //---- indicator buffers double ExtBuffer0[]; double ExtBuffer1[]; double ExtBuffer2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0,DRAW_NONE); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexStyle(2,DRAW_HISTOGRAM); IndicatorDigits(Digits+1); SetIndexDrawBegin(0,34); SetIndexDrawBegin(1,34); SetIndexDrawBegin(2,34); //---- 3 indicator buffers mapping SetIndexBuffer(0,ExtBuffer0); SetIndexBuffer(1,ExtBuffer1); SetIndexBuffer(2,ExtBuffer2); //---- name for DataWindow and indicator subwindow label IndicatorShortName("My_AO"); SetIndexLabel(1,NULL); SetIndexLabel(2,NULL); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Awesome Oscillator | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); double prev,current; //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- macd for(int i=0; i<limit; i++) ExtBuffer0[i]=iMA(NULL,0,FastPeriod,0,MODE_SMA,PRICE_MEDIAN,i)-iMA(NULL,0,LowPeriod,0,MODE_SMA,PRICE_MEDIAN,i); //---- dispatch values between 2 buffers bool up=true; for(i=limit-1; i>=0; i--) { current=ExtBuffer0[i]; prev=ExtBuffer0[i+1]; if(current>prev) up=true; if(current<prev) up=false; if(!up) { ExtBuffer2[i]=current; ExtBuffer1[i]=0.0; } else { ExtBuffer1[i]=current; ExtBuffer2[i]=0.0; } } //---- done return(0); }#property indicator_separate_window #property indicator_minimum -1.5 #property indicator_maximum 1.5 #property indicator_buffers 2 #property indicator_color1 Green #property indicator_color2 Red #property indicator_width1 2 #property indicator_width2 2 #property indicator_level1 0.0 //--- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(1,ExtMapBuffer2); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { double UP,DN; int counted_bars=IndicatorCounted(), limit; if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- for(int i=0;i<limit;i++) { UP=iCustom(NULL,0,"My_AO",1,i+1); DN=iCustom(NULL,0,"My_AO",2,i+1); if(UP>0) {ExtMapBuffer1[i+1]=1; ExtMapBuffer2[i+1]=0; } if(UP<0) {ExtMapBuffer1[i+1]=-1; ExtMapBuffer2[i+1]=0; } if(DN>0) { ExtMapBuffer1[i+1]=0; ExtMapBuffer2[i+1]=1; } if(DN<0) { ExtMapBuffer1[i+1]=0; ExtMapBuffer2[i+1]=-1; } } //---- return(0); } //+------------------------------------------------------------------+ TarasBY 2013.04.11 16:19 #2790 MK07:指标A-- 正常AO指标(My_AO)--图中最上面一个。指标B-- AO指标(My_AO)的直方图(+1/-1)--图中中间。如果你改变了指标A 的参数(图中底部),即使你重新编译,指标B 也不会改变。两个AO指标(My_AO)同时出现,我只是为了说明指标的情况,但在现实生活中,应该有一个AO(My_AO)。第一个代码是指标A。第二个代码是指标B。 而这种事情的顺序是正常的(这些是终端的原则)。 如果你想改变指标A 的参数,在指标之间进行信息交换(可以是文件、终端的全局变量、RAM):指标A 在初始化时传递可初始化的参数,指标B 定期检查指标A 的变化,当它检测到变化时,指标B 也应该用新参数进行初始化(强制init())。 1...272273274275276277278279280281282283284285286...432 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
我的函数在返回同一个数组的元素的值时出了问题。我将按顺序描述关于这个问题的一切。
全局变量 是。
int crossDir[3];
本计算中使用的函数。
我另外还打印了GetStateMa(int& crossDir[]) 函数返回的数组项的值。
这就是返回的内容。
返回的数组元素crossDir[] 的值是不同的,尽管它们的值都应该是1。
这可以从比较马赫4期和365期的表达式的未设置中看出。你能告诉我为什么返回的值不正确吗?
谢谢你的具体说明,因为发给我的链接没有具体提到这些数组,而且我没有注意左边那一栏,因为我在工作。
但没有人会吞下你吐出的一切,只有你自己;)
如果有的话,你是如何从暗示中学习的?只有积极的、充满好奇心的自学才会有成果!我把你嚼碎了,你却在 "回吐 "合理的建议!找个保姆来收拾你的烂摊子吧!
大家晚上好,我从指标A 建立了指标B(通过iCustom) 。 两个指标都在图表上。 当我改变指标A的 参数时,指标B 不会自动重建,我需要强行重新编译。 为什么指标B 不会自动重建? 请告诉我我的错误是什么?
你用某些设置调用指标A(通过iCustom),而这些设置并不取决于指标A 的设置,这意味着终端同时计算了指标A 的两个独立副本。
应该怎样做才能使终端计算出指标A 的第二个变体?
应该怎样做才能使终端计算出指标A 的第二个版本?
如果你学会了,你是如何从提示中学习的?只有积极的、充满好奇心的自学才会有成果!我把你嚼碎了,你却吐出了合理的建议!找个保姆来收拾你的烂摊子吧!
缓和你的自负!我没有因为这个建议而反弹,我接受了它并感谢你,但我不认为是这样的!我以文明的方式询问并回答了问题。
你好!
在EA中需要使用Point变量的 值。
但它等于0。
据我所知,这是因为报价中的小数点后有5位数字。
有什么方法可以确定这个值吗?
谢谢你。
请把你的任务说得更清楚。
指标A-- 正常AO(My_AO)--图片中最上面的一个。
指标B- AO指标(My_AO)的柱状图(+1/-1)--图中的中间一个。
当你改变指标A (图片中最下面那个)的参数时,即使你重新编译,指标B 也不会改变。
我同时展示了两个AO指标(My_AO),只是为了说明指标的情况,但在真实情况下,应该有一个AO(My_AO)。
第一个代码是指标A。
第二个代码--指标B。
指标A-- 正常AO指标(My_AO)--图中最上面一个。
指标B-- AO指标(My_AO)的直方图(+1/-1)--图中中间。
如果你改变了指标A 的参数(图中底部),即使你重新编译,指标B 也不会改变。
两个AO指标(My_AO)同时出现,我只是为了说明指标的情况,但在现实生活中,应该有一个AO(My_AO)。
第一个代码是指标A。
第二个代码是指标B。
而这种事情的顺序是正常的(这些是终端的原则)。
如果你想改变指标A 的参数,在指标之间进行信息交换(可以是文件、终端的全局变量、RAM):指标A 在初始化时传递可初始化的参数,指标B 定期检查指标A 的变化,当它检测到变化时,指标B 也应该用新参数进行初始化(强制init())。