编码帮助 - 页 88 1...818283848586878889909192939495...786 新评论 Chrisstoff 2013.05.19 07:09 #871 亲爱的Mladen, 很抱歉,这是个基本问题--当代码需要对日期和时间进行操作时,我总是会遇到麻烦。你几天前在这个论坛上发布的AverageJoe EA第97行有一个常数120。 if (OrderType() == OP_SELL && CurTime()-LastSellTime >=120) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ); 这个120 的测量单位是什么? 请注意。 Chrisstoff Chrisstoff 2013.05.19 07:59 #872 mladen: Chrisstoff 这些是秒数(如果我没记错的话,从1.1.1970开始,metatrader将时间保存为秒数,但重点是,当声明一个数据时间变量或调用一个类似CurrentTime()的函数时,它总是以秒数工作)。 姆拉登。 谢谢你的快速回复。 Mladen Rakic 2013.05.19 14:43 #873 chrisstoff: 亲爱的Mladen,很抱歉,这是个基本的问题--当一个代码需要对日期和时间进行操作时,我总是会遇到麻烦。几天前你在这个论坛上发布的AverageJoe EA第97行有一个常数120。 if (OrderType() == OP_SELL && CurTime()-LastSellTime >=120) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ); 这个120 的测量单位是什么? 请注意。 Chrisstoff Chrisstoff 这些是秒(如果我没有记错的话,metatrader将时间保存为自1.1.1970以来的秒数,但问题是,当声明一个日期变量或调用一个类似CurrentTime()的函数 时,它总是以秒为单位工作。) Kreangast 2013.05.21 07:06 #874 修改指标 谢谢! #属性 indicator_chart_window #property indicator_buffers 5 //---- 输入参数 extern int TimeFramePeriod; extern int N=100; // extern double CustoMA1; extern double CustoMA2; extern double CustoMA3; 外置双倍CustoMA4; 外置双倍数high20。 extern double low20; // #属性 indicator_color1 红色 #属性indicator_color2 Lime #属性 indicator_color3 橙色 #属性 indicator_color4 红色 //--- 缓冲区 double CustoMA1[]; double CustoMA2[]; double CustoMA3[]; 双倍CustoMA4[]。 double tr[]; // int init() { SetIndexStyle(0, DRAW_LINE); SetIndexBuffer(0, CustoMA1); SetIndexStyle(1, DRAW_LINE); SetIndexBuffer(1, CustoMA2); SetIndexStyle(2, DRAW_LINE); SetIndexBuffer(2, CustoMA3); SetIndexStyle(3, DRAW_LINE); SetIndexBuffer(3, CustoMA4); SetIndexStyle(4, DRAW_LINE); SetIndexBuffer(4,tr); 返回(0)。 } //---- 缓冲区 double buff[]。 //+------------------------------------------------------------------+ //|自定义指标 初始化函数| //+------------------------------------------------------------------+ //int init() //{ //if (Bars < MIN_BARS_REQUIRED) return(-1); //IndicatorDigits(Digits)。 //SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2); //SetIndexBuffer(0, buff); //string paramDesc = "("+getPeriodDesc(TimeFramePeriod) + ", ")"。 //IndicatorShortName("" + paramDesc)。 // 设置索引标签 //SetIndexLabel(0, "" + paramDesc); //---- //返回(0)。 } //+------------------------------------------------------------------+ //| 自定义指标去初始化函数| //+------------------------------------------------------------------+ int start() { int Limit; int counted_bars=IndicatorCounted()。 //---- if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--。 int limit=Bars-counted_bars。 int i=0; for (i=Mathmin(Bars-5,Limit);i>=0;i--) 。 tr[]=MathMax(MathMax(High-Low,MathAbs(Close-High)), MathAbs(Close-Low))。 higt20=H=HHV(H,N)。 low20=L=LLV(L,N)。 // MA1=H-tr[]*0.1。 MA2=H-tr[]*0.2。 MA3=L+tr[]*0.1。 MA4=L+tr[]*0.2。 // CustoMA1=REF(MA1,BarsSince(higt20))。 CustoMA2=REF(MA2,BarsSince(higt20))。 CustoMA3=REF(MA3,BarsSince(low20))。 CustoMA4=REF(MA4,BarsSince(low20))。 // Plot(CustoMA1, "TREND",colorRed); Plot(CustoMA2, "TREND",colorLime); Plot(CustoMA3, "TREND",colorOrange); Plot(CustoMA4, "TREND",colorRed); //---- return(0); //+------------------------------------------------------------------+ string getPeriodDesc(int aNumMinutes) { switch(aNumMinutes) { case PERIOD_M1 : return("M1"); case PERIOD_M15: return("M15"); case PERIOD_M30 : return("M30"); case PERIOD_H1 : return("H1"); case PERIOD_H4 : return("H4"); case PERIOD_D1 : return("D1"); case PERIOD_W1 : return("W1"); case PERIOD_MN1 : return("MN1"); case 0: return("Chart"); 默认情况下:返回("M" + aNumMinutes)。 } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double getDeMarker(int aShift) { return(iDeMarker(NULL, TimeFramePeriod, 13, iBarShift(NULL, TimeFramePeriod, Time[aShift]) )。 } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ 开始() { for(int shift=Bars-1;shift>=0;shift--) { buff[shift]=getDeMarker(shift)。 } return(0); } //+------------------------------------------------------------------+ 对不起 !将代码粘贴在这里 姜思达 2013/5/21 Coding help ICustom函数 顾比多重移动平均线 Mladen Rakic 2013.05.21 07:43 #875 Kreangast: 修改指标 谢谢你!#属性 indicator_chart_window #property indicator_buffers 5 //---- 输入参数 Extern int TimeFramePeriod; extern int N=100; // extern double CustoMA1; extern double CustoMA2; extern double CustoMA3; 外置双倍CustoMA4; 外置双倍数high20。 extern double low20; // #属性 indicator_color1 红色 #属性indicator_color2 Lime #属性 indicator_color3 橙色 #属性 indicator_color4 红色 //--- 缓冲区 double CustoMA1[]; double CustoMA2[]; double CustoMA3[]; 双倍CustoMA4[]。 double tr[]; // int init() { SetIndexStyle(0, DRAW_LINE); SetIndexBuffer(0, CustoMA1); SetIndexStyle(1, DRAW_LINE); SetIndexBuffer(1, CustoMA2); SetIndexStyle(2, DRAW_LINE); SetIndexBuffer(2, CustoMA3); SetIndexStyle(3, DRAW_LINE); SetIndexBuffer(3, CustoMA4); SetIndexStyle(4, DRAW_LINE); SetIndexBuffer(4,tr); 返回(0)。 } //---- 缓冲区 double buff[]。 //+------------------------------------------------------------------+ //|自定义指标初始化函数| //+------------------------------------------------------------------+ //int init() //{ //if (Bars < MIN_BARS_REQUIRED) return(-1); //IndicatorDigits(Digits)。 //SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2); //SetIndexBuffer(0, buff); //string paramDesc = "("+getPeriodDesc(TimeFramePeriod) + ", ")"。 //IndicatorShortName("" + paramDesc)。 // 设置索引标签 //SetIndexLabel(0, "" + paramDesc); //---- //返回(0)。 } //+------------------------------------------------------------------+ //| 自定义指标去初始化函数| //+------------------------------------------------------------------+ int start() { int Limit; int counted_bars=IndicatorCounted()。 //---- if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--。 int limit=Bars-counted_bars。 int i=0; for (i=Mathmin(Bars-5,Limit);i>=0;i--) 。 tr[]=MathMax(MathMax(High-Low,MathAbs(Close-High)), MathAbs(Close-Low))。 higt20=H=HHV(H,N)。 low20=L=LLV(L,N)。 // MA1=H-tr[]*0.1。 MA2=H-tr[]*0.2。 MA3=L+tr[]*0.1。 MA4=L+tr[]*0.2。 // CustoMA1=REF(MA1,BarsSince(higt20))。 CustoMA2=REF(MA2,BarsSince(higt20))。 CustoMA3=REF(MA3,BarsSince(low20))。 CustoMA4=REF(MA4,BarsSince(low20))。 // Plot(CustoMA1, "TREND",colorRed); Plot(CustoMA2, "TREND",colorLime); Plot(CustoMA3, "TREND",colorOrange); Plot(CustoMA4, "TREND",colorRed); //---- return(0); //+------------------------------------------------------------------+ string getPeriodDesc(int aNumMinutes) { switch(aNumMinutes) { case PERIOD_M1 : return("M1"); case PERIOD_M15: return("M15"); case PERIOD_M30 : return("M30"); case PERIOD_H1 : return("H1"); case PERIOD_H4 : return("H4"); case PERIOD_D1 : return("D1"); case PERIOD_W1 : return("W1"); case PERIOD_MN1 : return("MN1"); case 0: return("Chart"); 默认情况下:返回("M" + aNumMinutes)。 } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double getDeMarker(int aShift) { return(iDeMarker(NULL, TimeFramePeriod, 13, iBarShift(NULL, TimeFramePeriod, Time[aShift]) )。 } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ 开始() { for(int shift=Bars-1;shift>=0;shift--) { buff[shift]=getDeMarker(shift)。 } return(0); } //+------------------------------------------------------------------+ 对不起 !将代码粘贴在这里 克雷恩加斯特 2013/5/21 那是有人试图将tadestation的代码与metatrader的代码结合起来。这样做是不行的,也不能这样结合。 Kreangast 2013.05.21 07:54 #876 致:mladen 你能进MT4吗?一段TS的代码,我就不写MT4了。谢谢你。 姜思达 2013-5-21 Mladen Rakic 2013.05.21 08:41 #877 Kreangast: 致:mladen你能进MT4吗?一段TS的代码,我就不写MT4了。谢谢你。 尊敬的先生 2013-5-21 从你发布的内容来看,不可能看到它应该做什么。 Kreangast 2013.05.21 08:53 #878 致:mladen 我想问的是如何做? 谢谢你 尊敬的各位领导 Mladen Rakic 2013.05.21 09:11 #879 Kreangast: 致:mladen我想问问如何做? 谢谢你 尊敬的先生 首先,你必须阅读这些:https://www.mql5.com/en/forum/172969/page2,然后是类似的tradestation,然后你可以将代码从一种编码语言转换成另一种编码语言。 Kreangast 2013.05.21 09:15 #880 mladen: 对于开始,你首先要阅读这些:https://www.mql5.com/en/forum/172969/page2,然后对tradestation的类似东西,然后你可以将代码从一种编码语言转换为另一种编码语言。 但这段代码不写,麻烦你换成MT4好吗?非常感谢 尊敬的各位领导 2013/5/21 1...818283848586878889909192939495...786 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
亲爱的Mladen,
很抱歉,这是个基本问题--当代码需要对日期和时间进行操作时,我总是会遇到麻烦。你几天前在这个论坛上发布的AverageJoe EA第97行有一个常数120。
if (OrderType() == OP_SELL && CurTime()-LastSellTime >=120) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
这个120 的测量单位是什么?
请注意。
Chrisstoff
Chrisstoff 这些是秒数(如果我没记错的话,从1.1.1970开始,metatrader将时间保存为秒数,但重点是,当声明一个数据时间变量或调用一个类似CurrentTime()的函数时,它总是以秒数工作)。
姆拉登。
谢谢你的快速回复。
亲爱的Mladen,
很抱歉,这是个基本的问题--当一个代码需要对日期和时间进行操作时,我总是会遇到麻烦。几天前你在这个论坛上发布的AverageJoe EA第97行有一个常数120。
if (OrderType() == OP_SELL && CurTime()-LastSellTime >=120) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
这个120 的测量单位是什么?
请注意。
ChrisstoffChrisstoff
这些是秒(如果我没有记错的话,metatrader将时间保存为自1.1.1970以来的秒数,但问题是,当声明一个日期变量或调用一个类似CurrentTime()的函数 时,它总是以秒为单位工作。)
修改指标 谢谢!
#属性 indicator_chart_window
#property indicator_buffers 5
//---- 输入参数
extern int TimeFramePeriod;
extern int N=100;
//
extern double CustoMA1;
extern double CustoMA2;
extern double CustoMA3;
外置双倍CustoMA4;
外置双倍数high20。
extern double low20;
//
#属性 indicator_color1 红色
#属性indicator_color2 Lime
#属性 indicator_color3 橙色
#属性 indicator_color4 红色
//--- 缓冲区
double CustoMA1[];
double CustoMA2[];
double CustoMA3[];
双倍CustoMA4[]。
double tr[];
//
int init() {
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, CustoMA1);
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(1, CustoMA2);
SetIndexStyle(2, DRAW_LINE);
SetIndexBuffer(2, CustoMA3);
SetIndexStyle(3, DRAW_LINE);
SetIndexBuffer(3, CustoMA4);
SetIndexStyle(4, DRAW_LINE);
SetIndexBuffer(4,tr);
返回(0)。
}
//---- 缓冲区
double buff[]。
//+------------------------------------------------------------------+
//|自定义指标 初始化函数|
//+------------------------------------------------------------------+
//int init()
//{
//if (Bars < MIN_BARS_REQUIRED) return(-1);
//IndicatorDigits(Digits)。
//SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
//SetIndexBuffer(0, buff);
//string paramDesc = "("+getPeriodDesc(TimeFramePeriod) + ", ")"。
//IndicatorShortName("" + paramDesc)。
// 设置索引标签
//SetIndexLabel(0, "" + paramDesc);
//----
//返回(0)。
}
//+------------------------------------------------------------------+
//| 自定义指标去初始化函数|
//+------------------------------------------------------------------+
int start()
{
int Limit;
int counted_bars=IndicatorCounted()。
//----
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--。
int limit=Bars-counted_bars。
int i=0;
for (i=Mathmin(Bars-5,Limit);i>=0;i--) 。
tr[]=MathMax(MathMax(High-Low,MathAbs(Close-High)), MathAbs(Close-Low))。
higt20=H=HHV(H,N)。
low20=L=LLV(L,N)。
//
MA1=H-tr[]*0.1。
MA2=H-tr[]*0.2。
MA3=L+tr[]*0.1。
MA4=L+tr[]*0.2。
//
CustoMA1=REF(MA1,BarsSince(higt20))。
CustoMA2=REF(MA2,BarsSince(higt20))。
CustoMA3=REF(MA3,BarsSince(low20))。
CustoMA4=REF(MA4,BarsSince(low20))。
//
Plot(CustoMA1, "TREND",colorRed);
Plot(CustoMA2, "TREND",colorLime);
Plot(CustoMA3, "TREND",colorOrange);
Plot(CustoMA4, "TREND",colorRed);
//----
return(0);
//+------------------------------------------------------------------+
string getPeriodDesc(int aNumMinutes)
{
switch(aNumMinutes)
{
case PERIOD_M1 : return("M1");
case PERIOD_M15: return("M15");
case PERIOD_M30 : return("M30");
case PERIOD_H1 : return("H1");
case PERIOD_H4 : return("H4");
case PERIOD_D1 : return("D1");
case PERIOD_W1 : return("W1");
case PERIOD_MN1 : return("MN1");
case 0: return("Chart");
默认情况下:返回("M" + aNumMinutes)。
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double getDeMarker(int aShift)
{
return(iDeMarker(NULL, TimeFramePeriod, 13, iBarShift(NULL, TimeFramePeriod, Time[aShift]) )。
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
开始()
{
for(int shift=Bars-1;shift>=0;shift--)
{
buff[shift]=getDeMarker(shift)。
}
return(0);
}
//+------------------------------------------------------------------+
对不起 !将代码粘贴在这里
姜思达
2013/5/21
修改指标 谢谢你!
#属性 indicator_chart_window
#property indicator_buffers 5
//---- 输入参数
Extern int TimeFramePeriod;
extern int N=100;
//
extern double CustoMA1;
extern double CustoMA2;
extern double CustoMA3;
外置双倍CustoMA4;
外置双倍数high20。
extern double low20;
//
#属性 indicator_color1 红色
#属性indicator_color2 Lime
#属性 indicator_color3 橙色
#属性 indicator_color4 红色
//--- 缓冲区
double CustoMA1[];
double CustoMA2[];
double CustoMA3[];
双倍CustoMA4[]。
double tr[];
//
int init() {
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, CustoMA1);
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(1, CustoMA2);
SetIndexStyle(2, DRAW_LINE);
SetIndexBuffer(2, CustoMA3);
SetIndexStyle(3, DRAW_LINE);
SetIndexBuffer(3, CustoMA4);
SetIndexStyle(4, DRAW_LINE);
SetIndexBuffer(4,tr);
返回(0)。
}
//---- 缓冲区
double buff[]。
//+------------------------------------------------------------------+
//|自定义指标初始化函数|
//+------------------------------------------------------------------+
//int init()
//{
//if (Bars < MIN_BARS_REQUIRED) return(-1);
//IndicatorDigits(Digits)。
//SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
//SetIndexBuffer(0, buff);
//string paramDesc = "("+getPeriodDesc(TimeFramePeriod) + ", ")"。
//IndicatorShortName("" + paramDesc)。
// 设置索引标签
//SetIndexLabel(0, "" + paramDesc);
//----
//返回(0)。
}
//+------------------------------------------------------------------+
//| 自定义指标去初始化函数|
//+------------------------------------------------------------------+
int start()
{
int Limit;
int counted_bars=IndicatorCounted()。
//----
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--。
int limit=Bars-counted_bars。
int i=0;
for (i=Mathmin(Bars-5,Limit);i>=0;i--) 。
tr[]=MathMax(MathMax(High-Low,MathAbs(Close-High)), MathAbs(Close-Low))。
higt20=H=HHV(H,N)。
low20=L=LLV(L,N)。
//
MA1=H-tr[]*0.1。
MA2=H-tr[]*0.2。
MA3=L+tr[]*0.1。
MA4=L+tr[]*0.2。
//
CustoMA1=REF(MA1,BarsSince(higt20))。
CustoMA2=REF(MA2,BarsSince(higt20))。
CustoMA3=REF(MA3,BarsSince(low20))。
CustoMA4=REF(MA4,BarsSince(low20))。
//
Plot(CustoMA1, "TREND",colorRed);
Plot(CustoMA2, "TREND",colorLime);
Plot(CustoMA3, "TREND",colorOrange);
Plot(CustoMA4, "TREND",colorRed);
//----
return(0);
//+------------------------------------------------------------------+
string getPeriodDesc(int aNumMinutes)
{
switch(aNumMinutes)
{
case PERIOD_M1 : return("M1");
case PERIOD_M15: return("M15");
case PERIOD_M30 : return("M30");
case PERIOD_H1 : return("H1");
case PERIOD_H4 : return("H4");
case PERIOD_D1 : return("D1");
case PERIOD_W1 : return("W1");
case PERIOD_MN1 : return("MN1");
case 0: return("Chart");
默认情况下:返回("M" + aNumMinutes)。
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double getDeMarker(int aShift)
{
return(iDeMarker(NULL, TimeFramePeriod, 13, iBarShift(NULL, TimeFramePeriod, Time[aShift]) )。
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
开始()
{
for(int shift=Bars-1;shift>=0;shift--)
{
buff[shift]=getDeMarker(shift)。
}
return(0);
}
//+------------------------------------------------------------------+
对不起 !将代码粘贴在这里
克雷恩加斯特
2013/5/21那是有人试图将tadestation的代码与metatrader的代码结合起来。这样做是不行的,也不能这样结合。
致:mladen
你能进MT4吗?一段TS的代码,我就不写MT4了。谢谢你。
姜思达
2013-5-21
致:mladen
你能进MT4吗?一段TS的代码,我就不写MT4了。谢谢你。
尊敬的先生
2013-5-21从你发布的内容来看,不可能看到它应该做什么。
致:mladen
我想问的是如何做?
谢谢你
尊敬的各位领导
致:mladen
我想问问如何做?
谢谢你
尊敬的先生首先,你必须阅读这些:https://www.mql5.com/en/forum/172969/page2,然后是类似的tradestation,然后你可以将代码从一种编码语言转换成另一种编码语言。
对于开始,你首先要阅读这些:https://www.mql5.com/en/forum/172969/page2,然后对tradestation的类似东西,然后你可以将代码从一种编码语言转换为另一种编码语言。
但这段代码不写,麻烦你换成MT4好吗?非常感谢
尊敬的各位领导
2013/5/21