enum EResult{Ok,AllocError};
template<typename T>
EResult GetRepeat(const T &arr[],T &ret[],uint count){
int size=ArraySize(arr);
if (ArrayResize(ret,size)!=size) return AllocError;
int ii=0;
for (int i=0;i<size;){
T tmp=arr[i];
uint repeatCount=1;
while(++i<size&&arr[i]==tmp) ++repeatCount;
if (repeatCount>=count) ret[ii++]=tmp;}
returnArrayResize(ret,ii)==ii?Ok:AllocError;
}
voidOnStart()
{
int arr[]={1,2,4,4,4,55,55,7,7,7,7,7,8,9,77,66,66,66};
int ret[];
if (!GetRepeat(arr,ret,3)) ArrayPrint(ret);
}
if (IsTesting())
{
Trend = GlobalVariableGet(GV_tradesTrend);
TrendUP = iCustom(NULL,0,"Used\\# Once Trades Trend",3,0);
TrendDN = iCustom(NULL,0,"Used\\# Once Trades Trend",4,0);
if (TrendUP>0) {Trend=1; GlobalVariableSet(GV_tradesTrend,1);}
if (TrendDN>0) {Trend=-1;GlobalVariableSet(GV_tradesTrend,-1);}
if (Trend==1) {GlobalVariableSet(GV_Trend,1);}
if (Trend==-1) {GlobalVariableSet(GV_Trend,-1);}
if (Trend==0) {GlobalVariableSet(GV_Trend,0);}
}
else
{
Trend = GetLastTrendChange();
if (Trend==1) {GlobalVariableSet(GV_Trend,1);}
if (Trend==-1) {GlobalVariableSet(GV_Trend,-1);}
if (Trend==0) {GlobalVariableSet(GV_Trend,0);}
}
//+----------------------------------------------------------------------------+int GetLastTrendChange()
{
int trendType=0;
int y=0;
int t=500;
while (y<t)
{
if (iOpen(NULL,0,t)==y) {return(0);}
trendType=FindTrendChange(y);
if (trendType==1 || trendType==-1) {return(trendType);}
y++;
}
return(0);
}
//+----------------------------------------------------------------------------+int FindTrendChange(int index)
{
double trendUP,trendDN;
int trendType=0;
trendUP = iCustom(NULL,0,"Used\\# Once Trades Trend",3,index);
trendDN = iCustom(NULL,0,"Used\\# Once Trades Trend",4,index);
if (trendUP>0) {trendType=1;}
if (trendDN>0) {trendType=-1;}
return (trendType);
}
//+----------------------------------------------------------------------------+
祝大家今天愉快我在MT4测试器中使用mql4测试这个算法。我需要Print()函数来输出小数点后5位的买入价。但它只能打印出4(四)个小数位。请告诉我如何纠正我的错误,如果它存在的话。以下是我的代码。
}
同时,如果我用Print() 打印订单的开盘价和收盘价(通过SL和TP),那么Print()打印的价格是5(五)位数。
感谢大家的帮助。
DoubleToString(),而不是 NormalizeDouble()。
我告诉你我不喜欢我的决定(())。
太懒了,不想再写了。
谷歌 "阵列查找重复"--我想你会找到一些东西的
DoubleToString(),而不是 NormalizeDouble()。
非常感谢您提供的信息支持。
使用TimeToStruct()。
https://www.mql5.com/ru/docs/dateandtime/timetostruct
使用TimeToStruct()。
https://www.mql5.com/ru/docs/dateandtime/timetostruct
是的,我在mt4上有它
在MT4中可以使用
在MT4中可以使用
我不明白我如何能从这个返回小号的结构中获得位置被打开 时的分钟值......。
datetime o_open = OrderOpenTime();
MqlDateTime dt_struct;
TimeToStruct(o_open,dt_struct;)
int min =dt_struct.分钟。
如果你能帮助我了解在试图读取指标缓冲区数据时出了什么问题。
以下是EA的代码。
在实际和测试中,通过函数搜索最后一个值是可行的,但测试的速度是灾难性的(半年的测试要持续好几天)。
所以我决定在测试中使用交换,并将最后的数值保存到全局变量 中--专家顾问不再看到缓冲数据。而且,即使空缓冲区为0,由于某些原因,EA的变量取EMPTY_VALUE值而不改变。
但是当我把光标放在数据窗口中的缓冲线上时,工具提示中出现了两个值,第一个值是0,例如Value 5; 0.0000; 0.8855。
我找不到,尽管我在指标代码中打探到了这一点。在互联网和文献中的搜索并没有帮助。谁能告诉我,为什么当我试图使用这个指标时,测试的速度如此之慢?
请帮助我!