Initial commit: MQL5 Scripts Collection (MetaTrader 5)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# 🚀 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
|
||||
- `multi_breakeven.mq5`
|
||||
|
||||
---
|
||||
> Made with ❤️ for the trading community.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,93 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Multi_BreakEven.mq5 |
|
||||
//| Copyright 2023, MetaQuotes Ltd. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2023, MetaQuotes Ltd."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.00"
|
||||
#property script_show_inputs
|
||||
|
||||
#include <Trade/Trade.mqh>
|
||||
//create instance of the trade
|
||||
CTrade trade;
|
||||
//+------------------------------------------------------------------+
|
||||
//| input parameters |
|
||||
//+------------------------------------------------------------------+
|
||||
enum ChooseOption {Target=1,NumOfPips=2};
|
||||
input string Option = "SELECT TargetPrice OR NumOfPips BELOW";
|
||||
input string NOTEWELL = "When TargetPrice is selected,Pips has no effect&Vice Versa";
|
||||
|
||||
input ChooseOption TargetOrPips = 2;
|
||||
input int Pips2BreakEven = 100;
|
||||
input double TargetPrice = 1.03350;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
//---
|
||||
if( TerminalInfoInteger(TERMINAL_TRADE_ALLOWED) )
|
||||
{
|
||||
int pick = MessageBox("You are about to set StopLoss to BreakEven \n","BreakEven",0x00000001);
|
||||
if (pick==1) BreakEvenFunc();
|
||||
|
||||
}
|
||||
else MessageBox(" Enable AutoTrading !! ");
|
||||
|
||||
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
void BreakEvenFunc()
|
||||
{
|
||||
bool mbd =true;
|
||||
|
||||
for(int p=PositionsTotal()-1; p >=0; p--)
|
||||
if(PositionSelect(PositionGetSymbol(p)) && PositionGetString(POSITION_SYMBOL)== Symbol())
|
||||
{
|
||||
double opn = PositionGetDouble(POSITION_PRICE_OPEN),
|
||||
stl = PositionGetDouble(POSITION_SL),
|
||||
tp = PositionGetDouble(POSITION_TP);
|
||||
// Buy
|
||||
if(PositionGetInteger(POSITION_TYPE)== ORDER_TYPE_BUY)
|
||||
{
|
||||
double bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
|
||||
if(TargetOrPips==1)
|
||||
if(bid>TargetPrice && opn>stl)
|
||||
mbd= trade.PositionModify(PositionGetSymbol(p),TargetPrice,tp);
|
||||
|
||||
if(TargetOrPips==2)
|
||||
if(bid>opn+Pips2BreakEven*_Point && opn>stl)
|
||||
mbd= trade.PositionModify(PositionGetSymbol(p),opn+Pips2BreakEven*_Point,tp);
|
||||
|
||||
if(mbd==false)
|
||||
Alert("Buy modify. Err#",GetLastError());
|
||||
|
||||
}
|
||||
/*----------------------------------------------------------------------------------------------------------------*/
|
||||
// Sell
|
||||
if(PositionGetInteger(POSITION_TYPE)== ORDER_TYPE_SELL)
|
||||
{
|
||||
double ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
|
||||
if(TargetOrPips==1)
|
||||
if(ask<TargetPrice && (stl>opn || stl==0))
|
||||
mbd =trade.PositionModify(PositionGetSymbol(p),TargetPrice,tp);
|
||||
|
||||
if(TargetOrPips==2)
|
||||
if(ask<opn-Pips2BreakEven*_Point && (stl>opn || stl==0))
|
||||
mbd =trade.PositionModify(PositionGetSymbol(p),opn-Pips2BreakEven*_Point,tp);
|
||||
|
||||
if(mbd==false)
|
||||
Alert("Sell modify. Err#",GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
Reference in New Issue
Block a user