Initial commit: MQL5 Scripts Collection (MetaTrader 5)
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
@@ -0,0 +1,21 @@
|
||||
# 🚀 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
|
||||
- `scriptsell.mq5`
|
||||
|
||||
---
|
||||
> Made with ❤️ for the trading community.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
@@ -0,0 +1,62 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| ScriptSell.mq5 |
|
||||
//| B Gabela |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property strict
|
||||
#property script_show_inputs
|
||||
|
||||
#include <Trade\Trade.mqh>
|
||||
#include <Trade\SymbolInfo.mqh>
|
||||
#include <Trade\AccountInfo.mqh>
|
||||
|
||||
#include "TradeHelper.mqh"
|
||||
|
||||
input double FIXED_DEAL_AMOUNT = 10000.00; //FIXED_DEAL_AMOUNT: Fixed amount to use per trade
|
||||
input bool USE_SL_ON_SELL = true; //USE_SL_ON_SELL: Use stop loss on Short positions
|
||||
|
||||
//--- Global Variables
|
||||
/*
|
||||
_Symbol+_MAX_SPREAD //Max spread for given symbol
|
||||
*/
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
init();
|
||||
|
||||
int spread = SymbolInfoInteger(_Symbol,SYMBOL_SPREAD);
|
||||
printHelper(LOG_INFO, StringFormat("Script: About to execute sell on %s with spread %d ", _Symbol, spread));
|
||||
|
||||
//Check spread
|
||||
int maxSpread = GlobalVariableGet(_Symbol+"_MAX_SPREAD");
|
||||
if((maxSpread > 0) && (spread > maxSpread))
|
||||
{
|
||||
printHelper(LOG_INFO, StringFormat("Script: Can't execute sell on %s as spread is above %d ", _Symbol, maxSpread));
|
||||
return;
|
||||
}
|
||||
|
||||
int barIndex = findLastGreenBar(20);
|
||||
double sl = iHigh(NULL,0,barIndex) + (getAdjustedPoint()*0.60);
|
||||
if(!USE_SL_ON_SELL)
|
||||
{
|
||||
sl = 0.00;
|
||||
}
|
||||
|
||||
placeSellOrder(m_trade, sl, 0.00, FIXED_DEAL_AMOUNT, "[M] ");
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Initialisation of script |
|
||||
//+------------------------------------------------------------------+
|
||||
void init()
|
||||
{
|
||||
m_trade.SetExpertMagicNumber(getMagicWithTimeframe());
|
||||
m_trade.SetMarginMode();
|
||||
m_trade.SetTypeFillingBySymbol(_Symbol);
|
||||
m_trade.SetDeviationInPoints(m_slippage);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
Reference in New Issue
Block a user