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
double EXT_RISK_DIV = 10; | |
double EXT_RISK_MINAMT = 50; | |
double riskAmt = MathMax( getCashBalance() / EXT_RISK_DIV, EXT_RISK_MINAMT ); | |
// this function returns the actual cash balance of all positions if they were to close now | |
double getCashBalance() { | |
return( AccountBalance() + getOpenPL() ); | |
} | |
// this function will calculate the total profit/loss of all open positions if all stops are hit | |
double getOpenPL() { | |
int tot = OrdersTotal(); |
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 double EXT_RISK_MINAMT = 50; // minimal amount of money to risk per trade | |
extern int EXT_RISK_MULT = 15; // maximum number of consecutive losses needed to wipeout account | |
// calculates the amount of money to risk per trade | |
double getRiskAmount() { | |
return( MathMax( EXT_RISK_MINAMT, ( AccountBalance() + getStopPL() ) / EXT_RISK_MULT ) ); | |
} | |
// this function returns the profit/loss if the stop is hit | |
double profitAtStop( string sym, double open, double stop, double lots, int type ) { |
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
EnableScript("JScript"); | |
<% | |
function getArrayLength( a ) { | |
x = VBArray( a ).toArray(); | |
for ( y = 0; y < x.length; y += 1 ) { | |
if ( x[y] == undefined ) break; | |
} | |
return y; | |
} |
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
EnableScript("JScript"); | |
<% | |
function getArrayLength( a ) { | |
x = VBArray( a ).toArray(); | |
for ( y = 0; y < x.length; y += 1 ) { | |
if ( x[y] == undefined ) break; | |
} | |
return y; | |
} |
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
EnableScript("JScript"); | |
<% | |
function importForexQuotes() { | |
var files = [ | |
"Z:\\Dropbox\\DATA\\OANDA\\D1\\AUDCAD.csv", | |
"Z:\\Dropbox\\DATA\\OANDA\\D1\\AUDCHF.csv", | |
"Z:\\Dropbox\\DATA\\OANDA\\D1\\AUDJPY.csv", |
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
//+------------------------------------------------------------------+ | |
//| Example of using WinFile.mqh for reading/writing files | | |
//| anywhere on the hard disk. WinFile.mqh needs to be present | | |
//| in the experts\include directory, and "Allow DLL imports" | | |
//| needs to be turned on. | | |
//+------------------------------------------------------------------+ | |
#include <WinFile.mqh> | |
#property copyright "Copyright © 2013 Currency Secrets.com" | |
#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
/* | |
* Name: Automatic Trend Lines | |
* This Amibroker script is designed to automate the process of drawing: | |
* 1. Trend lines (sloping) | |
* 2. Support & resistance lines (horizontal) | |
* 3. Channel lines (parallel lines to trend lines & horizontal lines) | |
* This script is not a recommendation to buy or sell anything. It's to be | |
* used as is without any guarantees or warranties on its reliability. | |
* Author: Ryan Sheehy | |
* Version: v2.0.2 (20160816) |
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
//+------------------------------------------------------------------+ | |
//| MetaTrader EA Framework.mq4 | |
//| Copyright 2013, Ryan Sheehy | |
//| http://www.currencysecrets.com | |
//+------------------------------------------------------------------+ | |
#property copyright "Copyright 2013, Ryan Sheehy" | |
#property link "http://www.currencysecrets.com" | |
//--- global variables (keep capitalised) | |
string VERSION = "1.0.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
int getWeeklyTrend( string sym ) { | |
int per = PERIOD_W1, | |
b = iBars( sym, per ) - 3, | |
isLong, pk0, pk1, pk2, tr0, tr1, tr2, i; | |
for ( i = b; i > 0; i -= 1 ) { | |
if ( isLong <= 0 ) { | |
if ( tr1 > 0 && iHigh( sym, per, i ) > iHigh( sym, per, pk0 ) && iLow( sym, per, tr0 ) > iLow( sym, per, tr1 ) ) { | |
isLong = i; | |
} else if ( iHigh( sym, per, i ) > iHigh( sym, per, pk0 ) ) { | |
isLong = 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
double trendStrength( int b = 52, int per = 0, string sym = "" ) { | |
if ( sym == "" ) { sym = Symbol(); } | |
if ( b * 2 < iBars( sym, per ) ) { b = MathFloor( iBars( sym, per ) * 0.5 ); } | |
double maDiff = iMA( sym, per, b, 0, MODE_SMA, PRICE_CLOSE, 0 ) - iMA( sym, per, b, 0, MODE_SMA, PRICE_CLOSE, b ); | |
double strVal = maDiff / iATR( sym, per, b, 0 ); | |
double result = strVal * MarketInfo( sym, MODE_TICKVALUE ); | |
return ( result ); | |
} |