Warning: Rookie alert.
Suppose we have a custom array of say 1's and 0's. Is it possible to lookup for an array of pattern inside that array? How do we translate that into a code?
e.g.
MyArray[] = {0,1,1,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,1,1,0,0...} //customized array
PatternArray[5] = {1,0,1,0,1} //pattern to look for inside MyArray
TIA
- Array initialisation
- Array Count
- Help!! i have been struggling with arrays
arbteylim:
Warning: Rookie alert.
Suppose we have a custom array of say 1's and 0's. Is it possible to lookup for an array of pattern inside that array? How do we translate that into a code?
e.g.
MyArray[] = {0,1,1,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,1,1,0,0...} //customized array
PatternArray[5] = {1,0,1,0,1} //pattern to look for inside MyArray
TIA
Need to compare two arrays using: ArrayCompare.
Code:
//+------------------------------------------------------------------+ //| ArrayCompare.mq5 | //| Copyright © 2016, Vladimir Karputov | //| http://wmua.ru/slesar/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2016, Vladimir Karputov" #property link "http://wmua.ru/slesar/" #property version "1.00" //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- int MyArray[]={0,1,1,0,0,1,0,0,1,0,1,0,1,0,0,0,1,1,1,1,0,0}; //customized array int PatternArray[5]={1,0,1,0,1}; //pattern to look for inside MyArray //--- for(int i=0;i<ArraySize(MyArray);i++) { if(ArrayCompare(MyArray,PatternArray,i,0,ArraySize(PatternArray))==0) Print(IntegerToString(i)); } } //+------------------------------------------------------------------+
Files:
ArrayCompare.mq5
2 kb
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