Code snippets - page 8 12345678910111213 New comment learning 2014.09.26 20:05 #71 Is there a code snippet for rsi (not the built in rsi)? Mladen Rakic 2014.09.27 10:25 #72 apprentice coder:Is there a code snippet for rsi (not the built in rsi)? Here is an indicator that uses custom function (not the built in RSI) _rsi_function.mq4 It is as simple as it gets, and it can calculate RSI of period 1 (which built in RSI can not do) Files: _rsi_function.mq4 3 kb learning 2014.09.27 18:49 #73 mladen:Here is an indicator that uses custom function (not the built in RSI) _rsi_function.mq4 It is as simple as it gets, and it can calculate RSI of period 1 (which built in RSI can not do) Thank you learning 2014.09.30 10:47 #74 Is there a code that prevents opening a new order of a same kind on a same bar (if stop loss or take profit was hit, for example)? Mladen Rakic 2014.09.30 13:44 #75 apprentice coder:Is there a code that prevents opening a new order of a same kind on a same bar (if stop loss or take profit was hit, for example)? Check the check_can_open function from this EA : https://www.mql5.com/en/forum/174385/page239 learning 2014.09.30 21:11 #76 mladen:Check the check_can_open function from this EA : https://www.mql5.com/en/forum/174385/page239 Got it Thanks Mladen Rakic 2014.10.04 10:00 #77 Metatrader does not know how to sort multidimensional arrays Here is a simple shell sort procedure that is sorting 2 dimensional array in this case. It is easy to extend it to any dimension of the array : //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // shell sort // // // void SortIt(double& sortArr[][2]) { int size = ArrayRange(sortArr,0); int increment = size / 2; // // // // // while (increment > 0) { for (int i = increment; i < size; i++) { int j = i; double temp = sortArr[0]; double temi = sortArr[1]; while ((j >= increment) && (sortArr[j-increment][0] < temp)) { sortArr[j][0] = sortArr[j-increment][0]; sortArr[j][1] = sortArr[j-increment][1]; j = j-increment; } sortArr[j,0] = temp; sortArr[j,1] = temi; } if (increment == 2) increment = 1; else increment = (increment / 2.2); } } Metatrader known bugs ... Coding help [ARCHIVE]Any rookie question, so learning 2014.10.04 11:55 #78 mladen:Metatrader does not know how to sort multidimensional arrays Here is a simple shell sort procedure that is sorting 2 dimensional array in this case. It is easy to extend it to any dimension of the array : //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // shell sort // // // void SortIt(double& sortArr[][2]) { int size = ArrayRange(sortArr,0); int increment = size / 2; // // // // // while (increment > 0) { for (int i = increment; i < size; i++) { int j = i; double temp = sortArr[0]; double temi = sortArr[1]; while ((j >= increment) && (sortArr[j-increment][0] < temp)) { sortArr[j][0] = sortArr[j-increment][0]; sortArr[j][1] = sortArr[j-increment][1]; j = j-increment; } sortArr[j,0] = temp; sortArr[j,1] = temi; } if (increment == 2) increment = 1; else increment = (increment / 2.2); } } mladen Thanks for this. One more question : how can I find out the size of the second dimension? Mladen Rakic 2014.10.04 13:30 #79 apprentice coder:mladen Thanks for this. One more question : how can I find out the size of the second dimension? Use ArrayRange(sortArr,1) for the second dimension learning 2014.10.04 15:55 #80 mladen:Use ArrayRange(sortArr,1) for the second dimension Got it. Thanks 12345678910111213 New comment
Is there a code snippet for rsi (not the built in rsi)?
Is there a code snippet for rsi (not the built in rsi)?
Here is an indicator that uses custom function (not the built in RSI) _rsi_function.mq4
It is as simple as it gets, and it can calculate RSI of period 1 (which built in RSI can not do)
Here is an indicator that uses custom function (not the built in RSI) _rsi_function.mq4 It is as simple as it gets, and it can calculate RSI of period 1 (which built in RSI can not do)
Thank you
Is there a code that prevents opening a new order of a same kind on a same bar (if stop loss or take profit was hit, for example)?
Is there a code that prevents opening a new order of a same kind on a same bar (if stop loss or take profit was hit, for example)?
Check the check_can_open function from this EA : https://www.mql5.com/en/forum/174385/page239
Check the check_can_open function from this EA : https://www.mql5.com/en/forum/174385/page239
Got it
Thanks
Metatrader does not know how to sort multidimensional arrays
Here is a simple shell sort procedure that is sorting 2 dimensional array in this case. It is easy to extend it to any dimension of the array :
//
//------------------------------------------------------------------
//
//
//
// shell sort
//
//
//
void SortIt(double& sortArr[][2])
{
int size = ArrayRange(sortArr,0);
int increment = size / 2;
//
//
//
//
//
while (increment > 0)
{
for (int i = increment; i < size; i++)
{
int j = i;
double temp = sortArr[0];
double temi = sortArr[1];
while ((j >= increment) && (sortArr[j-increment][0] < temp))
{
sortArr[j][0] = sortArr[j-increment][0];
sortArr[j][1] = sortArr[j-increment][1];
j = j-increment;
}
sortArr[j,0] = temp;
sortArr[j,1] = temi;
}
if (increment == 2) increment = 1;
else increment = (increment / 2.2);
}
}Metatrader does not know how to sort multidimensional arrays
Here is a simple shell sort procedure that is sorting 2 dimensional array in this case. It is easy to extend it to any dimension of the array :
//
//------------------------------------------------------------------
//
//
//
// shell sort
//
//
//
void SortIt(double& sortArr[][2])
{
int size = ArrayRange(sortArr,0);
int increment = size / 2;
//
//
//
//
//
while (increment > 0)
{
for (int i = increment; i < size; i++)
{
int j = i;
double temp = sortArr[0];
double temi = sortArr[1];
while ((j >= increment) && (sortArr[j-increment][0] < temp))
{
sortArr[j][0] = sortArr[j-increment][0];
sortArr[j][1] = sortArr[j-increment][1];
j = j-increment;
}
sortArr[j,0] = temp;
sortArr[j,1] = temi;
}
if (increment == 2) increment = 1;
else increment = (increment / 2.2);
}
}mladen
Thanks for this. One more question : how can I find out the size of the second dimension?
mladen Thanks for this. One more question : how can I find out the size of the second dimension?
Use ArrayRange(sortArr,1) for the second dimension
Use ArrayRange(sortArr,1) for the second dimension
Got it. Thanks