cm_SL_Mouse

Author: Copyright � 2012
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategy
0 Views
0 Downloads
0 Favorites
cm_SL_Mouse
//+------------------------------------------------------------------+
//|                                                     SL Mause.mq4 |
//|                                Copyright © 2012 Vladimir Hlystov |
//|                                         http://cmillion.narod.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012"
#property link      "http://cmillion.narod.ru"
extern bool    comment           = true;  //display information on screen
//+------------------------------------------------------------------+
int start()
  {
   int Ticket;
   double value = NormalizeDouble(WindowPriceOnDropped(),Digits);
   string txt=StringConcatenate("script exhibiting SL ",DoubleToStr(value,Digits)," start ",TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS));
   RefreshRates();
   for(int i=OrdersTotal()-1;i>=0;i--)
   {
      if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
      if(OrderSymbol()!=Symbol()) continue;
      
      Ticket = OrderTicket();
      if(OrderType()==OP_BUY)     
      if(value<Ask) 
      {
         if (OrderModify(Ticket,OrderOpenPrice(),value,OrderTakeProfit() ,OrderExpiration(),White))
            txt = StringConcatenate(txt,"\nSet stoploss ",DoubleToStr(value,Digits)," BUY order ",Ticket);
         else txt = StringConcatenate(txt,"\nError ",GetLastError()," âûñòàâëåíèÿ stoploss BUY order ",Ticket);
      }
      
      if(OrderType()==OP_SELL)
      if(value>Bid) 
      {
         if (OrderModify(Ticket,OrderOpenPrice(),value, OrderTakeProfit(),OrderExpiration(),White))   
            txt = StringConcatenate(txt,"\nSet stoploss ",DoubleToStr(value,Digits)," SELL order ",Ticket);
         else txt = StringConcatenate(txt,"\nError ",GetLastError()," stoploss SELL order ",Ticket);
      }
         
      if((OrderType()==OP_BUYSTOP) || (OrderType()==OP_BUYLIMIT))     
      if(value<OrderOpenPrice()) 
      {
         if (OrderModify(Ticket,OrderOpenPrice(),value, OrderTakeProfit(),OrderExpiration(),White)) 
            txt = StringConcatenate(txt,"\nSet stoploss ",DoubleToStr(value,Digits)," placing BUY order ",Ticket);
         else txt = StringConcatenate(txt,"\nError ",GetLastError()," stoploss placing BUY order ",Ticket);
      }
       
      if((OrderType()==OP_SELLSTOP) || (OrderType()==OP_SELLLIMIT))
      if(value>OrderOpenPrice()) 
      {
         if (OrderModify(Ticket,OrderOpenPrice(),value, OrderTakeProfit(),OrderExpiration(),White))                
            txt = StringConcatenate(txt,"\nSet stoploss ",DoubleToStr(value,Digits)," placing SELL order ",Ticket);
         else txt = StringConcatenate(txt,"\nError ",GetLastError()," stoploss placing SELL order ",Ticket);
      }
      if (comment) Comment(txt);
   }   
   if (comment) Comment(txt,"\nThe script has finished its work ",TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS));
   return(0);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---