← К каталогу
Исходный код · ID 3944

Pro7_EA

pro7_ea.mq4

Похожие материалы по тегам

#__slope direction line.mq5MQL5 / MetaTrader 5 · 1 общих теговrange breakout @meowforex1.pineTradingView · 1 общих тегов#1.mtf_collider_h4_close_13_v18bar.mq4MQL4 / MetaTrader 4 · 1 общих тегов!mth_fasttmaline_edit3.mq4MQL4 / MetaTrader 4 · 1 общих тегов!mth_fasttmaline_edit2.mq4MQL4 / MetaTrader 4 · 1 общих тегов!mth_fasttmaline_edit.mq4MQL4 / MetaTrader 4 · 1 общих тегов
Вы автор или правообладатель?

Сообщите нам, если считаете, что материал размещён без разрешения.

Краткий обзор

О программе

Pro7_EA — торговый советник для MetaTrader 4, позволяющий размещать отложенные ордера на покупку и продажу с настраиваемыми ценами входа. Советник поддерживает режим кумулятивных (диапазонных) сделок, при котором создаётся серия ордеров на разных ценовых уровнях вокруг заданной цены.

Советник отслеживает открытые позиции, управляет стоп-лоссами, тейк-профитами и брейк-эвенами для каждой сделки. Встроена фильтрация по максимальному спреду и задержка между сделками. Визуализация на графике включает кнопки включения/отключения, линии отложенных ордеров, уровни стоп-лосса и тейк-профита, а также информационные метки.

Обработка событий реализована через тики (start), таймер (OnTimer) и события кликов на графических объектах (OnChartEvent). Торговые операции выполняются через стандартный API OrderSend. Советник отслеживает сделки по магическому номеру и управляет массивом активных позиций.

Настройки программы

НастройкаОписание
Original EA Settings (Additional) Дополнительно — Разделитель настроек оригинального советника
Trade Lot size (LotSize) Размер лота — Размер лота для сделок
Number of minutes between trades (DelayNext) Задержка между сделками (мин) — Задержка в минутах между сделками
Max Slippage (Slippage) Максимальное проскальзывание — Максимальный проскальзывание
Max Spread to only open trades below this value (MaxSpread) Максимальный спред — Максимальный спред для открытия сделок
Magic number (MagicNumber) Магический номер — Магический номер для идентификации сделок
Trade Comment (Comment) Комментарий сделки — Комментарий к сделке
Pending Sell and Sell Range Options (PendsSell) Настройки отложенных продаж — Разделитель настроек отложенных продаж
Pending sell price to enter (PendSell) Цена отложенной продажи — Цена входа для отложенной продажи
Number of attempts EA will sell at price (NoSellAttempts) Количество попыток продажи — Количество попыток продажи по цене
Take profit pips, 0 for no TP (TakeProfitSellPips) Тейк-профит продажа (пипсы) — Тейк-профит в пипсах для продаж, 0 — без тейк-профита
Stop loss pips, 0 for no SL (StopLossSellPips) Стоп-лосс продажа (пипсы) — Стоп-лосс в пипсах для продаж, 0 — без стоп-лосса
Break even if profit pips above this, 0 for no BE (BreakEvenSellPips) Брейк-Эвен Продажа (пипсы) — Брейк-эвен в пипсах для продаж, 0 — без брейк-эвен
Default pips for pending range (DefaultRangeSellPips) Диапазон продаж (пипсы) — Стандартные пипсы для диапазона отложенных продаж
Trade Comment (CommentSell) Комментарий продажи — Комментарий к продаже
Pending Buy and Buy Range Options (PendsBuy) Настройки отложенных покупок — Разделитель настроек отложенных покупок
Pending buy price to enter (PendBuy) Цена отложенной покупки — Цена входа для отложенной покупки
Number of attempts EA will buy at price (NoBuyAttempts) Количество попыток покупки — Количество попыток покупки по цене
Take profit pips, 0 for no TP (TakeProfitBuyPips) Тейк-профит покупки (пипсы) — Тейк-профит в пипсах для покупок, 0 — без тейк-профита
Stop loss pips, 0 for no SL (StopLossBuyPips) Стоп-лосс покупки (пипсы) — Стоп-лосс в пипсах для покупок, 0 — без стоп-лосса
Break even if profit pips above this, 0 for no BE (BreakEvenBuyPips) Брейк-Эвен Покупка (пипсы) — Брейк-эвен в пипсах для покупок, 0 — без брейк-эвен
Default pips for pending range (DefaultRangeBuyPips) Диапазон покупок (пипсы) — Стандартные пипсы для диапазона отложенных покупок
Trade Comment (CommentBuy) Комментарий покупки — Комментарий к покупке
Color Options (Colors) Настройки цветов — Разделитель настроек цветов
On screen Labels (ColorLabels) Цвет меток — Цвет текстовых меток на графике
Pend Buy (ColorPendBuy) Цвет отложенной покупки — Цвет линии отложенной покупки
Pend Sell (ColorPendSell) Цвет отложенной продажи — Цвет линии отложенной продажи
Stop Loss (ColorStopLoss) Цвет стоп-лосса — Цвет отображения стоп-лосса на графике
Break Even (ColorBreakEven) Цвет брейк-эвен — Цвет отображения брейк-эвен на графике
Take Profit (ColorTakeProfit) Цвет тейк-профита — Цвет отображения тейк-профита на графике
Range Button (ColorRangeButton) Цвет кнопки диапазона — Цвет кнопки диапазона
Range Button Active (ColorRangeButtonActive) Цвет кнопки диапазона активна — Цвет кнопки диапазона при активном состоянии
Получить полный код

