LowerMaxTSV[0].idx = n;
I think you have it - loop through and find it.
Otherwise at the time of entering a value you could keep track of the highest/lowest but that's helpful with very large data sets, in this case it could be overkill
Hi Anil,
Please use the below ArraySorter code to get the least double value from a single dimensional array. I hope it helps.
#define Descending 0 #define Ascending 1 //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //+------------------------------------------------------------------+ //---- double arr[]= { 0,-10.6,-10.4,-12.5,-13.9,0,-13.3,-12.6,0,2.3,0.88,-5.6 }; ArraySorter(arr, Ascending); ArrayPrint(arr); Print(arr[0]); //---- return(INIT_SUCCEEDED); }// End init() //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ // Array Sorter | // - Single dimensional array sorter | //+------------------------------------------------------------------+ void ArraySorter( double &arrArray[], int AscDesc= Ascending ) { if (ArraySize(arrArray) == 1) return; // Only one item in array for(int i=0; i < ArraySize(arrArray); i++) { for(int j=i+1; j < ArraySize(arrArray); j++) { double store= arrArray[j]; switch (AscDesc) { case Ascending : if (arrArray[i] > arrArray[j]) { arrArray[j]= arrArray[i]; arrArray[i]= store; } break; case Descending : if (arrArray[i] < arrArray[j]) { arrArray[j]= arrArray[i]; arrArray[i]= store; } break; } } } //---- } //+------------------------------------------------------------------+
Hi Anil,
Please use the below ArraySorter code to get the least double value from a single dimensional array. I hope it helps.
This works if the data had only -ve nos, but it contains 0's.
I did consider copying all -ve values to a second array and using the in-built ArraySort(), but it was not clear whether the sequence had to be maintained also.
Ultimately it has to be loop (which your function uses anyway) - that maintains sequences and handles non -ve values
Hi Anil,
Please use the below ArraySorter code to get the least double value from a single dimensional array. I hope it helps.
@Keni Chetankumar Gajanan - Thanks a lot friend.
However @R4tna C has perfectly captured my logic (yes I need the Index of such bar).
Seems what I am doing is a correct workable solution.
Thanks again for both you to share the thoughts.
Regards.
@Keni Chetankumar Gajanan - Thanks a lot friend.
However @R4tna C has perfectly captured my logic (yes I need the Index of such bar).
Seems what I am doing is a correct workable solution.
Thanks again for both you to share the thoughts.
Regards.
You are welcome @Anil Varma
Glad to know that you got the solution.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi Friends
I have a array of negative or zero values.
I can find Minimum Lowest (-veLowest) by ArrayMinimum() method.
Is there any function which I can use to find Maximum Lowest (-ve Highest) ?
Currently I am using following code, but is there a better way to get this information.
Regards