Description

Top-quality MetaTrader 4 library with different functions to support you with improving your returns. All functions were tested thoroughly and optimized for minimal speed and latency.

Calculate orders profit based on type:

double LongOrdersProfit(string argSymbol) export
double ShortOrdersProfit(string argSymbol) export

Close orders based on a specific condition:
bool CloseOrder(int argOrder) export

bool CloseOrder(int argOrder,double argLotSize) export
bool CloseLongOrders(string argSymbol) export
bool CloseShortOrders(string argSymbol) export
bool ClosePendingOrder(int argOrder) export
bool CloseAllPendingOrders() export
bool CloseAllProfitingOrders(string argSymbol) export
bool CloseAllLosingOrders() export
bool CloseAllOrders(int argMagicNumber) export
bool CloseAllOrders(string argSymbol) export
bool CloseAllOrders() export

Verify the lot size is valid for this symbol:
double VerifyLotSize(string argSymbol,double argLotSize) export

Calculate lot size based on risk parameters such as the equity percentage you want to use for this order and the volatility for this period:
double CalcRiskBasedLotSize(string argSymbol,double argPercentageRiskPerOrder,int argTimeframe,int argSTDFactor,int argSTDPeriod) export

Calculate the P&L for today based on the closed historical orders:
double DailyProfitAndLoss() export

Confirm there is enough margin in the account prior to opening an order:
bool ConfirmEnoughMargin(string argSymbol,int argOrderType,double argLotSize) export

Open order function, return code can be -1 for a failure or the ticket ID:

int OpenOrder(string argSymbol,int argOrderType,double argLotSize,double argSL=0,double argTP=0,string argComment=NULL,int argMagicNumber=0,int argSpread=0) export
int OpenStopOrder(string argSymbol,int argStopOrderType,double argLotSize,double argPendingPrice,double argSLPoints=0,double argTPPoints=0,string argComment=NULL,int argMagicNumber=0) export

Calculate profit / loss for the open positions:
double AccountProfitAdj(string argSymbol=””) export

double AccountLossAdj(string argSymbol=””) export

Update stop loss / take profit for a specific order:
bool AddStopProfit(int argOrder,double argStopLoss,double argTakeProfit) export

Count open orders based on type:
void CountOpenOrders(int &argResult[],string argSymbol) export

Print the un-initialization message on adviser exit:
string GetUninitReasonText(int reasonCode) export

Close all open charts:
void CloseAllCharts(string argProductsExclude=””) export

Initialize a specific product with an existing template (i.e. expert adviser):
long InitializeProduct(string argTemplate,string argProduct,int argargTimeFrame) export

Formatted logging functions:
void LogError(string argSymbol,double argOrderLots,string argMessage,int argErrorCode=0,bool argSilent=false) export

void Log(string argMessage,bool argSilent=false) export

Generate magic number based on the product name:
int GenerateMagicNumber(string argInput) export

Quick sort an array:
void QuickSort(string &arr[],int beg,int end) export

Retry closing tickets which failed to close:
void RetryClosingTickets(string &TicketsString) export

Usage

To use this library, place it in the libraries folder, compile and import the function you want to use in the expert adviser / indicator. For example, to use the close all charts function, use the following statement at the beginning of the file:

#import “Common.ex4”
void CloseAllCharts(string argProductsExclude=””);
#import
And then calling the function –
CloseAllCharts();

Download

This entry was posted by . Bookmark the . Titled

Leave a Reply

Your email address will not be published. Required fields are marked *