ANDREY: Good day to you all! I am testing this algorithm in MT4 tester using mql4. I need Print() function to output the Bid price in log with 5 (five) decimal places. But it would only print 4 (four) decimal places. Please tell me how to fix my mistake, if it exists. Here is my code.
At the same time, if I print using Print() the opening, and closing price of the order( by SL and TP), then Print() prints the price with 5(five) digits. Thank you all for your help.
Google "array find repetitions" - I think you'll find something
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 you can help me understand what's wrong when trying to read indicator buffer data.
Here is the code from the EA:
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);
}
//+----------------------------------------------------------------------------+
In real and in tests searching for the last value through the function works, but the test is catastrophically slow (half year test stretches for several days).
So I decided to use swap on test and save last value to global variable - the Expert Advisor stopped seeing buffer data. And even though empty buffers are 0, for some reason EA's variables take EMPTY_VALUE values and do not change.
But when I put the cursor over the buffer line in the data window, two values appear in the tooltip, and the first value is 0, for example Value 5; 0.0000; 0.8855.
I can't find it out, though I poke around in the indicator code. The search in Internet and documentation didn't help. May someone please advise why the test is so slow when I try to use this indicator?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Good day to you all!
I am testing this algorithm in MT4 tester using mql4. I need Print() function to output the Bid price in log with 5 (five) decimal places. But it would only print 4 (four) decimal places. Please tell me how to fix my mistake, if it exists.
Here is my code.
}
At the same time, if I print using Print() the opening, and closing price of the order( by SL and TP), then Print() prints the price with 5(five) digits.
Thank you all for your help.
DoubleToString(), not NormalizeDouble()
I told you I didn't like my decision (((
I'm too lazy to write again.
Google "array find repetitions" - I think you'll find something
DoubleToString(), not NormalizeDouble()
Thank you very much for your informative support.
use TimeToStruct()
https://www.mql5.com/ru/docs/dateandtime/timetostruct
use TimeToStruct()
https://www.mql5.com/ru/docs/dateandtime/timetostruct
Yes I have it on mt4
it works in MT4
it works in MT4
I don't understand how I can get the value of minute whenposition was opened from this struct which returns trumpet...
datetime o_open = OrderOpenTime();
MqlDateTime dt_struct;
TimeToStruct( o_open, dt_struct;)
int min = dt_struct.min;
If you can help me understand what's wrong when trying to read indicator buffer data.
Here is the code from the EA:
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);} }In real and in tests searching for the last value through the function works, but the test is catastrophically slow (half year test stretches for several days).
So I decided to use swap on test and save last value to global variable - the Expert Advisor stopped seeing buffer data. And even though empty buffers are 0, for some reason EA's variables take EMPTY_VALUE values and do not change.
But when I put the cursor over the buffer line in the data window, two values appear in the tooltip, and the first value is 0, for example Value 5; 0.0000; 0.8855.
I can't find it out, though I poke around in the indicator code. The search in Internet and documentation didn't help. May someone please advise why the test is so slow when I try to use this indicator?
Please help me!