//+------------------------------------------------------------------+ //| IRINKARAZAN.mq4 | //| Copyright © 2005, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" int magic_buy = 1000; int magic_sell = 1010; int order_buy [8]; int order_sell[8]; int count = 0; bool first_launch = false; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { for (int i = 0; i < 8; i++) { order_buy [i] = 0; order_sell[i] = 0; } count = 0; first_launch = false; return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if (!IsTradeAllowed()) { Alert("Òîðãîâëÿ çàïðåùåíà!"); return (0); } if (first_launch == false) { int a = 0, b = 0; first_launch = true; for (int ind = 0; ind < OrdersTotal(); ind++) { if ((OrderSelect(ind, SELECT_BY_POS, MODE_MAIN) == TRUE) && ((OrderMagicNumber() > 0))) { if ((OrderType() == OP_BUY) || (OrderType() == OP_BUYSTOP)) { order_buy[a] = OrderTicket(); a++; } if ((OrderType() == OP_BUY) || (OrderType() == OP_BUYSTOP)) { order_sell[b] = OrderTicket(); b++; } } } } //---- if (OrdersTotal() != count) { for (int j = 0; j < 8; j++) { if (OrderSelect(order_buy [j], SELECT_BY_TICKET, MODE_HISTORY)) { if (OrderProfit() > 0) { OrderSend(Symbol(), OP_BUYLIMIT, 0.1, OrderOpenPrice(), 3, NormalizeDouble(OrderOpenPrice() - 50 * Point, Digits), NormalizeDouble(OrderOpenPrice() + 25 * Point, Digits), "", 0, 0, CLR_NONE); } } if (OrderSelect(order_sell[j], SELECT_BY_TICKET, MODE_HISTORY)) { if (OrderProfit() > 0) { OrderSend(Symbol(), OP_SELLLIMIT, 0.1, OrderOpenPrice(), 3, NormalizeDouble(OrderOpenPrice() + 50 * Point, Digits), NormalizeDouble(OrderOpenPrice() - 25 * Point, Digits), "", 0, 0, CLR_NONE); } } Sleep(10000); while (IsTradeContextBusy()) { Sleep(1000); if (IsStopped() || !IsConnected()) return (0); } } count = OrdersTotal(); return (0); } if (OrdersTotal() != 0) { return (0); } for (int i = 0; i < 8; i++) { RefreshRates(); double price_buy = Ask + 50 * i * Point; double price_sell = Bid - 50 * i * Point; double stoploss_buy = price_buy - 50 * Point; double take_buy = price_buy + 25 * Point; double stoploss_sell= price_sell + 50 * Point; double take_sell = price_sell - 25 * Point; order_buy[i] = OrderSend(Symbol(), OP_BUYSTOP, 0.1, NormalizeDouble(price_buy, Digits), 3, NormalizeDouble(stoploss_buy, Digits), NormalizeDouble(take_buy, Digits), "BUYSTOP"+i, magic_buy + i, 0, CLR_NONE); Sleep(10000); while (IsTradeContextBusy()) { Print("Òîðãîâûé ïîòîê çàíÿò!"); Sleep(1000); if (IsStopped() || !IsConnected()) return (0); } RefreshRates(); order_sell[i]= OrderSend(Symbol(), OP_SELLSTOP, 0.1, NormalizeDouble(price_sell, Digits), 3, NormalizeDouble(stoploss_sell, Digits), NormalizeDouble(take_sell, Digits), "SELLSTOP"+i, magic_sell + i, 0, CLR_NONE); Sleep(10000); while (IsTradeContextBusy()) { Print("Òîðãîâûé ïîòîê çàíÿò!"); Sleep(1000); if (IsStopped() || !IsConnected()) return (0); } } count = 16; //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Indicator Curves created:
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Checks for the total of open orders
Other Features:
It issuies visual alerts to the screen