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
//+------------------------------------------------------------------+ | |
//| 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
//+------------------------------------------------------------------+ | |
//| Period_Converter.mq4 | | |
//| Copyright © 2005-2007, MetaQuotes Software Corp. | | |
//| http://www.metaquotes.net | | |
//+------------------------------------------------------------------+ | |
#property copyright "Copyright © 2007, MetaQuotes Software Corp." | |
#property link "http://www.metaquotes.net" | |
#property show_inputs | |
#include <WinUser32.mqh> |
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
//+------------------------------------------------------------------+ | |
//| CS Auto Trend Lines (Offline).mq4 | | |
//| Ryan Sheehy | | |
//| http://www.currencysecrets.com | | |
//| Version: 1.0 | | |
//| Released: 12 Jan 13 | | |
//+------------------------------------------------------------------+ | |
#property copyright "Ryan Sheehy" | |
#property link "http://www.currencysecrets.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
/* | |
* checkOpenTrades | |
* This function checks open trades and compares them to risk levels. | |
* @param sym | |
* @return int -1 = error | |
*/ | |
int checkOpenTrades( string sym ) { | |
int type, revType, tradeReady, tkt, dir; | |
double p, revP, profit, trailingStop; | |
for ( int i = 0; i < OrdersTotal(); i++ ) { |
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
int getOpenBar( string sym, datetime openTime ) { | |
// each bar has the opening time at the start of the bar | |
// eg if openTime is 12:01PM we will know at 4:00PM (when the | |
// bar is greater than the opening time of trade) | |
for ( int i = 0; i < Bars; i++ ) { | |
if ( openTime >= Time[i] ) { | |
return( i ); | |
} | |
} | |
} |
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 returns the spread of the currency in double form | |
double getSpread( string sym ) { | |
return( MarketInfo( sym, MODE_SPREAD ) * MarketInfo( sym, MODE_POINT ) ); | |
} |
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 provides a boilerplate type template for sending email alerts about your MetaTrader code. | |
// param subject (optional) => Usually a short description of what the email is alerting you about | |
// param body (optional) => As the email already contains many bits of information I just use the body for detailing a reason | |
// param systemTag (optional) => The name/tag of your expert advisor | |
// | |
// Example usage within my EA: | |
// alertMe( "CLOSE long order failed", "Reason: Closing a pending buystop order in function XYZ has failed", "My Sys (v1.0)" ); | |
void alertMe( string subject = "", string body = "", string systemTag = "" ) { | |
SendMail( subject + " " + Symbol() + " " + systemTag , |
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 removeOldOrders( string sym, string systemTag ) { | |
int tot = OrdersTotal(); | |
for( int i = 0; i < tot; i++ ) { | |
if ( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) ) { | |
if ( OrderSymbol() == sym ) { | |
if ( OrderType() != OP_BUY || OrderType() != OP_SELL ) { | |
if ( OrderComment() != systemTag ) { // don't forget your new order must contain the systemTag! | |
OrderDelete( OrderTicket() ); | |
} | |
} |
OlderNewer