Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1012

 
MGSMGS:
Hello, could you please tell me if it's possible to convert the value of a text variable into the name of another variable. Or compare the text of a variable with the name of another variable.
You can, if the variable is global. GlobalVariableSet()
 
Good day, colleagues! I've been struggling with this for a week, I've added ready-made codes to scopes, but even if I compile them without errors, they still do not work in the tester, I've looked all over the Internet! I think the expert advisor is not bad if properly tuned, I can tighten the profit with trailing stops, please help, I'm boiling my brains out)) I have no idea what to do with it.
 
AlexeyVik:

Please try to keep your questions within this thread.

And read all the documentation carefully, you will remember that the function you need is there. All you have to do is find it. Here it is ArrayFree.


Thank you for your reply. TheArrayFree function is designed to work with dynamic arrays, as written in the documentation, and I asked for static arrays.
 
i999i:
Thank you for your reply. TheArrayFree function is designed to work with dynamic arrays, as written in the documentation, and I asked about static arrays.
Well, static arrays reserve memory for themselves immediately, regardless of whether they have data or not. If there is a need to free memory, you should use dynamic arrays, not static.
 
AlexeyVik:
Static arrays reserve memory for themselves immediately, regardless of whether they contain data or not. If there is a need to free memory, then dynamic arrays should be used, not static ones.
When exiting a function, do dynamic arrays work as local variables, or should the ArrayFree function be used?
 
i999i:
When exiting a function, do dynamic arrays work as local variables or do you still need to use the ArrayFree function ?
If the array is declared locally, it does not need anything. But if the array data is used in different functions, the array must be global, and then, before changing both array size and value, it's sometimes better to "delete" it and fill it again. Or, as in your question, if you think the array will no longer be used, nothing prevents you from getting rid of it.
 
AlexeyVik:
If the array is declared locally, it does not need anything. But if the array data is used in different functions, then the array must be global, and then, before changing both array size and values, it is sometimes better to "delete" it and fill it again. Or, as in your question, if you think the array will no longer be used, nothing prevents you from getting rid of it.
Thanks for the answers, it all makes sense now.
 

Hello! In the line below I got the error"array out of range". Can you help make this line correct?

rs=  High[iHighest(NULL,PERIOD_M15,MODE_HIGH,1,1)];
 
abeiks:

Hello! In the line below I got the error "array out of range". Can you help make this line correct?

In High[], the square brackets [ ] must contain an integer - the index of the candlestick in the chart, while the result iHighest(NULL,PERIOD_M15,MODE_HIGH,1,1) is the maximal value of one candlestick with index 1 and it will be a real number of type double in 99,999... %. Generally, this record by itself is not quite clear what it should do.
 
paladin80:
High[] must contain an integer in square brackets [ ] - the index of the candle in the chart, while the result iHighest(NULL,PERIOD_M15,MODE_HIGH,1,1) - the maximum value of one candle with index 1 and it will be a real number of type double in 99,999...%. In general, such an entry by itself is not quite clear what it should do.
Thank you! Then I will redo it.

Will this work? "array out of range" will not cause errors?

double High_Lim(ENUM_TIMEFRAMES GrafPeriod, int Bari_atp, int Bari_shift)
{double HighLim = iHigh(NULL, GrafPeriod,iHighest(NULL,GrafPeriod,MODE_HIGH,Bari_atp,Bari_shift));  
return(HighLim);}