Поиск по коду файла

#define VERSION "1.0"
#property version VERSION
#property description "Pro7_EA"
#property strict

enum ActivateEA {
	off=0,  	// Trading Off
	on=1,  		// Trading On
};
ActivateEA Activate_EA = 0;			// EA activate

extern string Additional = "---------- Original EA Settings ----------";		// Original EA Settings
extern double LotSize = 0.02;						// Trade Lot size
extern int DelayNext = 3;							// Number of minutes between trades
extern int Slippage = 5;							// Max Slippage
extern int MaxSpread = 3;							// Max Spread to only open trades below this value
extern int MagicNumber = 9991;						// Magic number
extern string Comment = "Comment";					// Trade Comment

extern string PendsSell = "---------- Pending Sell and Sell Range Options ----------";		// Pending Sell and Sell Range Options
extern double PendSell = 0;							// Pending sell price to enter
extern int NoSellAttempts = 5;						// Number of attempts EA will sell at price
extern int TakeProfitSellPips = 0;					// Take profit pips, 0 for no TP
extern int StopLossSellPips = 0;					// Stop loss pips, 0 for no SL
extern int BreakEvenSellPips = 0;					// Break even if profit pips above this, 0 for no BE
extern int DefaultRangeSellPips = 0;				// Default pips for pending range
extern string CommentSell = "CommentSell";			// Trade Comment

extern string PendsBuy = "---------- Pending Buy and Buy Range Options ----------";		// Pending Buy and Buy Range Options
extern double PendBuy = 0;							// Pending buy price to enter
extern int NoBuyAttempts = 5;						// Number of attempts EA will buy at price
extern int TakeProfitBuyPips = 0;					// Take profit pips, 0 for no TP
extern int StopLossBuyPips = 0;						// Stop loss pips, 0 for no SL
extern int BreakEvenBuyPips = 0;					// Break even if profit pips above this, 0 for no BE
extern int DefaultRangeBuyPips = 0;					// Default pips for pending range
extern string CommentBuy = "CommentBuy";			// Trade Comment

extern string Colors = "---------- Color Options ----------";		// Color Options
extern color ColorLabels = White;					// On screen Labels
extern color ColorPendBuy = Lime;					// Pend Buy
extern color ColorPendSell = Red;					// Pend Sell
extern color ColorStopLoss = Magenta;				// Stop Loss
extern color ColorBreakEven = Yellow;				// Break Even
extern color ColorTakeProfit = DeepSkyBlue;			// Take Profit
extern color ColorRangeButton = White;				// Range Button 
extern color ColorRangeButtonActive = Green;		// Range Button Active

