0% found this document useful (0 votes)
27 views5 pages

New Text Document_061512

The document outlines the code for a trading expert advisor (EA) named 'HUNTER EA V12' that integrates Fibonacci analysis for scalping and day trading strategies. It includes various input parameters for risk management, trade execution, and market conditions, as well as functions for optimal trade entry and order placement. The EA also incorporates checks for daily loss limits, maximum drawdown, and market hours to ensure effective trading operations.

Uploaded by

Mickel James
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views5 pages

New Text Document_061512

The document outlines the code for a trading expert advisor (EA) named 'HUNTER EA V12' that integrates Fibonacci analysis for scalping and day trading strategies. It includes various input parameters for risk management, trade execution, and market conditions, as well as functions for optimal trade entry and order placement. The EA also incorporates checks for daily loss limits, maximum drawdown, and market hours to ensure effective trading operations.

Uploaded by

Mickel James
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

//+------------------------------------------------------------------+

//| HUNTER EA V12 ICT Enhanced with Fibonacci |


//| TP-FX TRADER |
//+------------------------------------------------------------------+
#property strict

// Input parameters
input double RiskPercentage = 1; // Risk percentage for position
sizing
input int ScalpingTakeProfitPips = 5; // Scalping take profit in pips
input int ScalpingStopLossPips = 3; // Scalping stop loss in pips
input int DayTradingTakeProfitPips = 20; // Day trading take profit in pips
input int DayTradingStopLossPips = 10; // Day trading stop loss in pips
input double TrailingStopPips = 2; // Trailing stop in pips
input bool IsScalpingEnabled = true; // Enable scalping strategy
input bool IsDayTradingEnabled = true; // Enable day trading strategy
input int MaxDrawdownPercent = 10; // Max drawdown percentage
input double DailyLossLimit = 50; // Daily loss limit in account
currency
input int RSIPeriod = 14; // RSI period
input double OverboughtLevel = 70; // RSI overbought level
input double OversoldLevel = 30; // RSI oversold level
input int NewsBufferMinutes = 15; // Avoid trading near news events
input int MTFPeriod = 60; // Multi-timeframe analysis period
in minutes
input int TradingStartHour = 1; // Trading start hour (GMT)
input int TradingEndHour = 22; // Trading end hour (GMT)

// Global variables
bool orderOpened = false;
double startingBalance;
double dailyLoss = 0;

//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
startingBalance = AccountBalance();
return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Fibonacci Golden Zone (OTE) Detection |
//+------------------------------------------------------------------+
bool IsOptimalTradeEntry(bool isBuy)
{
double high = High[iHighest(NULL, 0, MODE_HIGH, 20, 0)];
double low = Low[iLowest(NULL, 0, MODE_LOW, 20, 0)];
double fib618 = isBuy ? low + (0.618 * (high - low)) : high - (0.618 * (high -
low));
double fib786 = isBuy ? low + (0.786 * (high - low)) : high - (0.786 * (high -
low));

// Check if the current price is within the Golden Zone


return isBuy ? (Close[0] >= fib618 && Close[0] <= fib786) : (Close[0] <= fib618
&& Close[0] >= fib786);
}
//+------------------------------------------------------------------+
//| Fibonacci Extensions for Take-Profit |
//+------------------------------------------------------------------+
double GetFibonacciExtension(bool isBuy, double high, double low)
{
double fibExtension127 = isBuy ? high + (1.272 * (high - low)) : low - (1.272 *
(high - low));
double fibExtension161 = isBuy ? high + (1.618 * (high - low)) : low - (1.618 *
(high - low));
return fibExtension127; // You can return the desired level, or allow
configuration.
}

//+------------------------------------------------------------------+
//| Trading Logic with Fibonacci Integration |
//+------------------------------------------------------------------+
void TradingLogicICT()
{
double positionSize = CalculatePositionSize(); // Calculate position size
double high = High[iHighest(NULL, 0, MODE_HIGH, 20, 0)];
double low = Low[iLowest(NULL, 0, MODE_LOW, 20, 0)];

if (IsScalpingEnabled) {
if (!orderOpened && IsFairValueGap() && IsOrderBlockICT(true) &&
IsOptimalTradeEntry(true)) {
double tpExtension = GetFibonacciExtension(true, high, low);
PlaceOrderWithCustomTP(positionSize, true, true, tpExtension); // Buy
with Fibonacci TP
} else if (!orderOpened && IsFairValueGap() && IsOrderBlockICT(false) &&
IsOptimalTradeEntry(false)) {
double tpExtension = GetFibonacciExtension(false, high, low);
PlaceOrderWithCustomTP(positionSize, false, true, tpExtension); // Sell
with Fibonacci TP
}
}

if (IsDayTradingEnabled) {
if (!orderOpened && IsFairValueGap() && IsOrderBlockICT(true) &&
IsOptimalTradeEntry(true)) {
double tpExtension = GetFibonacciExtension(true, high, low);
PlaceOrderWithCustomTP(positionSize, true, false, tpExtension); // Buy
with Fibonacci TP
} else if (!orderOpened && IsFairValueGap() && IsOrderBlockICT(false) &&
IsOptimalTradeEntry(false)) {
double tpExtension = GetFibonacciExtension(false, high, low);
PlaceOrderWithCustomTP(positionSize, false, false, tpExtension); //
Sell with Fibonacci TP
}
}
}

