//+------------------------------------------------------------------+ //| Copyright 2005, Gordago Software Corp. | //| mail://CENTR75@MAIL.RU | //+------------------------------------------------------------------+ #property copyright "Copyright 2005,SS" #property link " mail://CENTR75@MAIL.RU " #define MAGIC 216457 extern double lStopLoss = 500; extern double sStopLoss = 500; extern double lTakeProfit = 100; extern double sTakeProfit = 100; extern double lTrailingStop = 4; extern double sTrailingStop = 4; 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 = 0; extern bool UseSound = True; extern string NameFileSound = "alert.wav"; extern double Lots = 0.10; extern int per=2; extern int per1=4; extern int zam=1; extern int Bands_Mode_0_2=0; // =0-2 MODE_MAIN, MODE_LOW, MODE_HIGH extern int Power_Price_0_6=1; // =0-6 PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW,PRICE_MEDIAN,PRICE_TYPICAL,PRICE_WEIGHTED extern int Price_Type_0_3=1; // =0-3 PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW extern int Bands_Period=50; extern int Power_Period=90; extern int CountBars=50; void deinit() { Comment(""); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start(){ if(Bars<100){ Print("bars less than 100"); return(0); } if(lStopLoss<10){ Print("StopLoss less than 10"); return(0); } if(lTakeProfit<10){ Print("TakeProfit less than 10"); return(0); } if(sStopLoss<10){ Print("StopLoss less than 10"); return(0); } if(sTakeProfit<10){ Print("TakeProfit less than 10"); return(0); } double diWPR0=iStochastic(NULL,0,per,1,zam,MODE_EMA,0,MODE_MAIN,0); double diWPR1=iStochastic(NULL,0,per1,1,zam,MODE_EMA,0,MODE_MAIN,0); double diADX0=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_MAIN,0); double diADX1=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_SIGNAL,0); double diADX2=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_MAIN,0); double diADX3=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_SIGNAL,0); double diADX4=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_MAIN,0); double diADX5=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_SIGNAL,0); double diADX6=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_MAIN,0); double diADX7=iCustom(NULL,0,"Trend",Bands_Mode_0_2,Power_Price_0_6,Price_Type_0_3,Bands_Period,Power_Period,CountBars,MODE_SIGNAL,0); if(AccountFreeMargin()<(1000*Lots)){ Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if (!ExistPositions()){ if ((diWPR0<1 && diADX0>diADX1 )){ OpenBuy(); return(0); } if ((diWPR0>99 && diADX0<diADX1 )){ OpenSell(); return(0); } } if (ExistPositions()){ if(OrderType()==OP_BUY){ if ((diWPR1>99 || diADX0<diADX1 )){ CloseBuy(); return(0); } } if(OrderType()==OP_SELL){ if ((diWPR1<1 || diADX0>diADX1)){ CloseSell(); return(0); } } } TrailingPositionsBuy(lTrailingStop); TrailingPositionsSell(sTrailingStop); return (0); } bool ExistPositions() { for (int i=0; i<OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) { return(True); } } } return(false); } void TrailingPositionsBuy(int trailingStop) { for (int i=0; i<OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) { if (OrderType()==OP_BUY) { if (Bid-OrderOpenPrice()>trailingStop*Point) { if (OrderStopLoss()<Bid-trailingStop*Point) ModifyStopLoss(Bid-trailingStop*Point); } } } } } } void TrailingPositionsSell(int trailingStop) { for (int i=0; i<OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) { if (OrderType()==OP_SELL) { if (OrderOpenPrice()-Ask>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 CloseBuy() { bool fc; fc=OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, clCloseBuy); if (fc && UseSound) PlaySound(NameFileSound); } void CloseSell() { bool fc; fc=OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, clCloseSell); if (fc && UseSound) PlaySound(NameFileSound); } void OpenBuy() { double ldLot, ldStop, ldTake; string lsComm; ldLot = GetSizeLot(); ldStop = GetStopLossBuy(); ldTake = GetTakeProfitBuy(); lsComm = GetCommentForOrder(); OrderSend(Symbol(),OP_BUY,ldLot,Ask,Slippage,ldStop,ldTake,lsComm,MAGIC,0,clOpenBuy); if (UseSound) PlaySound(NameFileSound); } void OpenSell() { double ldLot, ldStop, ldTake; string lsComm; ldLot = GetSizeLot(); ldStop = GetStopLossSell(); ldTake = GetTakeProfitSell(); lsComm = GetCommentForOrder(); OrderSend(Symbol(),OP_SELL,ldLot,Bid,Slippage,ldStop,ldTake,lsComm,MAGIC,0,clOpenSell); if (UseSound) PlaySound(NameFileSound); } string GetCommentForOrder() { return(Name_Expert); } double GetSizeLot() { return(Lots); } double GetStopLossBuy() { return (Bid-lStopLoss*Point);} double GetStopLossSell() { return(Ask+sStopLoss*Point); } double GetTakeProfitBuy() { return(Ask+lTakeProfit*Point); } double GetTakeProfitSell() { return(Bid-sTakeProfit*Point); }
Sample
Analysis
Market Information Used:
Indicator Curves created:
Indicators Used:
Stochastic oscillator
Custom Indicators Used:
Trend
Order Management characteristics:
Checks for the total of open orders
It can change open orders parameters, due to possible stepping strategy
It Closes Orders by itself
It automatically opens orders when conditions are reached
Other Features:
It plays sound alerts