arr[0]=v1; arr[1]=v2; …
gooeycode #: For example in a bubble algorithm
-
Never use Bubble Sort; forget you ever heard of it. An Insertion Sort is simpler and twice as fast.
-
template <typename Datatype, typename BinaryPredicate> void insertion_sort( const BinaryPredicate& comp, ///<[in]Comp. class/struct. Datatype& arr[],///<[in,out] Array to search. INDEX iEnd=MAX_INDEX,///<[in]One past last. INDEX iBeg=0)/**<[in]Starting index. */{ if(iEnd == MAX_INDEX) iEnd = get_size(arr); if(iEnd == iBeg) return; // This is more complicated than a standard insertion sort because array // access in MT4 is 10x slower than variable access. Datatype placing; Datatype previous = arr[iBeg]; for(INDEX iPlace = iBeg + 1; iPlace < iEnd; ++iPlace){ placing = arr[iPlace]; // Where does this go? if(comp.is_before(previous, placing) ){ // Already in correct position. previous = placing; continue; } // Prime for next iteration. INDEX iEmpty = iPlace; // Value in placing. do{ arr[iEmpty] = previous; // Move up. if(--iEmpty == iBeg) break; // No below. previous = arr[iEmpty - 1]; // Next one. } while(comp.is_before(placing, previous) ); arr[iEmpty] = placing; // Insert. previous = arr[iPlace]; // Prime for next iteration. } }
Ill read the documentation, there are a few concepts here I need to understand before I can reply. Thank you.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Any help will be much appreciated