int tradeDifference;
int tradeDigits = 0;
datetime tradeTime = 0;
datetime tradeSecond;
double SlippageTrade = 1.0;			// 1.0 pips range of price detection below or above

bool RangeBuy = false;
bool RangeSell = false;
double RangePendBuy;
double RangePendSell;

bool BreakEvenBuy = false;
bool BreakEvenSell = false;

class Trades {
private:

public:
	int tradeID;			// client side trade id
	int tradeType;			// Long or short
	double tradeLotSize;	// Lot size
	double tradePrice;		// Price at trade open
	string tradeComment;	// Comment
	bool tradeClosed;		// Trade closed

	Trades() { }
	~Trades() { }
};
Trades* UserTrades[];

class CumulativeTrades {
private:
public:
	double price;
	int opened;
	int type;
	CumulativeTrades() { }
	~CumulativeTrades() { }
};
CumulativeTrades* CumulativeBuy[];
CumulativeTrades* CumulativeSell[];

int init() {
      // код доступен только после оплаты
   }

void OnDeinit( const int reason ) {
	for( int i = 0; i < ArraySize( UserTrades ); i++ ) {
		delete UserTrades[i];
	}
	ArrayResize( UserTrades, 0 );

	switch( reason ) {

		case REASON_PROGRAM:			// EA Removed from ExpertRemove()
		case REASON_REMOVE:				// EA Removed manually by user
		case REASON_CHARTCLOSE:			// Chart closed
		case REASON_INITFAILED: break;	// Failed to load EA

		case REASON_RECOMPILE:			// Mq4 Recompile
		case REASON_CHARTCHANGE:		// Chart / Timeframe change
		case REASON_PARAMETERS:			// EA input parameters changed
		case REASON_ACCOUNT:			// Changed Account
		case REASON_TEMPLATE:			// Template Changed
		case REASON_CLOSE:				// Terminal(MT4) Closed

			if( ArraySize( CumulativeBuy ) > 0 ) {
				string Implode = DoubleToStr( PendBuy ) + ";" + DoubleToStr( RangePendBuy ) + ";";
				for (int i = 0; i < ArraySize( CumulativeBuy ); i++) {
					Implode = StringConcatenate( Implode, IntegerToString( CumulativeBuy[i].opened ), ";" );
					ObjectDelete( 0, "PendBuy" + IntegerToString( i ) );
					delete CumulativeBuy[i];
				}
				ArrayResize( CumulativeBuy, 0 );
				if( ObjectFind( 0, "CumulativeBuy" ) < 0 ) ObjectCreate( 0, "CumulativeBuy", OBJ_TEXT, 0, 0, 0 );
				ObjectSetText( "CumulativeBuy", Implode );
			}
			if( ArraySize( CumulativeSell ) > 0 ) {
				string Implode = DoubleToStr( PendSell ) + ";" + DoubleToStr( RangePendSell ) + ";";
				for (int i = 0; i < ArraySize( CumulativeSell ); i++) {
					Implode = StringConcatenate( Implode, IntegerToString( CumulativeSell[i].opened ), ";" );
					ObjectDelete( 0, "PendSell" + IntegerToString( i ) );
					delete CumulativeSell[i];
				}
				ArrayResize( CumulativeSell, 0 );
				if( ObjectFind( 0, "CumulativeSell" ) < 0 ) ObjectCreate( 0, "CumulativeSell", OBJ_TEXT, 0, 0, 0 );
				ObjectSetText( "CumulativeSell", Implode );
			}
		break;
	}

	if( ArraySize( CumulativeBuy ) > 0 ) {
		for (int i = 0; i < ArraySize( CumulativeBuy ); i++) {
			ObjectDelete( 0, "PendBuy" + IntegerToString( i ) );
			delete CumulativeBuy[i];
		}
		ArrayResize( CumulativeBuy, 0 );
	}
	if( ArraySize( CumulativeSell ) > 0 ) {
		for (int i = 0; i < ArraySize( CumulativeSell ); i++) {
			ObjectDelete( 0, "PendSell" + IntegerToString( i ) );
			delete CumulativeSell[i];
		}
		ArrayResize( CumulativeSell, 0 );
	}

	for( int i = 0; i < 7; i++ ) {
		ObjectDelete( 0, "Jail_EA_" + IntegerToString( i ) );
	}
	ObjectDelete( 0, "EAActive" );
	ObjectDelete( 0, "PendBuy" );
	ObjectDelete( 0, "PendBuyT" );
	ObjectDelete( 0, "RangeBuy" );
	ObjectDelete( 0, "RangePendBuy" );
	ObjectDelete( 0, "PendSell" );
	ObjectDelete( 0, "PendSellT" );
	ObjectDelete( 0, "RangeSell" );
	ObjectDelete( 0, "RangePendSell" );

	ObjectDelete( 0, "PendBuySL" );
	ObjectDelete( 0, "PendBuySLT" );
	ObjectDelete( 0, "PendBuyTP" );
	ObjectDelete( 0, "PendBuyTPT" );
	ObjectDelete( 0, "PendSellSL" );
	ObjectDelete( 0, "PendSellSLT" );
	ObjectDelete( 0, "PendSellTP" );
	ObjectDelete( 0, "PendSellTPT" );

	RangeBuy = RangeSell = false;
	RangePendBuy = RangePendSell = 0;

}

