Exp-Rami-Stop

Author: Copyright � 2006, LeonSi.
Exp-Rami-Stop
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
Exp-Rami-Stop
//+------------------------------------------------------------------+
//|                                                Exp-4StepStop.mq4 |
//|                                        Copyright © 2006, LeonSi. |
//|                                      http://www.expert-mt4.nm.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, LeonSi."
#property link      "http://www.expert-mt4.nm.ru"

//---- input parameters
extern int       Trailing1=50;
extern int       STLos1=20;
extern int       Trailing2=40;
extern int       STLos2=40;
extern int       Trailing3=30;
extern int       STLos3=60;
extern int       Trailing4=10;
extern int       STLos4=90;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//---- 
int cnt;
//---- Go for Change StopLoss
if(OrdersTotal()>0)
   {
   Comment(" ");
   for(cnt=0; cnt<=OrdersTotal(); cnt++)
      {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
//---- StopLoss for Buy
      if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && OrderStopLoss()>0)
         {
         if(OrderOpenPrice()+(STLos4*Point)<Bid && OrderStopLoss()<Bid-(Trailing4*Point))
            {
            Comment("4 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket());
            OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(Trailing4*Point),OrderTakeProfit(),0,Blue);
            return(0);
            }
//---- STLos1
         if(OrderOpenPrice()+(STLos3*Point)<Bid && OrderStopLoss()<Bid-(Trailing3*Point))
            {
            Comment("3 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket());
            OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(Trailing3*Point),OrderTakeProfit(),0,Blue);
            return(0);
            }
//---- STLos2
         if(OrderOpenPrice()+(STLos2*Point)<Bid && OrderStopLoss()<Bid-(Trailing2*Point))
            {
            Comment("2 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket());
            OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(Trailing2*Point),OrderTakeProfit(),0,Blue);
            return(0);
            }
//---- STLos3
         if(OrderOpenPrice()+(STLos1*Point)<Bid && OrderStopLoss()<Bid-(Trailing1*Point))
            {
            Comment("1 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket());
            OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(Trailing1*Point),OrderTakeProfit(),0,Blue);
            return(0);
            }
         }
//---- StopLoss for Sell
      if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && OrderStopLoss()>0)
         {
         if(OrderOpenPrice()-(STLos4*Point)>Ask && OrderStopLoss()>Ask+(Trailing4*Point))
            {
            Comment("4 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket());
            OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(Trailing4*Point),OrderTakeProfit(),0,Green);
            return(0);
            }
//---- STLos1
         if(OrderOpenPrice()-(STLos3*Point)>Ask && OrderStopLoss()>Ask+(Trailing3*Point))
            {
            Comment("3 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket());
            OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(Trailing3*Point),OrderTakeProfit(),0,Green);
            return(0);
            }
//---- STLos2
         if(OrderOpenPrice()-(STLos2*Point)>Ask && OrderStopLoss()>Ask+(Trailing2*Point))
            {
            Comment("2 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket());
            OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(Trailing2*Point),OrderTakeProfit(),0,Green);
            return(0);
            }
//---- STLos3
         if(OrderOpenPrice()-(STLos1*Point)>Ask && OrderStopLoss()>Ask+(Trailing1*Point))
            {
            Comment("1 Stop Changed ",OrderSymbol(),OrderType()," Number Ticket=",OrderTicket());
            OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(Trailing1*Point),OrderTakeProfit(),0,Green);
            return(0);
            }
         }
      }
   }
//+------------------------------------------------------------------+
   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 ---