//+------------------------------------------------------------------+ //| Gurion.mq4 | //| Copyright © 2006, MetaQuotes Software Corp. | //| http://forum.alpari-idc.ru/showthread.php?p=563517 | //+------------------------------------------------------------------+ #property copyright "Copyright © 2006, MetaQuotes Software Corp." #property link "http://forum.alpari-idc.ru/showthread.php?p=563517" #property show_inputs #include <stdlib.mqh> extern int TakeProffit = 100; extern int StopLoss = 200; extern string type = "BUY STOP"; extern string symbol = "EURUSD"; extern double price = 0; extern double Lots = 1; extern int count = 1; //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { int cmd = 0; double stoploss = 0, takeprofit = 0; if (!IsConnected()) { Alert("Ñâÿçü îòñóòñòâóåò"); return (0); } if (!IsTradeAllowed()) { Alert("Òîðãîâëÿ çàïðåùåíà"); return (0); } if (type == "BUY STOP") cmd = OP_BUYSTOP; else if (type == "SELL STOP") cmd = OP_SELLSTOP; else if (type == "BUY LIMIT") cmd = OP_BUYLIMIT; else if (type == "SELL LIMIT") cmd = OP_SELLLIMIT; else return (0); if ((cmd == OP_BUYSTOP) || (cmd == OP_BUYLIMIT)) { stoploss = price - StopLoss * MarketInfo(symbol, MODE_POINT); takeprofit = price + TakeProffit * MarketInfo(symbol, MODE_POINT); } if ((cmd == OP_SELLSTOP) || (cmd == OP_SELLLIMIT)) { stoploss = price + StopLoss * MarketInfo(symbol, MODE_POINT); takeprofit = price - TakeProffit * MarketInfo(symbol, MODE_POINT); } Print(takeprofit+":"+stoploss); for (int i = 0; i < count; i++) { int ticket = OrderSend(symbol, cmd, NormalizeDouble(Lots, 1), NormalizeDouble(price, MarketInfo(symbol, MODE_DIGITS)), 3, NormalizeDouble(stoploss, MarketInfo(symbol, MODE_DIGITS)), NormalizeDouble(takeprofit, MarketInfo(symbol, MODE_DIGITS)), "", 0, 0, CLR_NONE); if (ticket < 0) { int err = GetLastError(); Print("OrderSend failed with error #", ErrorDescription(err)); return (0); } Sleep(1000); while (IsTradeContextBusy()) { Sleep(100); } } return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Indicator Curves created:
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Other Features:
It issuies visual alerts to the screen