void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam ) {
	if( id == CHARTEVENT_OBJECT_CLICK ) {
		string clickedChartObject = sparam;
		if( clickedChartObject == "EAActive" ) {
			Activate_EA = (ActivateEA)(1 - Activate_EA);
			if( Activate_EA == 0 ) {
				ObjectSetString( 0, "EAActive", OBJPROP_TEXT, "OFF" );
				ObjectSetInteger( 0, "EAActive", OBJPROP_BGCOLOR, ColorRangeButton );
			} else {
				ObjectSetString( 0, "EAActive", OBJPROP_TEXT, "ON" );
				ObjectSetInteger( 0, "EAActive", OBJPROP_BGCOLOR, ColorRangeButtonActive );
				tradeTime = 0; // Reset timer trade and allow instant trade
			}
		}
		if( clickedChartObject == "RangeBuy" ) {
			RangeBuy = 1 - RangeBuy;
			if( RangeBuy == true ) {
				RangePendBuy = PendBuy + DefaultRangeBuyPips * tradeDifference * Point;
				CalculateRangeTrades( OP_BUY );
			} else {
				for( int i = 0; i < ArraySize( CumulativeBuy ); i++ ) {
					ObjectDelete( 0, "PendBuy" + IntegerToString( i ) );
					ObjectDelete( 0, "PendBuyT" + IntegerToString( i ) );
					delete CumulativeBuy[i];
				}
				ArrayResize( CumulativeBuy, 0 );
				RangePendBuy = 0;
			}
		}
		if( clickedChartObject == "RangeSell" ) {
			RangeSell = 1 - RangeSell;
			if( RangeSell == true ) {
				RangePendSell = PendSell - DefaultRangeSellPips * tradeDifference * Point;
				CalculateRangeTrades( OP_SELL );
			} else {
				for( int i = 0; i < ArraySize( CumulativeSell ); i++ ) {
					ObjectDelete( 0, "PendSell" + IntegerToString( i ) );
					ObjectDelete( 0, "PendSellT" + IntegerToString( i ) );
					delete CumulativeSell[i];
				}
				ArrayResize( CumulativeSell, 0 );
				RangePendSell = 0;
			}
		}
	}
}

void start() {
      // код доступен только после оплаты
   }

