bool CSignalMACD::ExtState(int ind)
{
//--- operation of this method results in a bit-map of extremums//--- practically, the bit-map of extremums is an "array" of 4-bit fields//--- each "element of the array" definitely describes the ratio//--- of current extremums of the oscillator and the price with previous ones//--- purpose of bits of an element of the analyzed bit-map//--- bit 3 - not used (always 0)//--- bit 2 - is equal to 1 if the current extremum of the oscillator is "more extreme" than the previous one//--- (a higher peak or a deeper valley), otherwise - 0//--- bit 1 - not used (always 0)//--- bit 0 - is equal to 1 if the current extremum of price is "more extreme" than the previous one//--- (a higher peak or a deeper valley), otherwise - 0//--- in addition to them, the following is formed://--- array of values of extremums of the oscillator,//--- array of values of price extremums and//--- array of "distances" between extremums of the oscillator (in bars)//--- it should be noted that when using the results of the extended check of state,//--- you should consider, which extremum of the oscillator (peak or valley)//--- is the "reference point" (i.e. was detected first during the analysis)//--- if a peak is detected first then even elements of all arrays//--- will contain information about peaks, and odd elements will contain information about valleys//--- if a valley is detected first, then respectively in reverseint pos=ind,off,index;
uint map; // intermediate bit-map for one extremum//---
m_extr_map=0;
for(int i=0;i<10;i++)
{
off=StateMain(pos);
if(off>0)
{
//--- minimum of the oscillator is detected
pos+=off;
m_extr_pos[i]=pos;
m_extr_osc[i]=Main(pos);
if(i>1)
{
m_extr_pr[i]=m_low.MinValue(pos-2,5,index);
//--- form the intermediate bit-map
map=0;
if(m_extr_pr[i-2]<m_extr_pr[i])
map+=1; // set bit 0if(m_extr_osc[i-2]<m_extr_osc[i])
map+=4; // set bit 2//--- add the result
m_extr_map+=map<<(4*(i-2));
}
else
m_extr_pr[i]=m_low.MinValue(pos-1,4,index);
}
else
{
//--- maximum of the oscillator is detected
pos-=off;
m_extr_pos[i]=pos;
m_extr_osc[i]=Main(pos);
if(i>1)
{
m_extr_pr[i]=m_high.MaxValue(pos-2,5,index);
//--- form the intermediate bit-map
map=0;
if(m_extr_pr[i-2]>m_extr_pr[i])
map+=1; // set bit 0if(m_extr_osc[i-2]>m_extr_osc[i])
map+=4; // set bit 2//--- add the result
m_extr_map+=map<<(4*(i-2));
}
else
m_extr_pr[i]=m_high.MaxValue(pos-1,4,index);
}
}
//---return(true);
}
i doubt the sentence : m_extr_pr[i]=m_low.MinValue(pos-2,5,index); and m_extr_pr[i]=m_low.MinValue(pos-1,4,index);
why do not use the price that just at m_extr_pos[i] to fill m_extr_pr[i] .
the function as below shows
i doubt the sentence : m_extr_pr[i]=m_low.MinValue(pos-2,5,index); and m_extr_pr[i]=m_low.MinValue(pos-1,4,index);
why do not use the price that just at m_extr_pos[i] to fill m_extr_pr[i] .