//+------------------------------------------------------------------+ //| Copyright 2005, Gordago Software Corp. | //| http://www.gordago.com/ | //+------------------------------------------------------------------+ // Run this on EUR/USD 1MIN. adjust lots to suit <----> remove this whole line then compile #property copyright "Copyright 2005, Gordago Software Corp." #property link "http://www.gordago.com" extern double lTrailingStop = 13; extern double sTrailingStop = 21; extern color clOpenBuy = Blue; extern color clCloseBuy = Aqua; extern color clOpenSell = Red; extern color clCloseSell = Violet; extern color clModiBuy = Blue; extern color clModiSell = Red; extern string Name_Expert = "Generate from Gordago"; extern int Slippage = 2; extern bool UseSound = False; extern string NameFileSound = "alert.wav"; extern double Lots = 5; void deinit() { Comment(""); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start(){ if(Bars<100){ Print("bars less than 100"); return(0); } double diMA0=iMA(NULL,1,29,0,MODE_LWMA,PRICE_CLOSE,0); double diClose1=iClose(NULL,1,0); double diMA2=iMA(NULL,1,75,0,MODE_LWMA,PRICE_CLOSE,0); double diClose3=iClose(NULL,1,0); if(AccountFreeMargin()<(1000*Lots)){ Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if (!ExistPositions()){ if ((diMA0diClose3)){ OpenSell(); return(0); } } TrailingPositionsBuy(lTrailingStop); TrailingPositionsSell(sTrailingStop); 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(NameFileSound); } void OpenBuy() { double ldLot, ldStop, ldTake; string lsComm; ldLot = GetSizeLot(); ldStop = 0; ldTake = 0; lsComm = GetCommentForOrder(); OrderSend(Symbol(),OP_BUY,ldLot,Ask,Slippage,ldStop,ldTake,lsComm,0,0,clOpenBuy); if (UseSound) PlaySound(NameFileSound); } void OpenSell() { double ldLot, ldStop, ldTake; string lsComm; ldLot = GetSizeLot(); ldStop = 0; ldTake = 0; lsComm = GetCommentForOrder(); OrderSend(Symbol(),OP_SELL,ldLot,Bid,Slippage,ldStop,ldTake,lsComm,0,0,clOpenSell); if (UseSound) PlaySound(NameFileSound); } string GetCommentForOrder() { return(Name_Expert); } double GetSizeLot() { return(Lots); }