//+------------------------------------------------------------------+ //| _Open_LOCK.mq4 | //| "ÑÊÐÈÏÒÛ ÄËß ËÅÍÈÂÎÃÎ" | //| Ñêðèïò îòêðûâàåò îäèí LOCK äëÿ âñåõ îòêðûòûõ ïîçèöèé | //| (åñëè õâàòèò äåíþøêè) | //| Bookkeeper, 2006, yuzefovich@gmail.com | //+------------------------------------------------------------------+ #property copyright "" #property link "" #property show_inputs // Åñëè åñòü æåëàíèå ìåíÿòü ýêñòåðíû â ïðîöåññå //---- extern int DistSL = 35; // StopLoss â ïóíêòàõ extern int DistTP = 35; // TakeProfit â ïóíêòàõ extern int Slippage = 7; // Ïðîñêàëüçûâàíèå extern bool StopLoss = true; // Ñòàâèòü èëè íåò extern bool TakeProfit = true; // Ñòàâèòü èëè íåò //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void start() { int Total, i, Pos, Error, MinLotDgts; int Result; double MinLot = MarketInfo(Symbol(), MODE_MINLOT); double SL = 0, TP = 0, Stake, BuyLots = 0, SellLots = 0; Total = OrdersTotal(); if(Total > 0) // Åñëè åñòü îðäåðà { for(i = Total - 1; i >= 0; i--) { if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == true) { Pos = OrderType(); Stake = OrderLots(); if((OrderSymbol() == Symbol()) && (Pos == OP_BUY || Pos == OP_SELL)) // Ñìîòðèì òîëüêî îòêðûòûå Buy è Sell { // â àêòèâíîì îêíå if(Pos == OP_BUY) BuyLots = BuyLots + Stake; // Ñóììèðóåì Ëîòû îòêðûòûõ Buy else SellLots = SellLots + Stake; // Ñóììèðóåì Ëîòû îòêðûòûõ Sell } } } if(MinLot < 0.1) MinLotDgts = 2; else if(MinLot < 1.0) MinLotDgts = 1; else MinLotDgts = 0; Stake = NormalizeDouble(BuyLots - SellLots, MinLotDgts); if(Stake != 0) // Åñëè åñòü ÷òî ËÎÊèðîâàòü { if(Stake > 0) // ËÎÊèðóåì ïðîäàæåé { RefreshRates(); if(StopLoss == true) SL = NormalizeDouble(Ask + DistSL*Point, Digits); if(TakeProfit == true) TP = NormalizeDouble(Bid - 2*DistTP*Point, Digits); Result = OrderSend(Symbol(), OP_SELL, Stake, Bid, Slippage, SL, TP, ""); } else // ËÎÊèðóåì ïîêóïêîé { RefreshRates(); Stake = -Stake; if(StopLoss == true) SL = NormalizeDouble(Bid - DistSL*Point, Digits); if(TakeProfit == true) TP = NormalizeDouble(Ask + 2*DistTP*Point, Digits); Result = OrderSend(Symbol(), OP_BUY, Stake, Ask , Slippage, SL, TP, ""); } if(Result <= 0) { Error = GetLastError(); Alert("_Open_LOCK: LastError = ", Error); } else Error = 0; } else Alert("_Open_LOCK: BuyLots = SellLots"); } 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
It automatically opens orders when conditions are reached
Other Features:
It issuies visual alerts to the screen