Array function use on strict mode
Array function use on strict mode
Loading saved threads...
Dr Dz · External communityPost link
External question — Stack Overflow Stack Exchange
Author: Dr Dz
Original post: https://stackoverflow.com/questions/67040371
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
i have trouble for using these array function to be able to use it on MQL4 strict mode.
Could anyone hint me where i should start? The purpose is so it could work on strict mode.
int Trigger;
void function6(int &arrays[50])
{
int vals = ArraySize(arrays);
int trailingstop = TimeCurrent() - (arrays[function5(arrays) - 1]);
while(trailingstop > Trigger)
{
arrays[function5(arrays) - 1] = 0;
trailingstop = TimeCurrent() - (arrays[function5(arrays) - 1]);
if(function5(arrays) < 2)
break;
}
}
int function5(int &arrays[50])
{
int vals = ArraySize(arrays);
for(int k = 0; k < vals; k++)
if(!(arrays[k] > 0))
return (k);
return (vals - 1);
}
void function4(double &val[50])
{
int vald = ArraySize(val);
for(int l = vald; l > 0; l--)
val[l] = val[l - 1];
val[0] = 0;
}
void function3(int &arrays[50])
{
int vald = ArraySize(arrays);
for(int l = vald; l > 0; l--)
arrays[l] = arrays[l - 1];
arrays[0] = 0;
}
Quote
Report
PaulB · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: PaulB
Original post: https://stackoverflow.com/a/67048650
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Arrays start at 0, not 1. When using ArraySize to define counting of arrays, you should always minus 1 to account for starting at 0.
void function6(int &arrays[50])
{
int vals = ArraySize(arrays)-1;
int trailingstop = TimeCurrent() - (arrays[function5(arrays) - 1]);
while(trailingstop > Trigger)
{
arrays[function5(arrays) - 1] = 0;
trailingstop = TimeCurrent() - (arrays[function5(arrays) - 1]);
if(function5(arrays) < 2) break;
}
}
int function5(int &arrays[50])
{
int vals = ArraySize(arrays)-1;
for(int k = 0; k < vals; k++)
if(!(arrays[k] > 0)) return (k);
return (vals - 1);
}
void function4(double &val[50])
{
int vald = ArraySize(val)-1;
for(int l = vald; l > 0; l--)
val[l] = val[l - 1];
val[0] = 0;
}
void function3(int &arrays[50])
{
int vald = ArraySize(arrays)-1;
for(int l = vald; l > 0; l--) arrays[l] = arrays[l - 1];
arrays[0] = 0;
}
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: Dr Dz Source score (net votes, not local likes): 1 Original post: https://stackoverflow.com/questions/67040371 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. i have trouble for using these array function to be able to use it on MQL4 strict mode. Could anyone hint me where i should start? The purpose is so it could work on strict mode. int Trigger; void function6(int &arrays[50]) { int vals = ArraySize(arrays); int trailingstop = TimeCurrent() - (arrays[function5(arrays) - 1]); while(trailingstop > Trigger) { arrays[function5(arrays) - 1] = 0; trailingstop = TimeCurrent() - (arrays[function5(arrays) - 1]); if(function5(arrays) < 2) break; } } int function5(int &arrays[50]) { int vals = ArraySize(arrays); for(int k = 0; k < vals; k++) if(!(arrays[k] > 0)) return (k); return (vals - 1); } void function4(double &val[50]) { int vald = ArraySize(val); for(int l = vald; l > 0; l--) val[l] = val[l - 1]; val[0] = 0; } void function3(int &arrays[50]) { int vald = ArraySize(arrays); for(int l = vald; l > 0; l--) arrays[l] = arrays[l - 1]; arrays[0] = 0; }
Checking account access…