checking for proper alignment of 5, 10, 20, 200 smas and returning color......
trend type filter......h
//------
//------
trend type filter......h
//------
Code:
//------ //------ for(int r = 0; r < ArraySize(tfs); r++) { int ma5[15]; int ma10[15]; int ma20[15]; int ma200[15]; ma5[r] = iMA(symbol, tfs[r],5,0,MODE_SMA,PRICE_CLOSE); ma10[r] = iMA(symbol, tfs[r],10,0,MODE_SMA,PRICE_CLOSE); ma20[r] = iMA(symbol, tfs[r],20,0,MODE_SMA,PRICE_CLOSE); ma200[r] = iMA(symbol, tfs[r],200,0,MODE_SMA,PRICE_CLOSE); double ma5s[]; ArraySetAsSeries(ma5s,true); CopyBuffer(ma5[r],0,0,4,ma5s); double ma10s[]; ArraySetAsSeries(ma10s,true); CopyBuffer(ma10[r],0,0,4,ma10s); double ma20s[]; ArraySetAsSeries(ma20s,true); CopyBuffer(ma20[r],0,0,4,ma20s); double ma200s[]; ArraySetAsSeries(ma200s,true); CopyBuffer(ma200[r],0,0,4,ma200s); clrmasalign[r] = clrYellow; if(( (ma5s[0] > ma10s[0]) && (ma5s[0] > ma20s[0]) && (ma10s[0] > ma20s[0]) && (ma20s[0] > ma200s[0]) ) && ( (ma5s[0] > ma5s[1]) && (ma10s[0] > ma10s[1]) && (ma20s[0] > ma20s[1]) && (ma200s[0] > ma200s[1]) ) ) { clrmasalign[r] = clrBlue; } if( ( (ma5s[0] < ma10s[0]) && (ma5s[0] < ma20s[0]) && (ma10s[0] < ma20s[0]) && (ma20s[0] < ma200s[0]) ) && ( (ma5s[0] < ma5s[1]) && (ma10s[0] < ma10s[1]) && (ma20s[0] < ma20s[1]) && (ma200s[0] < ma200s[1]) ) ) { clrmasalign[r] = clrRed; } } //------ //------
//------