Code Library / Ichimoku

MQL4 Ichimoku Filter

Ichimoku cloud as trade direction filter.

Language: MQL4 · Category: Ichimoku · Tags: Ichimoku, filter, MQL4, cloud, trend direction

Source code

int IchiFilter() {
   double sA=iIchimoku(Symbol(),0,9,26,52,MODE_SENKOUSPANA,0);
   double sB=iIchimoku(Symbol(),0,9,26,52,MODE_SENKOUSPANB,0);
   double t=iIchimoku(Symbol(),0,9,26,52,MODE_TENKANSEN,0);
   double k=iIchimoku(Symbol(),0,9,26,52,MODE_KIJUNSEN,0);
   if(Close[0]>MathMax(sA,sB)&&t>k) return 1;
   if(Close[0]<MathMin(sA,sB)&&t<k) return -1;
   return 0;
}

How to use this snippet

This is a building block, not a finished trading system. Paste it into your own MQL4 project, compile it, and test it on a demo account with your broker's real spreads before relying on it. If MetaEditor reports errors, the compilation error fixer can help.

Related snippets