//+------------------------------------------------------------------+
//| Function to Place Order with Custom Take-Profit |
//+------------------------------------------------------------------+
bool PlaceOrderWithCustomTP(double positionSize, bool isBuy, bool isScalping,
double customTP)
{
double price = isBuy ? Ask : Bid;
double sl = isBuy ? price - (isScalping ? ScalpingStopLossPips * Point :
DayTradingStopLossPips * Point)
: price + (isScalping ? ScalpingStopLossPips * Point :
DayTradingStopLossPips * Point);

int ticket = OrderSend(Symbol(), isBuy ? OP_BUY : OP_SELL, positionSize, price,


3, sl, customTP, "Fibonacci TP", 0, 0, clrBlue);

if (ticket < 0) {
Print("Error placing order: ", GetLastError());
return false;
}
Print("Order placed successfully with Fibonacci TP: ", ticket);
orderOpened = true;
return true;
}

//+------------------------------------------------------------------+
//| Supporting Functions |
//+------------------------------------------------------------------+
double CalculatePositionSize()
{
double accountRisk = AccountBalance() * RiskPercentage / 100;
double pipValue = MarketInfo(Symbol(), MODE_TICKVALUE);
return accountRisk / ((IsScalpingEnabled ? ScalpingStopLossPips :
DayTradingStopLossPips) * pipValue);
}

bool MarketIsOpen()
{
int hour = TimeHour(TimeCurrent());
return (hour >= TradingStartHour && hour < TradingEndHour);
}

bool IsFairValueGap()
{
double high1 = High[2];
double low1 = Low[2];
double high2 = High[1];
double low2 = Low[1];
double high3 = High[0];
double low3 = Low[0];

return (low1 > high2 && high3 > low1); // FVG logic
}

bool IsOrderBlockICT(bool isBuy)


{
int lookback = 5;
if (isBuy) {
for (int i = 1; i <= lookback; i++) {
if (Open[i] > Close[i] && Close[i] < Open[i + 1]) {
return true; // Bullish order block detected
}
}
} else {
for (int i = 1; i <= lookback; i++) {
if (Open[i] < Close[i] && Close[i] > Open[i + 1]) {
return true; // Bearish order block detected
}
}
}
return false;
}

bool IsDailyLossExceeded()
{
double currentBalance = AccountBalance();
dailyLoss = startingBalance - currentBalance;
return (dailyLoss >= DailyLossLimit);
}

bool IsMaxDrawdownExceeded()
{
double currentDrawdown = (startingBalance - AccountBalance()) / startingBalance
* 100;
return (currentDrawdown >= MaxDrawdownPercent);
}

//+------------------------------------------------------------------+-------------
+
//| Advanced Pattern Recognition |
//+------------------------------------------------------------------+
bool IsHeadAndShoulders()
{
// Placeholder logic for detecting Head and Shoulders
return false; // Change this to actual detection logic
}

bool IsDoubleTopBottom()
{
// Placeholder logic for detecting Double Tops/Bottoms
return false; // Change this to actual detection logic
}

//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
// Check if the market is open during specified hours
if (!MarketIsOpen() || IsDailyLossExceeded() || IsMaxDrawdownExceeded() ||
IsNewsEvent()) {
Print("Market is closed or risk limits exceeded. Current time: ",
TimeToString(TimeCurrent(), TIME_DATE | TIME_MINUTES));
return;
}

// Execute trading logic


TradingLogic();

// Manage trailing stops for open trades


ManageTrailingStop();
}

//+------------------------------------------------------------------+
//| Trading Logic |
//+------------------------------------------------------------------+
void TradingLogic()
{
double positionSize = CalculatePositionSize(); // Calculate position size

if (IsScalpingEnabled) {
// Scalping Logic
if (!orderOpened && IsInDemandZone() && IsRSIConditionMet(true) &&
IsMTFConditionMet(true) && IsHeadAndShoulders()) {
PlaceOrder(positionSize, true, true); // Buy for scalping
} else if (!orderOpened && IsInSupplyZone() && IsRSIConditionMet(false) &&
IsMTFConditionMet(false) && IsDoubleTopBottom()) {
PlaceOrder(positionSize, false, true); // Sell for scalping
}
}

if (IsDayTradingEnabled) {
// Day Trading Logic
if (!orderOpened && IsInDemandZone() && IsRSIConditionMet(true) &&
IsMTFConditionMet(true)) {
PlaceOrder(positionSize, true, false); // Buy for day trading
} else if (!orderOpened && IsInSupplyZone() && IsRSIConditionMet(false) &&
IsMTFConditionMet(false)) {
PlaceOrder(positionSize, false, false); // Sell for day trading
}
}
}

//+------------------------------------------------------------------+

You might also like