void CumulativeTradeOpen( int trend ) {

	double Spread = MarketInfo( NULL, MODE_SPREAD );
	if( ( Spread / tradeDifference ) > MaxSpread ) return;

	if( trend == OP_BUY ) {

		int _noBA = NoBuyAttempts - 1; if( _noBA < 1 ) _noBA = 1;
		double _diff = MathAbs( PendBuy - RangePendBuy ) / _noBA / 2;
		for( int i = 0; i < ArraySize( CumulativeBuy ); i++ ) {
			if( CumulativeBuy[i].opened == 0 ) {
				if( CumulativeBuy[i].type == OP_SELL ) {
					if( Ask <= CumulativeBuy[i].price ) {
						if( Ask <= ( CumulativeBuy[i].price - _diff ) ) {
							CumulativeBuy[i].opened = 1;
							return;
						}
						if( TicketType( OP_BUY ) < NoBuyAttempts ) {
							tradeTime = TimeCurrent() + 1;
							int res = OrderSend( Symbol(), OP_BUY, LotSize, Ask, Slippage, 0, 0, CommentBuy, MagicNumber, 0, Blue );
							if( res == -1 ) printf( "Error opening trade: %u", GetLastError() );
						}
						CumulativeBuy[i].opened = 1;
					}
				} else {
					if( i == ArraySize( CumulativeBuy ) / 2 && TicketType( OP_BUY ) > 0 ) {
						CumulativeBuy[i].opened = 1;
						return;
					}
					if( Ask >= CumulativeBuy[i].price ) {
						if( Ask >= ( CumulativeBuy[i].price + _diff ) ) {
							CumulativeBuy[i].opened = 1;
							return;
						}
						if( TicketType( OP_BUY ) < NoBuyAttempts ) {
							tradeTime = TimeCurrent() + 1;
							int res = OrderSend( Symbol(), OP_BUY, LotSize, Ask, Slippage, 0, 0, CommentBuy, MagicNumber, 0, Blue );
							if( res == -1 ) printf( "Error opening trade: %u", GetLastError() );
						}
						CumulativeBuy[i].opened = 1;
					}
				}
				return;
			}
		}
	} else {

		int _noSA = NoSellAttempts - 1; if( _noSA < 1 ) _noSA = 1;
		double _diff = MathAbs( PendSell - RangePendSell ) / _noSA / 2;
		for( int i = 0; i < ArraySize( CumulativeSell ); i++ ) {
			if( CumulativeSell[i].opened == 0 && TicketType( OP_SELL ) < NoSellAttempts ) {
				if( CumulativeSell[i].type == OP_BUY ) {
					if( Bid >= CumulativeSell[i].price ) {
						if( Bid >= ( CumulativeSell[i].price + _diff ) ) {
							CumulativeSell[i].opened = 1;
							return;
						}
						if( TicketType( OP_SELL ) < NoSellAttempts ) {
							tradeTime = TimeCurrent() + 1;
							int res = OrderSend( Symbol(), OP_SELL, LotSize, Bid, Slippage, 0, 0, CommentSell, MagicNumber, 0, Red );
							if( res == -1 ) printf( "Error opening trade: %u", GetLastError() );
						}
						CumulativeSell[i].opened = 1;
					}
				} else {
					if( i == ArraySize( CumulativeSell ) / 2 && TicketType( OP_SELL ) > 0 ) {
						CumulativeSell[i].opened = 1;
						return;
					}
					if( Bid <= CumulativeSell[i].price ) {
						if( Bid <= ( CumulativeSell[i].price - _diff ) ) {
							CumulativeSell[i].opened = 1;
							return;
						}
						if( TicketType( OP_SELL ) < NoSellAttempts ) {
							tradeTime = TimeCurrent() + 1;
							int res = OrderSend( Symbol(), OP_SELL, LotSize, Bid, Slippage, 0, 0, CommentSell, MagicNumber, 0, Red );
							if( res == -1 ) printf( "Error opening trade: %u", GetLastError() );
						}
						CumulativeSell[i].opened = 1;
					}
				}
				return;
			}
		}
	}
}

void OnTimer() {
	Visuals();
}

