//+------------------------------------------------------------------+ //| Kolachi method EA.mq4 | //| Kolachi Method of Trading is copyright of David Kolachi| //| Copyright © 2008, TradingSytemForex | //| http://www.tradingsystemforex.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2008, TradingSytemForex" #property link "http://www.tradingsystemforex.com" #define OrSt "Kolachi method EA" extern string IS="---------------- Indicator Settings"; extern double WMA_Period=5; extern double EMA1_Period=21; extern double EMA2_Period=55; extern double EMA3_Period=100; extern double EMA4_Period=200; extern string LM="---------------- Lot Management"; extern double Lots=0.1; extern bool MM=false; //money management extern double Risk=10; //risk in percentage extern string TSTB="---------------- TP SL TS BE"; bool RealSL_Enabled=false; int RealSL=5; //stop loss under 15 pīps bool RealTP_Enabled=false; int RealTP=10; //take profit under 10 pīps extern int SL=0; //stop loss extern int TP=0; //take profit extern int TS=0; //trailing stop extern int TS_Step=1; //trailing stop step extern int BE=0; //breakeven extern string EXT="---------------- Extras"; extern bool Reverse=false; extern bool Add_Positions=true; //positions cumulated extern int MaxOrders=100; //maximum number of orders extern int Magic=0; int Slip=3;static int TL=0;double MML=0; // expert start function int start(){int j=0,limit=1;double BV=0,SV=0;BV=0;SV=0;double WMA5a,WMA5b,EMA21a,EMA21b,EMA55,EMA100,EMA200; if(CntO(OP_BUY,Magic)>0) TL=1;if(CntO(OP_SELL,Magic)>0) TL=-1;for(int i=1;i<=limit;i++){ WMA5a=iMA(Symbol(),0,WMA_Period,0,MODE_LWMA,PRICE_CLOSE,i+1); WMA5b=iMA(Symbol(),0,WMA_Period,0,MODE_LWMA,PRICE_CLOSE,i); EMA21a=iMA(Symbol(),0,EMA1_Period,0,MODE_EMA,PRICE_CLOSE,i+1); EMA21b=iMA(Symbol(),0,EMA1_Period,0,MODE_EMA,PRICE_CLOSE,i); EMA55=iMA(Symbol(),0,EMA2_Period,0,MODE_EMA,PRICE_CLOSE,i); EMA100=iMA(Symbol(),0,EMA3_Period,0,MODE_EMA,PRICE_CLOSE,i); EMA200=iMA(Symbol(),0,EMA4_Period,0,MODE_EMA,PRICE_CLOSE,i); if(WMA5aEMA21b && EMA55EMA21a && WMA5bEMA21b && EMA100>EMA55 && EMA200>EMA100){if(Reverse) BV=1; else SV=1; break;}} // expert money management if(MM){if(Risk<0.1 || Risk>100) {Comment("Invalid Risk Value."); return(0);} else {MML=MathFloor((AccountFreeMargin() *AccountLeverage()*Risk*Point*100)/(Ask*MarketInfo(Symbol(),MODE_LOTSIZE)*MarketInfo(Symbol(),MODE_MINLOT )))*MarketInfo(Symbol(),MODE_MINLOT );}} if(MM==false){MML=Lots;} // expert init positions int cnt=0,OP=0,OS=0,OB=0,CS=0,CB=0;OP=0;for(cnt=0; cnt=1){OS=0; OB=0;}OB=0;OS=0;CB=0;CS=0; // expert conditions to open position if(SV>0){OS=1;OB=0;}if(BV>0){OB=1;OS=0;} // expert conditions to close position if((SV>0) || (RealSL_Enabled && (OrderOpenPrice()-Bid)/Point>=RealSL)||(RealTP_Enabled && (Ask-OrderOpenPrice())/Point>=RealTP)){CB=1;} if((BV>0) || (RealSL_Enabled && (Ask-OrderOpenPrice())/Point>=RealSL)||(RealTP_Enabled && (OrderOpenPrice()-Bid)/Point>=RealTP)){CS=1;} for(cnt=0;cnt0){if((pb-OrderOpenPrice())>BE*pp){if((OrderStopLoss()-OrderOpenPrice())<0){ModSL(OrderOpenPrice()+0*pp);}}} if(TS>0){if((pb-OrderOpenPrice())>TS*pp){if(OrderStopLoss()0){if((OrderOpenPrice()-pa)>BE*pp){if((OrderOpenPrice()-OrderStopLoss())<0){ModSL(OrderOpenPrice()-0*pp);}}} if (TS>0){if (OrderOpenPrice()-pa>TS*pp){if (OrderStopLoss()>pa+(TS+TS_Step-1)*pp || OrderStopLoss()==0){ModSL(pa+TS*pp);return;}}}}} //expert stoploss void ModSL(double ldSL){bool fm;fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldSL,OrderTakeProfit(),0,CLR_NONE);} //expert add positions function bool AddP(){int _num=0; int _ot=0; for (int j=0;j_ot) _ot=OrderOpenTime();}} if(_num==0) return(true);if(_num>0 && ((Time[0]-_ot))>0) return(true);else return(false);}