//http://forex-strategies-revealed.com/ #property copyright "Copyright 2008, Osama M. Ben Shaban" #property link "Email: shabano@gmail.com" #define MAGIC 1102008 string Name_Expert = "Jnene Baisc Balanced System"; extern double TimeFrame = 60; extern int EMA1 = 5; //EMA1 should be < EMA2 extern int EMA2 = 10; extern double SL = 60; extern double TP = 70; extern double TrStop = 40; extern double Lots = 1; extern bool UseMM = false; extern int Risk = 10; bool UseSound = True; int prevCountBars; void deinit() { Comment(""); } int start(){ if(Bars<100){ Print("bars less than 100"); return(0); } if(EMA1 >= EMA2){ Print("EMA1 > or = EMA2"); return(0); } if(SL<10 || TP<10){ Print("TakeProfit or StopLoss is less than 10"); return(0); } double EMA1c = iMA(NULL,TimeFrame,EMA1,0,MODE_EMA,PRICE_CLOSE,0); double EMA2c = iMA(NULL,TimeFrame,EMA2,0,MODE_EMA,PRICE_CLOSE,0); double EMA1p = iMA(NULL,TimeFrame,EMA1,0,MODE_EMA,PRICE_CLOSE,1); double EMA2p = iMA(NULL,TimeFrame,EMA2,0,MODE_EMA,PRICE_CLOSE,1); double RSI = iRSI(NULL,TimeFrame,14,PRICE_CLOSE,0); double STOc = iStochastic(NULL,TimeFrame,14,3,3,MODE_EMA,PRICE_CLOSE,MODE_MAIN,0); double STOp = iStochastic(NULL,TimeFrame,14,3,3,MODE_EMA,PRICE_CLOSE,MODE_MAIN,1); Comment("\nRSI = ",RSI); if (prevCountBars != Bars && prevCountBars !=0 && !ExistPositions()) { if(AccountFreeMargin()<(10)){ Print("You have no enough money. Free Margin = ", AccountFreeMargin()); return(0); } if (((EMA1c>EMA2c && EMA1p<=EMA2p)||(EMA1c>EMA2c)) && RSI>50 && STOp=EMA2p)||(EMA1cSTOc && STOc>20){ OpenSell(); return(0); } } if (prevCountBars != Bars && prevCountBars !=0 && ExistPositions()) { if(OrderType()==OP_BUY){ if(EMA1pEMA2p && RSI>50){ CloseSell(); } } } if(TrStop != 0){ TrailingPositionsBuy(TrStop); TrailingPositionsSell(TrStop); } prevCountBars = Bars; return (0); } bool ExistPositions() { for (int i=0; itrailingStop*Point) { if (OrderStopLoss()trailingStop*Point) { if (OrderStopLoss()>Ask+trailingStop*Point || OrderStopLoss()==0) ModifyStopLoss(Ask+trailingStop*Point); } } } } } } void ModifyStopLoss(double ldStopLoss) { bool fm; fm = OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE); if (fm && UseSound) PlaySound("alert.wav"); } void CloseBuy() { bool fc; fc=OrderClose(OrderTicket(), OrderLots(), Bid, 3, Aqua); if (fc && UseSound) PlaySound("alert.wav"); } void CloseSell() { bool fc; fc=OrderClose(OrderTicket(), OrderLots(), Ask, 3, Violet); if (fc && UseSound) PlaySound("alert.wav"); } void OpenBuy() { double ldLot, ldStop, ldTake; string lsComm; ldLot = GetSizeLot(); ldStop = GetStopLossBuy(); ldTake = GetTakeProfitBuy(); lsComm = GetCommentForOrder(); OrderSend(Symbol(),OP_BUY,ldLot,Ask,3,ldStop,ldTake,lsComm,MAGIC,0,Blue); if (UseSound) PlaySound("alert.wav"); } void OpenSell() { double ldLot, ldStop, ldTake; string lsComm; ldLot = GetSizeLot(); ldStop = GetStopLossSell(); ldTake = GetTakeProfitSell(); lsComm = GetCommentForOrder(); OrderSend(Symbol(),OP_SELL,ldLot,Bid,3,ldStop,ldTake,lsComm,MAGIC,0,Red); if (UseSound) PlaySound("alert.wav"); } string GetCommentForOrder() { return(Name_Expert); } double GetStopLossBuy() { return (Bid-SL*Point);} double GetStopLossSell() { return(Ask+SL*Point); } double GetTakeProfitBuy() { return(Ask+TP*Point); } double GetTakeProfitSell() { return(Bid-TP*Point); } double GetSizeLot(){ double Lot; Lot = (AccountBalance()*Risk*0.01)/1000; if (Lot>100) Lot = 100; if(!UseMM) Lot = Lots; return(Lot); }