//+------------------------------------------------------------------+ //| Copyright 2005, Gordago Software Corp. | //| http://www.gordago.com/ | //+------------------------------------------------------------------+ // I want to thank Michal Rutka, michal1@zonnet.nl, for helping me correct // the mistakes that I made... Good Job!! #property copyright "Provided by sencho, coded by don_forex" #property link "http://www.gordago.com" extern int TakeProfit = 850; extern int TrailingStop = 850; extern int PipDifference = 25; extern double Lots = 0.1; extern double MaximumRisk = 10; double Poin; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { //Checking for unconvetional Point digits number if (Point == 0.00001) Poin = 0.0001; //5 digits else if (Point == 0.001) Poin = 0.01; //3 digits else Poin = Point; //Normal } int start(){ int cnt, ticket; if(Bars<100){ Print("bars less than 100"); return(0); } if(TakeProfit<10){ Print("TakeProfit less than 10"); return(0); } string TradeSymbol = Symbol(); double MA144H = MathRound(iMA(NULL,0,144,0,MODE_EMA,PRICE_HIGH,0)/Poin)*Poin; double MA144L = MathRound(iMA(NULL,0,144,0,MODE_EMA,PRICE_LOW,0)/Poin)*Poin; double Spread = Ask-Bid; // MarketInfo(TradeSymbol,MODE_SPREAD); double BuyPrice = MA144H + Spread+PipDifference*Poin; double BuyStopLoss = MA144L - Poin; double BuyTakeProfit = MA144H +(PipDifference+TakeProfit)*Poin; double SellPrice = MA144L -(PipDifference)*Poin; double SellStopLoss = MA144H + Spread+Poin; double SellTakeProfit= MA144L - Spread-(PipDifference+TakeProfit)*Poin; double lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/50000,1); double close=iClose(NULL,0,0); int total=OrdersTotal(); bool need_long = true; bool need_short = true; // First update existing orders. for(cnt=0;cnt0) { if(Bid-OrderOpenPrice()>Poin*TrailingStop) { if(OrderStopLoss()SellStopLoss){ Print(SellStopLoss, " ",OrderStopLoss()); OrderModify(OrderTicket(),OrderOpenPrice(),SellStopLoss,SellTakeProfit,0,Green); OrderDelete(OrderTicket()); } if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(Poin*TrailingStop)) { if((OrderStopLoss()>(Ask+Poin*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Poin*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } } if(AccountFreeMargin()<(1000*lot)){ Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if (closeMA144L){ if(need_long) ticket=OrderSend(Symbol(),OP_BUYSTOP,lot,BuyPrice,3,BuyStopLoss,BuyTakeProfit,"Binario_v3",16384,0,Green); if(need_short) ticket=OrderSend(Symbol(),OP_SELLSTOP,lot,SellPrice,3,SellStopLoss,SellTakeProfit,"Binario_v3",16384,0,Red); } }