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 Automated Trading EA.mq4 | |
//| Copyright 2013, Ryan Sheehy | |
//| http://www.currencysecrets.com | |
//+------------------------------------------------------------------+ | |
#property copyright "Copyright 2013, Ryan Sheehy" | |
#property link "http://www.currencysecrets.com" | |
//--- input parameters |
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
void flushArray( int& arr[] ) { | |
ArrayInitialize( arr, 0 ); | |
ArrayResize( arr, 0 ); | |
} | |
// append new element to end of int array | |
void intArrayPush( int& arr[], int elem ) { | |
int size = ArraySize( arr ); | |
ArrayResize( arr, size + 1 ); | |
arr[ size ] = elem; |
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
//+------------------------------------------------------------------+ | |
//| Copyright © 2009 MTIntelligence.com | | |
//| http://www.mtintelligence.com | | |
//+------------------------------------------------------------------+ | |
#property copyright "Copyright © 2009 MTIntelligence.com" | |
#property link "http://www.mtintelligence.com" | |
// ************************************************************************************* | |
// |
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
string VERSION = "TL BO 1.0"; | |
// external global variables | |
extern int EXT_SWINGS = 2; // swing level, 0 is lowest, 2 is most common | |
extern int EXT_NO_SWING_LMT = 12; // don't consider the latest X bars as swing points to draw trend lines | |
extern int EXT_ATR = 300; // ATR(x) | |
extern double EXT_ATR_MAX_SLOPE = 0.05; // multiple of ATR that would be considered maximum slope | |
extern double EXT_ATR_BUFFER = 0.05; // multiple of ATR to add to low/high for it to be considered a "touch" | |
extern int EXT_NULL_CLOSES = 0; // number of closes beyond trend line to nullify it as a valid trend line | |
extern int EXT_NUM_TOUCHES = 3; // (inclusive) number of touches needed to be considered a valid trend line |
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 function exits at market, but needs the following params: | |
// sym = currency symbol | |
// tkt = trades' ticket number | |
// lots = trades' lot size | |
// p = price to exit at | |
bool exitNow( string sym, int tkt, double lots, double p ) { | |
// check if it's okay to exit trade | |
int trade = checkIsTradeAllowed(); | |
// place trade if ok to place order | |
if ( trade > 0 ) { |
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
string VERSION = "TL BO 1.0"; | |
extern int EXT_ATR = 300; // ATR(x) | |
extern double EXT_ATR_INI_STOP = 0.1; // additional buffer to add beyond the initial stop | |
extern int EXT_LOOKBACK = 3; // number of bars to find highest high/lowest low | |
extern double EXT_RISK_MINAMT = 50; // dollar value of the minimum amount to risk per trade | |
extern double EXT_RISK_DIVISOR = 10; // AccountBalance/X = risk per trade | |
extern int EXT_MAX_SLIP = 10; // maximum points of slippage allowed for order 10 = 1 pip | |
extern double EXT_ATR_TRAILSTOP = 2; // multiple for trailing the market ATR(EXT_ATR) * X |
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 function requires the following parameters: | |
// sym = currency | |
// op = opening price of the current trade | |
// sl = stop loss price of the current trade | |
// ot = opening datetime of the current trade | |
// per = active chart's period - for calculating ATR distance properly | |
// type = order type of the current trade | |
double getTrailingStop( string sym, double op, double sl, datetime ot, int per, int type ) { | |
double temp; | |
// make the result for this function initially equal the stop loss |
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
string VERSION = "TL BO 1.0"; | |
extern int EXT_ATR = 300; // ATR(x) | |
extern double EXT_ATR_INI_STOP = 0.1; // additional buffer to add beyond the initial stop | |
extern int EXT_LOOKBACK = 3; // number of bars to find highest high/lowest low | |
extern double EXT_RISK_MINAMT = 50; // dollar value of the minimum amount to risk per trade | |
extern double EXT_RISK_DIVISOR = 10; // AccountBalance/X = risk per trade | |
extern int EXT_MAX_SLIP = 10; // maximum points of slippage allowed for order 10 = 1 pip | |
// global variables |
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
extern int EXT_SWINGS = 2; // swing level, 0 is lowest, 2 is most common | |
extern int EXT_NO_SWING_LMT = 12; // don't consider the latest X bars as swing points to draw trend lines | |
extern int EXT_ATR = 300; // ATR(x) | |
extern double EXT_ATR_MAX_SLOPE = 0.05; // multiple of ATR that would be considered maximum slope | |
extern double EXT_ATR_BUFFER = 0.05; // multiple of ATR to add to low/high for it to be considered a "touch" | |
extern int EXT_NUM_CONSEC_CLOSES = 4; // number of consecutive closes beyond trend line to break | |
extern int EXT_NUM_TOUCHES = 3; // (inclusive) number of touches needed to be considered a valid trend line | |
extern int EXT_RES_COLOR = IndianRed; // horizontal resistance line http://docs.mql4.com/constants/colors | |
extern int EXT_SUP_COLOR = PaleGreen; // horizontal support line http://docs.mql4.com/constants/colors | |
extern int EXT_SLOPE_RES_COLOR = LightSalmon; // sloping resistance line http://docs.mql4.com/constants/colors |
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
extern int EXT_METRIC = 30; // bars for metric | |
extern int EXT_METRIC_MIN = 1; // minimum metric value needed for each individual currency | |
// this function returns the active currencies "strength" value | |
// it displays the strength value on the active chart's upper left portion of the screen (using Comment function) | |
double getTrend() { | |
// get the active chart's symbol | |
string sym = Symbol(); |
NewerOlder