Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #property copyright "skype atomrus1993"
- #property link "e-mail [email protected]"
- #property description "описание"
- extern string S1 = "Общие параметры";
- extern int Magic = 26082012;//магик номер
- int Slippage = 20;//максимальное проскальзывание в пунктах
- extern bool model = true;
- extern int TakeProfit = 60;//тейк профит
- extern int StopLoss = 20;//стоп лосс
- extern double Lot = 0.1;//первоначальный лот
- extern int h_start = 8;
- extern int h_end = 19;
- extern bool d1 = true;
- extern bool d2 = true;
- extern bool d3 = true;
- extern bool d4 = true;
- extern bool d5 = true;
- int LotDigits = 2;//кол-во цифр после запятой для лота
- extern double Koef = 1;//коэффициент увеличение лота при пройгрыше
- //+------------------------------------------------------------------+
- //| expert initialization function |
- //+------------------------------------------------------------------+
- int init()
- {
- //----
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| expert deinitialization function |
- //+------------------------------------------------------------------+
- int deinit()
- {
- //----
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| expert start function |
- //+------------------------------------------------------------------+
- int start()
- {
- //----
- if (all () > 0) return (0);
- //----определение лота
- double lot = 0;
- if (last ("p") >= 0) lot = Lot;
- else lot = last ("l")*Koef;
- lot = norm_lot (lot);
- //----открытие сделки
- int day = DayOfWeek(); bool dayT=false;
- if(day==1 && d1==true){dayT=true;}
- if(day==2 && d2==true){dayT=true;}
- if(day==3 && d3==true){dayT=true;}
- if(day==4 && d4==true){dayT=true;}
- if(day==5 && d5==true){dayT=true;}
- bool timeT = false;
- if (Hour() >= h_start && Hour() <= h_end) {timeT = true;} else {timeT = false;}
- bool trade = false;
- if (dayT == true && timeT == true) {trade = true;}
- int b,s;
- if (model == true)
- {b = 0; s = 1;}
- else
- {b = 1; s = 0;}
- double
- ATR1 = iATR(Symbol(),0,14,1),
- ATR2 = iATR(Symbol(),0,14,2),
- ATR3 = iATR(Symbol(),0,14,3);
- if ( trade == true ) {
- if (ATR1 > ATR2 && ATR2 > ATR3) open (b, lot); // buy
- if (ATR1 < ATR2 && ATR2 < ATR3) open (s, lot); // sell
- }
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- int open (int type, double lot)
- {
- int tic = -1;
- double price_take, price_stop;
- for (int i = 0; i <= 5; i ++)
- {
- if (type % 2 == 0)
- {
- if (TakeProfit > 0) price_take = NormalizeDouble (Bid + TakeProfit*Point, Digits);
- if (StopLoss > 0) price_stop = NormalizeDouble (Bid - StopLoss*Point, Digits);
- tic = OrderSend (Symbol (), type, lot, NormalizeDouble (Ask, Digits), Slippage, price_stop, price_take, "", Magic);
- }
- if (type % 2 == 1)
- {
- if (TakeProfit > 0) price_take = NormalizeDouble (Ask - TakeProfit*Point, Digits);
- if (StopLoss > 0) price_stop = NormalizeDouble (Ask + StopLoss*Point, Digits);
- tic = OrderSend (Symbol (), type, lot, NormalizeDouble (Bid, Digits), Slippage, price_stop, price_take, "", Magic);
- }
- if (tic != -1) break;
- }
- return (tic);
- }
- int all ()
- {
- int all = 0;
- for (int i = OrdersTotal () - 1; i >= 0; i --)
- if (OrderSelect (i, SELECT_BY_POS) && OrderMagicNumber () == Magic && OrderSymbol () == Symbol ())
- all ++;
- return (all);
- }
- double last (string mode)
- {
- int time = -1;
- double profit = 0, lot = 0;
- for (int i = OrdersHistoryTotal () - 1; i >= 0; i --)
- if (OrderSelect (i, SELECT_BY_POS, MODE_HISTORY) && OrderMagicNumber () == Magic && OrderSymbol () == Symbol ())
- if (time < OrderOpenTime ())
- {
- time = OrderOpenTime ();
- profit = OrderProfit ();
- lot = OrderLots ();
- }
- double ec;
- if (mode == "p") ec = profit;
- if (mode == "l") ec = lot;
- return ec;
- }
- double norm_lot (double lot)
- {
- if (lot < MarketInfo (Symbol (), MODE_MINLOT)) lot = MarketInfo (Symbol (), MODE_MINLOT);
- if (lot > MarketInfo (Symbol (), MODE_MAXLOT)) lot = MarketInfo (Symbol (), MODE_MAXLOT);
- lot = NormalizeDouble (lot, LotDigits);
- Comment("Баланс: "+AccountBalance()+"\nСредства: "+AccountEquity()+"\nЛот: "+lot);
- return (lot);
- }
Advertisement
Add Comment
Please, Sign In to add comment