One_Price_SL_TP

Author: Copyright 2021, SpaceX Software Corp.
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
One_Price_SL_TP
//+------------------------------------------------------------------+
//|                                              One Price SL TP.mq4 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, SpaceX Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
 #property strict
 #property show_inputs

input double ZEN = 0;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
      int total = OrdersTotal();
  for(int b=total-1;b>=0;b--)
  {
     if(OrderSelect(b, SELECT_BY_POS)==false) break;
     if(OrderCloseTime()!=0 || OrderSymbol()!=Symbol()) continue;
     
     if(OrderType()==OP_BUY)
       if(ZEN>0 && ZEN>Ask)
         if(OrderTakeProfit()>=0)
                 {
                 if(!OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),ZEN,0,clrNONE))
                        Print("Take Profit Updated TO New Level ",OrderTicket());
                     
                    }
                  
         if(ZEN>0 && ZEN<Bid)
         if(OrderStopLoss()>=0)
                 {
                 if(!OrderModify(OrderTicket(),OrderOpenPrice(),ZEN,OrderTakeProfit(),0,clrNONE))
                        Print("Stop Loss Updated TO New Level ",OrderTicket());
                     
                    }
                    
      if(OrderType()==OP_SELL)
       if(ZEN>0 && ZEN<Bid)
         if(OrderTakeProfit()>=0)
                 {
                 if(!OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),ZEN,0,clrNONE))
                        Print("Take Profit Updated TO New Level ",OrderTicket());
                     
                    }
                  
         if(ZEN>0 && ZEN>Ask)
         if(OrderStopLoss()>=0)
                 {
                 if(!OrderModify(OrderTicket(),OrderOpenPrice(),ZEN,OrderTakeProfit(),0,clrNONE))
                        Print("Stop Loss Updated TO New Level ",OrderTicket());
                     
                    }
//---
   
  }
//+------------------------------------------------------------------+
 
  }
//+------------------------------------------------------------------+

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 ---