void ActiveTrades() {

	if( tradeSecond == TimeCurrent() ) return;
	tradeSecond = TimeCurrent();

	for( int i = 0; i < OrdersTotal(); i++ ) {
		if( OrderSelect( i, SELECT_BY_POS ) ) {
			if( OrderSymbol() == Symbol() && MagicNumber == OrderMagicNumber() ) {
				int _trade = TradeId( OrderTicket() );
				if( _trade == -1 ) {
					Trades* pTrade = new Trades;
					pTrade.tradeID = OrderTicket();
					pTrade.tradeType = OrderType();
					pTrade.tradeComment = OrderComment();
					pTrade.tradeLotSize = OrderLots();
					pTrade.tradePrice = OrderOpenPrice();
					int sz = ArraySize( UserTrades );
					ArrayResize( UserTrades, sz + 1 );
					UserTrades[sz] = pTrade;
					if( OrderType() == OP_BUY )
						if( BreakEvenBuyPips > 0 ) VerifyBreakEven( OrderOpenTime(), OrderType() );
					else
						if( BreakEvenSellPips > 0 ) VerifyBreakEven( OrderOpenTime(), OrderType() );
				}
			}
		}
	}

	for( int i = 0; i < ArraySize( UserTrades ); i++ ) {
		if( UserTrades[i].tradeClosed == false ) {

			if( TicketId( UserTrades[i].tradeID ) == 0 ) {
				UserTrades[i].tradeClosed = true;
				return;
			}

			if( UserTrades[i].tradeType == OP_BUY ) {

				if( BreakEvenBuyPips > 0 && BreakEvenBuy == false ) {
					if( Bid > UserTrades[i].tradePrice + BreakEvenBuyPips * Point * tradeDifference ) {
						BreakEvenBuy = true;
					}
				}
				/*---- Close at break even, this has been detached to seperate function
				if( BreakEvenBuy == true ) {
					if( Bid <= UserTrades[i].tradePrice + SlippageTrade * Point * tradeDifference ) {
						if( !OrderClose( UserTrades[i].tradeID, UserTrades[i].tradeLotSize, Bid, Slippage, Blue ) ) Print( "OrderClose error ", GetLastError() );
					}
				}*/

				if( StopLossBuyPips > 0 && Bid < PendBuy - StopLossBuyPips * Point * tradeDifference ) {
					if( !OrderClose( UserTrades[i].tradeID, UserTrades[i].tradeLotSize, Bid, Slippage, Blue ) ) Print( "OrderClose error ", GetLastError() );
				}

				if( RangeBuy == true ) {
					if( TakeProfitBuyPips > 0 && RangePendBuy > 0 && Bid > RangePendBuy + TakeProfitBuyPips * Point * tradeDifference ) {
						if( !OrderClose( UserTrades[i].tradeID, UserTrades[i].tradeLotSize, Bid, Slippage, Blue ) ) Print( "OrderClose error ", GetLastError() );
						RangeBuy = false;
					}
				} else {
					if( TakeProfitBuyPips > 0 && Bid > PendBuy + TakeProfitBuyPips * Point * tradeDifference ) {
						if( !OrderClose( UserTrades[i].tradeID, UserTrades[i].tradeLotSize, Bid, Slippage, Blue ) ) Print( "OrderClose error ", GetLastError() );
						RangeBuy = false;
					}
				}
			}

			if( UserTrades[i].tradeType == OP_SELL ) {

				if( BreakEvenSellPips > 0 && BreakEvenSell == false ) {
					if( Ask < UserTrades[i].tradePrice - BreakEvenSellPips * Point * tradeDifference ) {
						BreakEvenSell = true;
					}
				}
				/*---- Close at break even, this has been detached to seperate function
				if( BreakEvenSell == true ) {
					if( Ask >= UserTrades[i].tradePrice - SlippageTrade * Point * tradeDifference ) {
						if( !OrderClose( UserTrades[i].tradeID, UserTrades[i].tradeLotSize, Ask, Slippage, Red ) ) Print( "OrderClose error ", GetLastError() );
					}
				}*/

				if( StopLossSellPips > 0 && Ask > PendSell + StopLossSellPips * Point * tradeDifference ) {
					if( !OrderClose( UserTrades[i].tradeID, UserTrades[i].tradeLotSize, Ask, Slippage, Red ) ) Print( "OrderClose error ", GetLastError() );
				}

				if( RangeSell == true ) {
					if( TakeProfitSellPips > 0 && RangePendSell > 0 && Ask < RangePendSell - TakeProfitSellPips * Point * tradeDifference ) {
						if( !OrderClose( UserTrades[i].tradeID, UserTrades[i].tradeLotSize, Ask, Slippage, Red ) ) Print( "OrderClose error ", GetLastError() );
						RangeSell = false;
					}
				} else {
					if( TakeProfitSellPips > 0 && Ask < PendSell - TakeProfitSellPips * Point * tradeDifference ) {
						if( !OrderClose( UserTrades[i].tradeID, UserTrades[i].tradeLotSize, Ask, Slippage, Red ) ) Print( "OrderClose error ", GetLastError() );
						RangeSell = false;
					}
				}
			}
		}
	}

	if( ArraySize( UserTrades ) > 0 ) TradesBreakEven();

	if( BreakEvenBuy == true && TicketType( OP_BUY ) == 0 ) BreakEvenBuy = false;
	if( BreakEvenSell == true && TicketType( OP_SELL ) == 0 ) BreakEvenSell = false;

	DeleteArray();
}

