currency correlation code help - page 2

 
//=1============================================================================
bool Correlation_Enabled  = false ;

void OnTick ()
{
if ( Correlation_Enabled == false && IsCorrelated () )
   {
     Alert ( Symbol () , " Correlation!" ) ;
     return ;
   }
}
//==============================================================================

//=2============================================================================
bool IsCorrelated ()
{
int  Positions = PositionsTotal () ;

if ( Positions == 0 ) return false ;


//------------------------------------------------------------------------------
// step 1> concatenate symbols of all opened positions in one buffer

string BufferString = "" ; 

for ( int i = Positions - 1 ; i >= 0 ; i-- )
    {
      int Length = StringConcatenate ( BufferString ,
                                       BufferString ,
                                       PositionGetSymbol ( i ) ) ;
    } // for
//------------------------------------------------------------------------------


// step 2> parse Symbol()

string Currency_1 = StringSubstr ( Symbol () , 0 , 3 ) ;  
string Currency_2 = StringSubstr ( Symbol () , 3 , 3 ) ;        


// step 3> search

int Comparison_1 = StringFind ( BufferString , Currency_1 , 0 ) ;
int Comparison_2 = StringFind ( BufferString , Currency_2 , 0 ) ;


// step 4> check

if      ( Comparison_1 >= 0 ) return true ;
else if ( Comparison_2 >= 0 ) return true ;


return false ;

} // IsCorrelated ()
//==============================================================================
 
Airat Safin:

AIrat you are an absolute legend, worked like a charm! Thank you.