This file contains hidden or 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 adxIndicator = AdxIndicator(20, 14, 0); | |
int AdxIndicator(int adxThreshold, int period, int shift) { | |
double adx = iADX(Symbol(),PERIOD_CURRENT,period,PRICE_TYPICAL,MODE_MAIN,shift); | |
//double adxDiPlus = iADX(Symbol(),PERIOD_CURRENT,period,PRICE_TYPICAL,MODE_PLUSDI,shift); | |
//double adxDiMinus = iADX(Symbol(),PERIOD_CURRENT,period,PRICE_TYPICAL,MODE_MINUSDI,shift); | |
int output = 0; | |
This file contains hidden or 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
// Gets the range (highest minus lowest) of price for the last 5 bars | |
// double currentRange = CalculateCurrentRange(5); | |
double CalculateCurrentRange(int howManyBars){ | |
double highVal; | |
double lowVal; | |
int highVal_index=iHighest(NULL,0,MODE_HIGH,howManyBars,0); | |
int lowVal_index=iLowest(NULL,0,MODE_LOW,howManyBars,0); | |
This file contains hidden or 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 result = OpenBuyOrder(0.01, 0.00300, 0.0900); | |
int OpenBuyOrder(double lots, double stopLossPips, double pipsProfit){ | |
double takeProfit = NormalizeDouble(Ask + pipsProfit, Digits); | |
double stopLoss =NormalizeDouble(Ask - stopLossPips, Digits); | |
return OrderSend(Symbol(),OP_BUY,lots,Ask,3,stopLoss,takeProfit,"",MAGICMA,0,clrPurple); | |
} |
This file contains hidden or 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 result = OpenSellOrder(0.01, 0.00300, 0.00900); | |
int OpenSellOrder(double lots, double stopLossPips, double pipsProfit){ | |
double takeProfit = NormalizeDouble(Bid - pipsProfit, Digits); | |
double stopLoss = NormalizeDouble(Bid + stopLossPips, Digits); | |
return OrderSend(Symbol(),OP_SELL,lots,Bid,3,stopLoss,takeProfit,"",MAGICMA,0,clrPink); | |
} |
This file contains hidden or 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
// select the order http://docs.mql4.com/trading/orderselect | |
// OrderSelect(...... | |
// then this method will work on the order selected | |
// bool result = ModifyOpenOrder(0.00300, 0.00900); | |
// returns true if the order was modified successfully | |
// returns false if the order didn't need modification or if modification failed | |
bool ModifyOpenOrder(double stopLossPips, double pipsProfit){ | |
bool modify = false; | |
double takeProfit; |
This file contains hidden or 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
// bool result = CloseOpenOrder(5); | |
// closes the currently selected order | |
bool CloseOpenOrder(int slippage){ | |
double price; | |
if(OrderType() == OP_SELL) { | |
price = Ask; | |
} else { | |
price = Bid; | |
} |
This file contains hidden or 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
// NUnit can use a list of "TestParameters", but then it | |
// doesn't populate the list of tests with the method(parameter, parameter) | |
// item in the list. So, instead, I made a class so I could | |
// create the TestParameters object in queries, assign values | |
// to named properties, and when I need them in a list of | |
// object[] for NUnit, I just convert each one by calling it's | |
// ToObject() method. | |
/// <summary> | |
/// Structure of test parameters |
OlderNewer