void TradesBreakEven() {
	if( BreakEvenBuy == true ) {

		int count = 0;
		double breakeven = 0;
		for( int i = 0; i < OrdersTotal(); i++ ) {
			if( OrderSelect( i, SELECT_BY_POS ) ) {
				if( OrderSymbol() == Symbol() && MagicNumber == OrderMagicNumber() && OrderType() == OP_BUY ) {
					breakeven += OrderOpenPrice();
					count++;
				}
			}
		}
		if( count == 0 ) return; // Prevents divide by 0 error
		breakeven /= count;

		if( ObjectFind( "BreakEvenBuy" ) < 0 ) {
			ObjectCreate( 0, "BreakEvenBuy", OBJ_TREND, 0, Time[3], breakeven + SlippageTrade * Point * tradeDifference, ( Time[0] + 3 * 60 * Period() ), breakeven + SlippageTrade * Point * tradeDifference );
			ObjectSetInteger( 0, "BreakEvenBuy", OBJPROP_COLOR, ColorBreakEven );
			ObjectSetInteger( 0, "BreakEvenBuy", OBJPROP_STYLE, STYLE_SOLID );
			ObjectSetInteger( 0, "BreakEvenBuy", OBJPROP_WIDTH, 1 );
			ObjectSetInteger( 0, "BreakEvenBuy", OBJPROP_RAY_RIGHT, 0 );
		}
		ObjectMove( "BreakEvenBuy", 0, Time[3], breakeven + SlippageTrade * Point * tradeDifference );
		ObjectMove( "BreakEvenBuy", 1, ( Time[0] + 3 * 60 * Period() ), breakeven + SlippageTrade * Point * tradeDifference );

		if( Bid < breakeven + SlippageTrade * Point * tradeDifference ) {
			for( int i = 0; i < OrdersTotal(); i++ ) {
				if( OrderSelect( i, SELECT_BY_POS ) ) {
					if( OrderSymbol() == Symbol() && MagicNumber == OrderMagicNumber() && OrderType() == OP_BUY ) {
						if( !OrderClose( OrderTicket(), OrderLots(), Bid, Slippage, Blue ) ) Print( "OrderClose error ", GetLastError() );
					}
				}
			}
			ObjectDelete( 0, "BreakEvenBuy" );
		}
	}
	if( BreakEvenSell == true ) {

		int count = 0;
		double breakeven = 0;
		for( int i = 0; i < OrdersTotal(); i++ ) {
			if( OrderSelect( i

Показано первые 50% кода (символов: 31813)

Открыть по тарифу

Купите тариф с пакетом открытий или войдите, если тариф уже есть. Открытый файл останется в вашем кабинете навсегда.

Разовая покупка файла

На этой странице откроется полный исходный код файла вместо ознакомительного фрагмента.

Чтобы оформить заказ, введите email и перейдите к оплате.

Стоимость полного кода
3 181,30₽ ≈ $38.89