Initial Commit ...
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
# RSI MA Cross Strategy
|
||||
|
||||
EURUSD M15 Chart is Open
|
||||
|
||||
## Strategy Used
|
||||
|
||||
- 10 Period RSI:
|
||||
- ;
|
||||
- ;
|
||||
- 5 Period EMA;
|
||||
- 10 Period MA;
|
||||
|
||||
works by over solde and over baughts on rsi and then check mas;
|
||||
|
||||
## Implementation
|
||||
|
||||
```mq4
|
||||
//
|
||||
// Fast MA ...
|
||||
input int fastMaPeriod = 20; // Fast MA Bars
|
||||
input ENUM_MA_METHOD fastMaMethod = MODE_EMA; // Fast MA Method
|
||||
input ENUM_APPLIED_PRICE fastMaAppliedPrice = PRICE_CLOSE; // Fast MA Applied Price
|
||||
|
||||
//
|
||||
// Slow MA ...
|
||||
input int slowMaPeriod = 50; // Slow MA Bars
|
||||
input ENUM_MA_METHOD slowMaMethod = MODE_EMA; // Slow MA Method
|
||||
input ENUM_APPLIED_PRICE slowMaAppliedPrice = PRICE_CLOSE; // Slow MA Applied Price
|
||||
|
||||
//
|
||||
// SL / TP ...
|
||||
input int stopLossPips = 50; // SL Pips
|
||||
input int takeProfitPips = 50; // TP Pips
|
||||
|
||||
//
|
||||
// Trade ...
|
||||
intput double orderSize = 0.01; // Order size in Lots
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double fastMaBuffer[];
|
||||
double slowMaBuffer[];
|
||||
|
||||
const int buffersValuesRequired = 3;
|
||||
|
||||
//
|
||||
// Global Variables ...
|
||||
double stopLoss;
|
||||
double takeProfit;
|
||||
|
||||
//
|
||||
int OnInit() {
|
||||
//
|
||||
stopLoss = PipsToDouble(stopLossPips);
|
||||
takeProfit = PipsToDouble(takeProfitPips);
|
||||
|
||||
//
|
||||
IsNewBar();
|
||||
}
|
||||
```
|
||||
|
||||
## Calculating SL and TP Gaps on Trading Open
|
||||
|
||||
```mq4
|
||||
//
|
||||
// Define Some Variables ...
|
||||
double price;
|
||||
double closePrice;
|
||||
double tp = 0;
|
||||
double sl = 0;
|
||||
double slGap = PointsToDouble((int) SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL));
|
||||
|
||||
//
|
||||
if (stopLoss > 0 && stopLoss < slGap) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
if (takeProfit > 0 && takeProfit < slGap) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
RefreshRates();
|
||||
|
||||
//
|
||||
if (type == ORDER_TYPE_BUY) {
|
||||
//
|
||||
price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
|
||||
closePrice = SymbolInfoDouble(_Symbol, SYMBOL_BID);
|
||||
|
||||
//
|
||||
if (stopLoss > 0) {
|
||||
sl = closePrice - stopLoss;
|
||||
}
|
||||
|
||||
//
|
||||
if (takeProfit > 0) {
|
||||
tp = price + takeProfit;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
price = SymbolInfoDouble(_Symbol, SYMBOL_BID);
|
||||
closePrice = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
|
||||
|
||||
//
|
||||
if (stopLoss > 0) {
|
||||
sl = closePrice + stopLoss;
|
||||
}
|
||||
|
||||
//
|
||||
if (takeProfit > 0) {
|
||||
tp = price - takeProfit;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
price = NormalizeDouble(price, _Digits);
|
||||
sl = NormalizeDouble(sl, _Digits);
|
||||
tp = NormalizeDouble(tp, _Digits);
|
||||
```
|
||||
|
||||
## Usefull Library Methods
|
||||
|
||||
```mq4
|
||||
//
|
||||
// Convert points to Actual Point ...
|
||||
double PointsToDouble(int points) {
|
||||
//
|
||||
double result = points * _Point;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Converts Pips to Points ...
|
||||
int PipsToPoints(int pips) {
|
||||
//
|
||||
int result = pips * ((_Digits == 3 || _Digits == 5) ? 10 : 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Converts Pips to Double ...
|
||||
double PipsToDouble(int pips) {
|
||||
//
|
||||
double result = PointsToDouble(PipsToPoints(pips));
|
||||
return result;
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user