//+-------------------+ //| V1+V2_v4.mq4 | //+-------------------+ #property copyright "Bolla 2007" #property link "http://www.forex-tsd.com/" #include extern double MinFreeMarginPct= 50; //inputs esterni extern double TakeProfitLong = 27; extern double TakeProfitShort = 27; extern int DLong = 20; extern int DShort = 20; extern double Multiplier = 2; extern int MaxTrades = 8; extern int Slippage = 3; extern bool UseSound = false; //variabili globali string Name_Expert = "V1+V2_v4"; double stopLossB = 0; double stopLossS = 0; string NameFileSound = "alert.wav"; double InitLots = 0.01; double MaxLot = 2.56; int SL = 0; double sB=0,sS=0; int c,j; double LotsB,LotsS,Long,Short; double LastB=0,LastS=1000; extern int MagicLong=800111; extern int MagicShort=800222; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if(Bars<1) {Print("bars less than 1");return(0);} double Price=iClose(NULL,0,0); if (!ExistPositions()) {sB=0; sS=0;} int T=0; int B=0; for(int i=0;i10000) MaxLot=25.6; if (LotsB>MaxLot) LotsB=MaxLot; if (LotsS>MaxLot) LotsS=MaxLot; if (LotsB>2.56) LotsB=0.1; if (LotsS>2.56) LotsS=0.1; if (T==0) { Long=1000;} if (B==0) {Short=-1000;} if ((T>0)||(B>0)) { if ((sB==1)&&(Long>LastB)) Long=LastB; if ((sS==2)&&(Short=(LastS+(DShort)*Point))&&(c==0)) {OpenSell();sS=2;return(0);} if ((sB==1)&&(Price>=(Long+TakeProfitLong*Point))&&(AccountProfit()>0)) {closeAllOrders(0);sB=0;return(0);} if ((sS==2)&&(Price<=(Short-(TakeProfitShort+spread)*Point))&&(AccountProfit()>0)) {closeAllOrders(1);sS=0;return(0);} } return (0); } // - - - - - - FUNZIONI - - - - - - - bool ExistPositions() { for(int i=0;i 1) {OrderDelete(OrderTicket()); } } } string GetCommentForOrder() {return(Name_Expert);} double GetSizeLotB() {return(LotsB);} double GetSizeLotS() {return(LotsS);} double GetTakeProfitBuy() {return(Ask+TakeProfitLong*Point);} double GetTakeProfitSell() {return(Bid-TakeProfitShort*Point);}