Initial commit: MQL5 Scripts Collection (MetaTrader 5)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
# 🚀 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
|
||||
- `stopandtake.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: 2.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,36 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| StopAndTake.mq5 |
|
||||
//| Copyright 2016, melnik |
|
||||
//| https://www.mql5.com/ru/users/melnik |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2016, melnik"
|
||||
#property link "https://www.mql5.com/ru/users/melnik"
|
||||
#property version "1.00"
|
||||
#include <Trade\PositionInfo.mqh>
|
||||
#include <Trade\Trade.mqh>
|
||||
CPositionInfo pos;
|
||||
CTrade trade;
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart()
|
||||
{
|
||||
//---
|
||||
double price = NormalizeDouble(ChartPriceOnDropped(), _Digits);
|
||||
double bid=SymbolInfoDouble(_Symbol, SYMBOL_BID);
|
||||
double ask=SymbolInfoDouble(_Symbol, SYMBOL_ASK);
|
||||
for(int i=PositionsTotal()-1; i>=0; i--)
|
||||
{
|
||||
if(pos.SelectByIndex(i)==false)continue;
|
||||
if((pos.Type()==POSITION_TYPE_BUY) && (pos.Symbol()==_Symbol) && (price<bid))
|
||||
trade.PositionModify(pos.Ticket(), price, pos.TakeProfit());
|
||||
if((pos.Type()==POSITION_TYPE_BUY) && (pos.Symbol()==_Symbol) && (price>ask))
|
||||
trade.PositionModify(pos.Ticket(), pos.StopLoss(), price);
|
||||
|
||||
if((pos.Type()==POSITION_TYPE_SELL) && (pos.Symbol()==_Symbol) && (price<bid))
|
||||
trade.PositionModify(pos.Ticket(), pos.StopLoss(), price);
|
||||
if((pos.Type()==POSITION_TYPE_SELL) && (pos.Symbol()==_Symbol) && (price>ask))
|
||||
trade.PositionModify(pos.Ticket(), price, pos.TakeProfit());
|
||||
}
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
Reference in New Issue
Block a user