Initial commit: MQL5 Scripts Collection (MetaTrader 5)
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,22 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## Source Files
|
||||
- `buygslvtp.mq5`
|
||||
|
||||
---
|
||||
> Made with ❤️ for the trading community.
|
||||
@@ -0,0 +1,69 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| buy+sl+tp.mq5 |
|
||||
//| Copyright 2024, MetaQuotes Ltd. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2024, MetaQuotes Ltd."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
|
||||
#include <Trade/Trade.mqh>
|
||||
#include <Trade\SymbolInfo.mqh>
|
||||
//#include <Trade\PositionInfo.mqh>
|
||||
//#include <Trade\AccountInfo.mqh>
|
||||
|
||||
CTrade *m_trade;
|
||||
CSymbolInfo *m_symbol;
|
||||
//CPositionInfo *m_position_info;
|
||||
//CAccountInfo *m_account;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
double Lots = 0.01; // Lots (in pips)
|
||||
double StopLoss = 200; // stop loss (in pips)
|
||||
double TakeProfit = 400; // take profit (in pips)
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
//---
|
||||
m_trade = new CTrade();
|
||||
m_symbol = new CSymbolInfo();
|
||||
//m_position_info = new CPositionInfo();
|
||||
//m_account = new CAccountInfo();
|
||||
|
||||
m_symbol.Name(Symbol());
|
||||
m_symbol.RefreshRates();
|
||||
|
||||
double point = m_symbol.Point();
|
||||
double digits = m_symbol.Digits();
|
||||
double spread = m_symbol.Spread();
|
||||
|
||||
//---
|
||||
//+------------------------------------------------------------------+
|
||||
//| get/set global variable |
|
||||
//+------------------------------------------------------------------+
|
||||
if(!GlobalVariableCheck("LOT"))
|
||||
GlobalVariableSet("LOT",Lots);
|
||||
Lots = GlobalVariableGet("LOT");
|
||||
if(!GlobalVariableCheck("STOPLOSS"))
|
||||
GlobalVariableSet("STOPLOSS", StopLoss);
|
||||
StopLoss = GlobalVariableGet("STOPLOSS");
|
||||
if(!GlobalVariableCheck("TAKEPROFIT"))
|
||||
GlobalVariableSet("TAKEPROFIT",TakeProfit);
|
||||
TakeProfit = GlobalVariableGet("TAKEPROFIT");
|
||||
|
||||
double sl = NormalizeDouble(m_symbol.Ask() - StopLoss * point, (int)digits);
|
||||
double tp = NormalizeDouble(m_symbol.Ask() + TakeProfit * point, (int)digits);
|
||||
m_trade.PositionOpen(_Symbol, ORDER_TYPE_BUY, Lots, SymbolInfoDouble(_Symbol, SYMBOL_ASK), sl, tp);
|
||||
|
||||
delete m_trade;
|
||||
m_trade = NULL;
|
||||
delete m_symbol;
|
||||
m_symbol = NULL;
|
||||
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 2.4 KiB |