This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Calculates the position size of the trade based upon entry price, stop loss & amount risked. | |
* @param entryPrice double Entry price of the order | |
* @param iniStop double Initial stop loss of the order | |
* @param riskAmt double Risk per trade (in dollars of account's currency) | |
* | |
* @return amount in mini-lots | |
*/ | |
double getLots( double entryPrice, double iniStop, double riskAmt ) { | |
string sym = Symbol(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Get the price of the Stop Loss according to last swing price. | |
* @param sym string Symbol of currency being analysed | |
* @param TF int TimeFrame of the currency being analysed | |
* @param ord int OrderType() = OP_BUYLIMIT, OP_BUYSTOP, OP_SELLLIMIT, OP_SELLSTOP | |
* @param entry double Entry price of the order | |
* @return double Last swing point | |
*/ | |
double getLastSwingPrice(string sym, int TF, int ord, double entry) { | |
int bars = iBars(sym,TF); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this procedure checks all manually placed orders | |
void checkManualOrders() { | |
for ( int i = 0; i < OrdersTotal(); i++ ) { | |
if ( OrderSelect(i, SELECT_BY_POS, MODE_TRADES) ) { | |
// the assumption will be that new manually placed pending orders have a MagicNumber of 0 | |
// check with your MT4 broker that they allow MagicNumbers, some brokers do NOT! | |
// if your broker doesn't then you'll have to remove "OrderMagicNumer() == 0 &&" | |
if ( OrderMagicNumber() == 0 && OrderCloseTime() == 0 ) { | |
if ( OP_BUYLIMIT || OP_BUYSTOP || OP_SELLLIMIT || OP_SELLSTOP ) { | |
// okay you're now here on an active PENDING order, what do you want to do? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//+------------------------------------------------------------------+ | |
//| My Money Management.mq4 | | |
//| Ryan Sheehy, CurrencySecrets.com | | |
//| http://www.currencysecrets.com | | |
//+------------------------------------------------------------------+ | |
#property copyright "Ryan Sheehy, CurrencySecrets.com" | |
#property link "http://www.currencysecrets.com" | |
//--- input parameters | |
extern double xRiskPerTrade=1; // $ amount of risked per trade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//+------------------------------------------------------------------+ | |
//| Automated Trend Lines.mq4 | | |
//| Ryan Sheehy, CurrencySecrets.com | | |
//| http://www.currencysecrets.com | | |
//+------------------------------------------------------------------+ | |
#property copyright "Ryan Sheehy, CurrencySecrets.com" | |
#property link "http://www.currencysecrets.com" | |
/* | |
* This script automates the generation and plotting of sloping trend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//+------------------------------------------------------------------+ | |
//| EoFY.mq4 | | |
//| Ryan Sheehy, RobotTradingForex.com | | |
//| https://robottradingforex.com | | |
/* | |
* DON'T FORGET TO SELECT "ALL HISTORY" FROM ACCOUNT HISTORY TAB!!! | |
* This script helps to calculate a summarised version of all trades | |
* done in a particular financial year. It converts all sales and | |
* purchase transactions into the base currency. | |
* 1. Loop through all HISTORICAL trades between a predetermined date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//+------------------------------------------------------------------+ | |
//| Trades Analysis.mq4 | | |
//| Ryan Sheehy, CurrencySecrets.com | | |
//| http://www.currencysecrets.com | | |
//+------------------------------------------------------------------+ | |
#property copyright "Ryan Sheehy, CurrencySecrets.com" | |
#property link "http://www.currencysecrets.com" | |
/* | |
* With this script we will be running through all trades that have |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This method calculates the profit or loss of a position in the home currency of the account | |
* @param string sym | |
* @param int type 0 = buy, 1 = sell | |
* @param double entry | |
* @param double exit | |
* @param double lots | |
* @result double profit/loss in home currency | |
*/ | |
double calcPL(string sym, int type, double entry, double exit, double lots) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//+------------------------------------------------------------------+ | |
//| Breakout Strategy Tester.mq4 | | |
//| Copyright 2012, MetaQuotes Software Corp. | | |
//| http://www.metaquotes.net | | |
//+------------------------------------------------------------------+ | |
// | |
// With this script we will be doing the following: | |
// 1. Get all the trades (be wary of reversal trades!) | |
// 2. | |
#property copyright "Copyright 2012, MetaQuotes Software Corp." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* clearIntArray | |
* This function deletes all items in array (sets it to 0) and resizes array according to size (default = 1). | |
* @param int& theArray - passing the array by reference | |
* @param int size - size of the array (default = 1) | |
* @return int blank array of size | |
*/ | |
int clearIntArray( int& theArray[], int size = 0 ) { | |
ArrayResize( theArray, size ); | |
if ( size > 0 ) { ArrayInitialize( theArray, 0 ); } |
OlderNewer