JawsTest
Download scriptThis automated trading system, titled "Jaws," is designed to manage and execute trades on the MetaTrader platform by combining specific technical indicators with customizable risk management protocols. The logic of the script can be broken down into four main categories:
Core Trading Indicators
The system relies on two primary mathematical models to interpret market movements:
- Parabolic SAR: This is used to determine the current trend direction and potential reversal points. It creates "dots" on the chart that help the system understand whether the price is moving in a steady momentum or if it is beginning to slow down.
- Price Channel Stop (PCS): This component monitors price channels to identify volatility. It looks at specific periods of historical data to establish boundaries, helping the system decide where the "safety zone" for a trade lies.
Trade Execution Logic
The script is designed to be highly disciplined in how it enters and exits the market:
- Confirmation Strategy: The system includes a setting to "Wait for Close," which ensures that a trade is only triggered once a candle has finished forming. This prevents the system from reacting to "fake" price movements that disappear before the bar ends.
- Profit and Loss Targets: Every trade is governed by predefined limits. It automatically calculates a Stop Loss (to cut losses quickly if a trade goes against the user) and a Take Profit (to lock in gains once a target is reached).
Money Management & Risk Control
A significant portion of the script is dedicated to protecting the user's capital:
- Equity Protection: Users can choose between fixed lot sizes or a dynamic percentage-based system. The latter automatically calculates how much of your total account balance to risk on a single trade.
- Trade Limits: The script allows for a "Maximum Lot" cap, providing a safety net to prevent the system from placing excessively large positions that could jeopardize the account.
Technical Configuration
To ensure the system operates independently and accurately, it uses several background identifiers:
- Magic Number: This acts as a unique ID for the trades opened by this specific script, allowing it to manage its own orders without interfering with other manual trades or different automated systems running on the same account.
- Slippage Control: It includes a buffer to handle price fluctuations, ensuring that trades are executed at acceptable prices even during fast-moving market conditions.
//=============================================================================
// Jaws.mq4
// Copyright © 2006, Derk Wehler
// derkwehler@gmail.com
//
//=============================================================================
#property copyright "Copyright © 2006, Derk Wehler"
#property link "no site"
// Input parameters
extern string S1 = "== MONEY MANAGEMENT SETTINGS ==";
extern bool MoneyManagement = false;
extern double TradeSizePercent = 10; // Change to whatever percent of equity you wish to risk.
extern double Lots = 1.0;
extern double MaxLots = 100.0;
extern string S1z = " ";
extern string S2 = "==== INDICATOR SETTINGS ====";
extern string S2a = "------- PARABOLIC SAR INDICATOR -------";
extern int SAR_Step = 0.02;
extern int SAR_Maximum = 0.2;
extern string S2b = "---- PRICE CHANNEL STOP INDICATOR ----";
extern int PCS_ChannelPeriod = 9;
extern double PCS_Risk = 0.3;
extern int PCS_Signal = 1;
extern int PCS_Line = 1;
extern int PCS_NBars = 1000;
extern string S2z = " ";
extern string S3 = "==== EA SETTINGS ====";
extern bool WaitForClose = true;
extern string S3a = "------ SL, TP AND TRAIL ------";
extern int TakeProfit = 60;
extern int StopLoss = 30;
extern string S3z = " ";
extern string S4c = "------ GENERAL EA ------";
extern int Slippage = 1;
extern int MagicSeed = 1969;
extern string ExpertName = "Jaws";
extern int DebugLevel = 0;
static int prevBars = -1;
int MagicNumber;
double SL;
double TP;
static int prevSAR_Mode = -1;
static int prevPCS_Mode = -1;
static int prevPCS_Mode2 = -1;
static int prevPCS_Mode3 = -1;
int PCS_Mode;
int SAR_Mode;
int CurPCS_Value;
int CurSAR_Value;
//=============================================================================
// expert initialization function
//=============================================================================
int init()
{
// ------------------------------------------------
// Put code here to test indicators. Sample:
// ------------------------------------------------
for (int i=0; i < 20; i++)
{
double SAR0 = iSAR(NULL, 0, SAR_Step, SAR_Maximum, i);
Comment("\ni = ", i, "\nSAR: ", SAR0);
Sleep(2000);
}
}
//=============================================================================
// expert deinitialization function
//=============================================================================
int deinit()
{
return (0);
}
//=============================================================================
// Expert start function
//=============================================================================
int start()
{
return (0);
}
Comments