BO_open_trade

Author: Copyright 2016, Barash777
Orders Execution
It automatically opens orders when conditions are reached
0 Views
0 Downloads
0 Favorites

Profitability Reports

GBP/CAD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
BO_open_trade
//+------------------------------------------------------------------+
//|                                                BO open trade.mq4 |
//|                                        Copyright 2016, Barash777 |
//|                                      barash.vertihvost@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, Barash777"
#property link      "barash.vertihvost@gmail.com"
#property version   "1.0"
#property strict
#property show_inputs
//+------------------------------------------------------------------+
//| Trade type                                                       |
//+------------------------------------------------------------------+
enum tmode
  {
   a1=0, // Buy
   a2=1, // Sell
  };

extern tmode  TradeDirection=0; // Trade direction
extern double BOInvestment=10;  // Investment size
extern int    BOExpiry=1;       // Expiration in minutes
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   OpenBO(TradeDirection);
  }
//+------------------------------------------------------------------+
//| Open BO orders                                                   |
//+------------------------------------------------------------------+
void OpenBO(int cmd)
  {
   int tkt=-1;

// define lot value
   double Lot=BOInvestment;

   if(cmd==OP_BUY)
      tkt=OrderSend(Symbol(),cmd,Lot,NormalizeDouble(Ask,Digits),0,0,0,"BO exp:"+IntegerToString(BOExpiry*60),0,0,clrGreen);
   if(cmd==OP_SELL)
      tkt=OrderSend(Symbol(),cmd,Lot,NormalizeDouble(Bid,Digits),0,0,0,"BO exp:"+IntegerToString(BOExpiry*60),0,0,clrRed);

// if order was opened
   if(tkt>0) return;
   else
     {
      int error=GetLastError();
      Print("Order was not open! Error #",error);
     }

   return;
  }
//+------------------------------------------------------------------+

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