gbpusd_m1
Download scriptThis automated trading script is designed to manage market positions by analyzing multiple technical indicators simultaneously. Its primary goal is to identify specific trends in price action and execute trades based on a "consensus" of several different mathematical models.
Core Trading Logic
The system operates by evaluating seven distinct market signals. For a trade to be initiated, the script requires all of these indicators to align in the same direction.
- Price Action & Momentum: It examines current price candles and moving averages to determine if the immediate trend is bullish or bearish.
- Oscillators: It utilizes several oscillators (such as RSI and Stochastic) to measure the speed and change of price movements, helping to identify whether a market is overextended or gaining strength.
- MACD Analysis: It calculates the Moving Average Convergence Divergence to track the relationship between two different moving averages, identifying shifts in momentum.
How the Script Executes Trades
The script follows a structured decision-making process every time a new price candle begins:
-
Entry Signals:
- Buy (Long): If all seven indicators suggest upward momentum, the script opens a "Buy" position.
- Sell (Short): If all seven indicators suggest downward momentum, the script opens a "Sell" position.
-
Trade Management & Reversal: The script is designed to actively manage existing positions. If you already have an open trade and the market conditions suddenly shift significantly enough to trigger an opposing signal (e.g., you are in a Buy position but all indicators now suggest a Sell), the script will:
- Open a new trade in the opposite direction with double the volume of the original trade.
- Simultaneously close the previous, losing position.
Key Operational Features
- Unique Identification: The script uses a "Magic Number," which acts as a unique ID. This ensures that it only manages trades it opened itself and does not interfere with your other manual trades or different automated systems.
- Execution Delay: After opening a new trade, the system includes a brief pause (30 seconds) before finalizing the logic to ensure the platform has processed the request successfully.
- Single Trade Constraint: The script is built to focus on one primary set of operations at a time, ensuring it doesn't over-leverage your account by opening multiple simultaneous trades on the same signal.
//+-------------------------------------------------------------------------+
//| SSB.mq4 |
//| Copyright © 2009, Yury V. Reshetov http://ssb.bigfx.ru/ |
//| http://ssb.bigfx.ru/ |
//+-------------------------------------------------------------------------+
#property copyright "Copyright © 2009, Yury V. Reshetov http://ssb.bigfx.ru"
#property link "http://ssb.bigfx.ru"
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
*/
extern double lots = 1;
extern int prsi = 86;
extern int fastmacd = 11;
extern int slowmacd = 53;
extern int signalmacd = 26;
extern int stochD = 23;
extern int stochK = 40;
extern int stochS = 82;
extern int magic = 888;
extern int slippage = 0;
static int prevtime = 0;
int init() {
prevtime = Time[0];
return(0);
}
int start() {
if (! IsTradeAllowed()) {
return(0);
}
if (Time[0] == prevtime) {
return(0);
}
prevtime = Time[0];
int ticket = -1;
int total = OrdersTotal();
for (int i = total - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if ((OrderSymbol() == Symbol()) && (OrderMagicNumber() == magic)) {
int prevticket = OrderTicket();
if (OrderType() == OP_BUY) {
if (shortsignal()) {
ticket = OrderSend(Symbol(), OP_SELL, 2.0 * lots, Bid, slippage, 0, 0, WindowExpertName(), magic, 0, Red);
Sleep(30000);
if (ticket < 0) {
prevtime = Time[1];
return(0);
} else {
OrderCloseBy(ticket, prevticket, Red);
}
}
} else {
if (longsignal()) {
ticket = OrderSend(Symbol(), OP_BUY, 2.0 * lots, Ask, slippage, 0, 0, WindowExpertName(), magic, 0, Blue);
Sleep(30000);
if (ticket < 0) {
prevtime = Time[1];
return(0);
} else {
OrderCloseBy(ticket, prevticket, Blue);
}
}
}
return(0);
}
}
if (longsignal()) {
ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, slippage, 0, 0, WindowExpertName(), magic, 0, Blue);
Sleep(30000);
if (ticket < 0) {
prevtime = Time[1];
}
return(0);
}
if (shortsignal()) {
ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, slippage, 0, 0, WindowExpertName(), magic, 0, Red);
Sleep(30000);
if (ticket < 0) {
prevtime = Time[1];
}
return(0);
}
return(0);
}
bool longsignal() {
if (fcandle() < 0) {
return(false);
}
if (frsi() < 0) {
return(false);
}
if (fao() < 0) {
return(false);
}
if (fmacd1() < 0) {
return(false);
}
if (fosma() < 0) {
return(false);
}
if (fosma1() < 0) {
return(false);
}
if (fstoch2() < 0) {
return(false);
}
return(true);
}
bool shortsignal() {
if (fcandle() > 0) {
return(false);
}
if (frsi() > 0) {
return(false);
}
if (fao() > 0) {
return(false);
}
if (fmacd1() > 0) {
return(false);
}
if (fosma() > 0) {
return(false);
}
if (fosma1() > 0) {
return(false);
}
if (fstoch2() > 0) {
return(false);
}
return(true);
}
int fcandle() {
int result = 0;
if (Open[0] > Open[1]) {
result = 1;
}
if (Open[0] < Open[1]) {
result = -1;
}
return(result);
}
int frsi() {
int result = 0;
double ind = iRSI(Symbol(), 0, prsi, PRICE_OPEN, 0) - 50.0;
if (ind < 0) {
result = 1;
}
if (ind > 0) {
result = -1;
}
return(result);
}
int fao() {
int result = 0;
double ind = iAO(Symbol(), 0, 0);
if (ind < 0) {
result = 1;
}
if (ind > 0) {
result = -1;
}
return(result);
}
int fmacd1() {
int result = 0;
double ind = iMACD(Symbol(), 0, fastmacd, slowmacd, signalmacd, PRICE_OPEN, MODE_MAIN, 0);
double ind1 = iMACD(Symbol(), 0, fastmacd, slowmacd, signalmacd, PRICE_OPEN, MODE_MAIN, 1);
if ((ind - ind1) < 0) {
result = 1;
}
if ((ind - ind1) > 0) {
result = -1;
}
return(result);
}
int fosma() {
int result = 0;
double ind = iOsMA(Symbol(), 0, fastmacd, slowmacd, signalmacd, PRICE_OPEN, 0);
if (ind < 0) {
result = 1;
}
if (ind > 0) {
result = -1;
}
return(result);
}
int fosma1() {
int result = 0;
double ind = iOsMA(Symbol(), 0, fastmacd, slowmacd, signalmacd, PRICE_OPEN, 0);
double ind1 = iOsMA(Symbol(), 0, fastmacd, slowmacd, signalmacd, PRICE_OPEN, 1);
if ((ind - ind1) > 0) {
result = 1;
}
if ((ind - ind1) < 0) {
result = -1;
}
return(result);
}
int fstoch2() {
int result = 0;
double ind = iStochastic(Symbol(), 0, stochK, stochD, stochS, MODE_SMMA, 0,MODE_SIGNAL, 0) - 50.0;
if (ind < 0) {
result = 1;
}
if (ind > 0) {
result = -1;
}
return(result);
}
Profitability Reports
Expected payoff
Average expected payoff across the available backtests for each symbol.
Comments