Anyone please make a zigzag indicator based on pullback strategy
Similar Threads
I will code your pivot EAs for no charge 23 replies
I will code your scalping EAs for no charge 163 replies
Oanda MT4 - Indicators and EAs not showing 2 replies
EAs and indicators relating to moutaki... 22 replies
InterbankFX has loaded its MT4 platform with custom EAs, indicators and scripts 1 reply
- Post #62,062
- Quote
- Jun 27, 2023 5:25am Jun 27, 2023 5:25am
Dislikedhey guys, i want to learn and improve my mql4 skills. I think the best way to do this is to practice. Unfortunately sometimes i don`t have any nice idea which i can implement in a expert advisor / indicator. So if any of you is interested, please post in this forum your ideas and i will try to implement it into mql4. AndiIgnored
sir
i need your help for create a zigzag indicator based on pullback , inducement strategy
- Post #62,063
- Quote
- Jun 27, 2023 5:32am Jun 27, 2023 5:32am
Disliked{quote} tintep Thanks for always been their with us on this trading journey. i really appreciate your effort. Please help to include show line on symbol/pairs on this TT-STO Dash-BT2{file} And also please help for the great tools TT-STO_StrengthX-BT as well by including stochastic settings %K Period --- %D Period --- S Period --- Price field --- Low/High Close/Close MA Method --- Simple Exponential Smooth Linear Weight {file} So i will be able to insert settings/values of my choice. Please i will really be grateful.Ignored
Attached File(s)
TT STO Dash-BT2.ex4
48 KB
|
192 downloads
TT-STO_StrengthX-BT.ex4
35 KB
|
200 downloads
1
- Post #62,064
- Quote
- Edited 4:46pm Jun 27, 2023 1:33pm | Edited 4:46pm
please coder in the house i need your help to help me correct the errors in this code and help me compile it as ea ,i believe it will help many traders as i have benefited alot from this platform pls dont let this call for help go without been attended to as i have made many of such calls without being attended to.am just a baby coder trying to survive in d big occean of trading forex,pls help me and others who will benefit from this perfect this code,thank u in advance
// MACD Expert Advisor with Candlestick Pattern Detection
// Parameters: FastEMA = 21, SlowEMA = 13, SignalSMA = 8
input int FastEMA = 21;
input int SlowEMA = 13;
input int SignalSMA = 8;
input double LotSize = 0.01; // Fixed lot size
input double StopLossPercentage = 0.5; // Stop loss as a percentage of ADR
input double TakeProfitPercentage = 1.0; // Take profit as a percentage of ADR
input int NumberOfTrades = 5; // Number of trades to execute
input int MagicNumber = 123456; // Unique identifier for trades
input string Comment = "MACD EA"; // Comment for trades
input double TrailingStopPips = 20; // Trailing stop in pips
input bool EnableNewsFilter = true; // Enable economic news filter
input int NewsImpactLevel = 2; // Minimum impact level of news to consider
input bool EnableATRFilter = true; // Enable ATR filter
input double ATRMultiplier = 2.0; // ATR multiplier for filtering
input bool EnableCandlestickPattern = true; // Enable candlestick pattern detection
input double MaxRiskPercent = 2.0; // Maximum risk per trade as a percentage of account equity
input int VolatilityPeriod = 14; // Period for calculating market volatility
input double VolatilityThreshold = 0.5; // Minimum volatility level to trade
input int TrendConfirmationPeriod = 20; // Period for confirming the trend
input bool CloseOnReversal = false; // Close trade on market reversal
input string IndicatorNames = ""; // Names of multiple indicators separated by comma
input int MaxTradesPerStrategy = 3; // Maximum number of trades per strategy
input int MaxTotalTrades = 10; // Maximum total number of trades
input bool UseVolatilityFilter = true; // Enable volatility filter
input double MinVolatilityPercent = 0.5; // Minimum volatility level as a percentage of average true range (ATR)
input bool UseTradeExitStrategy = true; // Enable trade exit strategy
input int NewsImpactFilter = 2; // Minimum impact level of news to trade (0 - Low, 1 - Medium, 2 - High)
input bool UseDiversification = true; // Enable diversification of trading strategy
input int MaxTradesPerSymbol = 1; // Maximum number of trades per symbol
// Global variables
double macdBuffer[];
double signalBuffer[];
double histogramBuffer[];
// Candlestick pattern enumeration
enum CandlestickPattern
{
BULLISH_ENGULFING,
BEARISH_ENGULFING,
HAMMER,
HANGING_MAN,
SHOOTING_STAR,
INVERTED_HAMMER,
DOJI,
SPINNING_TOP,
PIERCING_LINE,
THREE_WHITE_SOLDIERS,
THREE_STARS_IN_THE_SOUTH,
DRAGONFLY_DOJI,
THREE_OUTSIDE_UP,
THREE_OUTSIDE_DOWN,
GRAVESTONE_DOJI,
DARK_CLOUD_COVER,
THREE_INSIDE_UP,
THREE_INSIDE_DOWN,
ABANDONED_BABY,
THREE_BLACK_CROWS,
MARUBOZU,
KICKING,
TRI_STAR,
LADDER_BOTTOM,
DOWNSIDE_GAP_THREE_METHODS,
TASUKI_GAP,
MATCHING_LOW,
UPSIDE_GAP_TWO_CROWS,
DOWN_GAP_SIDE_BY_SIDE_WHITE_LINES,
UP_GAP_SIDE_BY_SIDE_WHITE_LINES,
LADDER_TOP,
THRUSTING,
CLOSING_MARUBOZU,
UPSIDE_GAP_THREE_METHODS,
TWO_CROWS,
ISLAND_REVERSAL,
NONE
};
// Initialization function
int OnInit()
{
// Add indicators
IndicatorSetInteger(INDICATOR_DIGITS, Digits);
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, macdBuffer);
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(1, signalBuffer);
SetIndexStyle(2, DRAW_HISTOGRAM);
SetIndexBuffer(2, histogramBuffer);
// Set indicator parameters
SetIndexShift(0, SlowEMA);
SetIndexShift(1, SignalSMA);
// Set the necessary indicator buffers for calculation
SetIndexBuffer(0, macdBuffer);
SetIndexBuffer(1, signalBuffer);
SetIndexBuffer(2, histogramBuffer);
return INIT_SUCCEEDED;
}
// Deinitialization function
void OnDeinit(const int reason)
{
// Free indicator buffers
ArrayFree(macdBuffer);
ArrayFree(signalBuffer);
ArrayFree(histogramBuffer);
}
// Main trading function
void OnTick()
{
// Check for news filter
if (EnableNewsFilter)
{
// Check for upcoming economic news events
datetime currentTime = TimeCurrent();
datetime newsTime;
int newsImpact;
for (int i = 0; i < NewsTotal(); i++)
{
newsTime = NewsTime(i);
newsImpact = NewsImpact(i);
// Check if there is an upcoming news event with the desired impact level
if (newsTime > currentTime && newsImpact >= NewsImpactLevel)
{
return; // Skip trading during news events
}
}
}
// Calculate MACD values
int macdCalc = iMACD(Symbol(), PERIOD_CURRENT, FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE);
// Get the current MACD, Signal, and Histogram values
double currentMACD = macdBuffer[0];
double currentSignal = signalBuffer[0];
double currentHistogram = histogramBuffer[0];
// Calculate candlestick pattern
CandlestickPattern pattern = GetCandlestickPattern();
// Add your trading logic based on the MACD, candlestick pattern, and other parameters
// ...
}
// Function to detect candlestick pattern
CandlestickPattern GetCandlestickPattern()
{
double open = iOpen(Symbol(), PERIOD_CURRENT, 1);
double close = iClose(Symbol(), PERIOD_CURRENT, 1);
double high = iHigh(Symbol(), PERIOD_CURRENT, 1);
double low = iLow(Symbol(), PERIOD_CURRENT, 1);
double bodySize = MathAbs(close - open);
double upperShadow = high - MathMax(close, open);
double lowerShadow = MathMin(close, open) - low;
double totalSize = bodySize + upperShadow + lowerShadow;
// Check for bearish candlestick patterns
if (close > open && close > high - bodySize / 2 && open <= low + bodySize / 2)
{
return BULLISH_ENGULFING;
}
else if (close < open && open > high - bodySize / 2 && close <= low + bodySize / 2)
{
return BEARISH_ENGULFING;
}
else if (close < open && bodySize > 2 * upperShadow && lowerShadow < upperShadow / 3)
{
return HAMMER;
}
else if (close < open && bodySize > 2 * upperShadow && upperShadow < lowerShadow / 3)
{
return HANGING_MAN;
}
else if (close < open && bodySize > upperShadow + lowerShadow && upperShadow < lowerShadow / 4)
{
return SHOOTING_STAR;
}
else if (close > open && bodySize > upperShadow + lowerShadow && lowerShadow < upperShadow / 4)
{
return INVERTED_HAMMER;
}
else if (bodySize < totalSize / 10 && MathAbs(open - close) < bodySize / 3)
{
return DOJI;
}
else if (bodySize < totalSize / 3 && upperShadow > bodySize / 2 && lowerShadow > bodySize / 2)
{
return SPINNING_TOP;
}
else if (close < open && close > open - bodySize / 2 && close > (high + low) / 2 && open <= (high + low) / 2)
{
return PIERCING_LINE;
}
else if (close > open && open < (high + low) / 2 && close >= (high + low) / 2)
{
return THREE_WHITE_SOLDIERS;
}
else if (close < open && open > (high + low) / 2 && close <= (high + low) / 2)
{
return THREE_STARS_IN_THE_SOUTH;
}
else if (close == open && upperShadow < bodySize / 2 && lowerShadow > bodySize / 2)
{
return DRAGONFLY_DOJI;
}
else if (close > open && open > low && close < (high + low) / 2 && open < (high + low) / 2)
{
return THREE_OUTSIDE_UP;
}
else if (close < open && open < high && close > (high + low) / 2 && open > (high + low) / 2)
{
return THREE_OUTSIDE_DOWN;
}
else if (close == open && upperShadow > bodySize / 2 && lowerShadow < bodySize / 2)
{
return GRAVESTONE_DOJI;
}
else if (close > open && close < open + bodySize / 2 && open >= high - bodySize / 2 && close <= low + bodySize / 2)
{
return DARK_CLOUD_COVER;
}
else if (close > open && open < close - bodySize / 2 && open > low + bodySize / 2 && close >= high - bodySize / 2)
{
return THREE_INSIDE_UP;
}
else if (close < open && open > close - bodySize / 2 && open > high - bodySize / 2 && close <= low + bodySize / 2)
{
return THREE_INSIDE_DOWN;
}
else if (open > high && close < low && iOpen(Symbol(), PERIOD_CURRENT, 2) > iHigh(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) < iLow(Symbol(), PERIOD_CURRENT, 2))
{
return ABANDONED_BABY;
}
else if (close < open && iClose(Symbol(), PERIOD_CURRENT, 2) > iClose(Symbol(), PERIOD_CURRENT, 3) && iOpen(Symbol(), PERIOD_CURRENT, 3) > iClose(Symbol(), PERIOD_CURRENT, 2) && iOpen(Symbol(), PERIOD_CURRENT, 3) < iOpen(Symbol(), PERIOD_CURRENT, 2))
{
return THREE_BLACK_CROWS;
}
else if (close > open && open == low && close == high)
{
return MARUBOZU;
}
else if (close < open && close < low && open > high)
{
return KICKING;
}
else if (close < open && close < low && open > high && iClose(Symbol(), PERIOD_CURRENT, 2) > iHigh(Symbol(), PERIOD_CURRENT, 2))
{
return TRI_STAR;
}
else if (close > open && close == high && open < low)
{
return LADDER_BOTTOM;
}
else if (close > open && open > high && iOpen(Symbol(), PERIOD_CURRENT, 2) < iLow(Symbol(), PERIOD_CURRENT, 2))
{
return DOWNSIDE_GAP_THREE_METHODS;
}
else if (close > open && open > high && iOpen(Symbol(), PERIOD_CURRENT, 2) > iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) < iLow(Symbol(), PERIOD_CURRENT, 2))
{
return TASUKI_GAP;
}
else if (close > open && open < low && close > high && iOpen(Symbol(), PERIOD_CURRENT, 2) > iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) < iOpen(Symbol(), PERIOD_CURRENT, 2))
{
return MATCHING_LOW;
}
else if (close < open && open > high && iOpen(Symbol(), PERIOD_CURRENT, 2) < iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) > iOpen(Symbol(), PERIOD_CURRENT, 2))
{
return UPSIDE_GAP_TWO_CROWS;
}
else if (close > open && close < iOpen(Symbol(), PERIOD_CURRENT, 2) && iOpen(Symbol(), PERIOD_CURRENT, 2) > iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) < low)
{
return DOWN_GAP_SIDE_BY_SIDE_WHITE_LINES;
}
else if (close < open && open > iClose(Symbol(), PERIOD_CURRENT, 2) && iOpen(Symbol(), PERIOD_CURRENT, 2) < iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) > high)
{
return UP_GAP_SIDE_BY_SIDE_WHITE_LINES;
}
else if (close > open && open == high && close == low)
{
return LADDER_TOP;
}
else if (close < open && close > low && open < high)
{
return THRUSTING;
}
else if (close > open && close > high && open < low)
{
return CLOSING_MARUBOZU;
}
else if (close > open && open < low && close > high && iOpen(Symbol(), PERIOD_CURRENT, 2) < iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) > iOpen(Symbol(), PERIOD_CURRENT, 2))
{
return UPSIDE_GAP_THREE_METHODS;
}
else if (close < open && close > low && open < high && iClose(Symbol(), PERIOD_CURRENT, 2) < iLow(Symbol(), PERIOD_CURRENT, 2))
{
return TWO_CROWS;
}
else if (close > open && open < low && close > high && iOpen(Symbol(), PERIOD_CURRENT, 2) > iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) < iOpen(Symbol(), PERIOD_CURRENT, 2))
{
return ISLAND_REVERSAL;
}
else
{
return NONE;
}
}
// MACD Expert Advisor with Candlestick Pattern Detection
// Parameters: FastEMA = 21, SlowEMA = 13, SignalSMA = 8
input int FastEMA = 21;
input int SlowEMA = 13;
input int SignalSMA = 8;
input double LotSize = 0.01; // Fixed lot size
input double StopLossPercentage = 0.5; // Stop loss as a percentage of ADR
input double TakeProfitPercentage = 1.0; // Take profit as a percentage of ADR
input int NumberOfTrades = 5; // Number of trades to execute
input int MagicNumber = 123456; // Unique identifier for trades
input string Comment = "MACD EA"; // Comment for trades
input double TrailingStopPips = 20; // Trailing stop in pips
input bool EnableNewsFilter = true; // Enable economic news filter
input int NewsImpactLevel = 2; // Minimum impact level of news to consider
input bool EnableATRFilter = true; // Enable ATR filter
input double ATRMultiplier = 2.0; // ATR multiplier for filtering
input bool EnableCandlestickPattern = true; // Enable candlestick pattern detection
input double MaxRiskPercent = 2.0; // Maximum risk per trade as a percentage of account equity
input int VolatilityPeriod = 14; // Period for calculating market volatility
input double VolatilityThreshold = 0.5; // Minimum volatility level to trade
input int TrendConfirmationPeriod = 20; // Period for confirming the trend
input bool CloseOnReversal = false; // Close trade on market reversal
input string IndicatorNames = ""; // Names of multiple indicators separated by comma
input int MaxTradesPerStrategy = 3; // Maximum number of trades per strategy
input int MaxTotalTrades = 10; // Maximum total number of trades
input bool UseVolatilityFilter = true; // Enable volatility filter
input double MinVolatilityPercent = 0.5; // Minimum volatility level as a percentage of average true range (ATR)
input bool UseTradeExitStrategy = true; // Enable trade exit strategy
input int NewsImpactFilter = 2; // Minimum impact level of news to trade (0 - Low, 1 - Medium, 2 - High)
input bool UseDiversification = true; // Enable diversification of trading strategy
input int MaxTradesPerSymbol = 1; // Maximum number of trades per symbol
// Global variables
double macdBuffer[];
double signalBuffer[];
double histogramBuffer[];
// Candlestick pattern enumeration
enum CandlestickPattern
{
BULLISH_ENGULFING,
BEARISH_ENGULFING,
HAMMER,
HANGING_MAN,
SHOOTING_STAR,
INVERTED_HAMMER,
DOJI,
SPINNING_TOP,
PIERCING_LINE,
THREE_WHITE_SOLDIERS,
THREE_STARS_IN_THE_SOUTH,
DRAGONFLY_DOJI,
THREE_OUTSIDE_UP,
THREE_OUTSIDE_DOWN,
GRAVESTONE_DOJI,
DARK_CLOUD_COVER,
THREE_INSIDE_UP,
THREE_INSIDE_DOWN,
ABANDONED_BABY,
THREE_BLACK_CROWS,
MARUBOZU,
KICKING,
TRI_STAR,
LADDER_BOTTOM,
DOWNSIDE_GAP_THREE_METHODS,
TASUKI_GAP,
MATCHING_LOW,
UPSIDE_GAP_TWO_CROWS,
DOWN_GAP_SIDE_BY_SIDE_WHITE_LINES,
UP_GAP_SIDE_BY_SIDE_WHITE_LINES,
LADDER_TOP,
THRUSTING,
CLOSING_MARUBOZU,
UPSIDE_GAP_THREE_METHODS,
TWO_CROWS,
ISLAND_REVERSAL,
NONE
};
// Initialization function
int OnInit()
{
// Add indicators
IndicatorSetInteger(INDICATOR_DIGITS, Digits);
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, macdBuffer);
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(1, signalBuffer);
SetIndexStyle(2, DRAW_HISTOGRAM);
SetIndexBuffer(2, histogramBuffer);
// Set indicator parameters
SetIndexShift(0, SlowEMA);
SetIndexShift(1, SignalSMA);
// Set the necessary indicator buffers for calculation
SetIndexBuffer(0, macdBuffer);
SetIndexBuffer(1, signalBuffer);
SetIndexBuffer(2, histogramBuffer);
return INIT_SUCCEEDED;
}
// Deinitialization function
void OnDeinit(const int reason)
{
// Free indicator buffers
ArrayFree(macdBuffer);
ArrayFree(signalBuffer);
ArrayFree(histogramBuffer);
}
// Main trading function
void OnTick()
{
// Check for news filter
if (EnableNewsFilter)
{
// Check for upcoming economic news events
datetime currentTime = TimeCurrent();
datetime newsTime;
int newsImpact;
for (int i = 0; i < NewsTotal(); i++)
{
newsTime = NewsTime(i);
newsImpact = NewsImpact(i);
// Check if there is an upcoming news event with the desired impact level
if (newsTime > currentTime && newsImpact >= NewsImpactLevel)
{
return; // Skip trading during news events
}
}
}
// Calculate MACD values
int macdCalc = iMACD(Symbol(), PERIOD_CURRENT, FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE);
// Get the current MACD, Signal, and Histogram values
double currentMACD = macdBuffer[0];
double currentSignal = signalBuffer[0];
double currentHistogram = histogramBuffer[0];
// Calculate candlestick pattern
CandlestickPattern pattern = GetCandlestickPattern();
// Add your trading logic based on the MACD, candlestick pattern, and other parameters
// ...
}
// Function to detect candlestick pattern
CandlestickPattern GetCandlestickPattern()
{
double open = iOpen(Symbol(), PERIOD_CURRENT, 1);
double close = iClose(Symbol(), PERIOD_CURRENT, 1);
double high = iHigh(Symbol(), PERIOD_CURRENT, 1);
double low = iLow(Symbol(), PERIOD_CURRENT, 1);
double bodySize = MathAbs(close - open);
double upperShadow = high - MathMax(close, open);
double lowerShadow = MathMin(close, open) - low;
double totalSize = bodySize + upperShadow + lowerShadow;
// Check for bearish candlestick patterns
if (close > open && close > high - bodySize / 2 && open <= low + bodySize / 2)
{
return BULLISH_ENGULFING;
}
else if (close < open && open > high - bodySize / 2 && close <= low + bodySize / 2)
{
return BEARISH_ENGULFING;
}
else if (close < open && bodySize > 2 * upperShadow && lowerShadow < upperShadow / 3)
{
return HAMMER;
}
else if (close < open && bodySize > 2 * upperShadow && upperShadow < lowerShadow / 3)
{
return HANGING_MAN;
}
else if (close < open && bodySize > upperShadow + lowerShadow && upperShadow < lowerShadow / 4)
{
return SHOOTING_STAR;
}
else if (close > open && bodySize > upperShadow + lowerShadow && lowerShadow < upperShadow / 4)
{
return INVERTED_HAMMER;
}
else if (bodySize < totalSize / 10 && MathAbs(open - close) < bodySize / 3)
{
return DOJI;
}
else if (bodySize < totalSize / 3 && upperShadow > bodySize / 2 && lowerShadow > bodySize / 2)
{
return SPINNING_TOP;
}
else if (close < open && close > open - bodySize / 2 && close > (high + low) / 2 && open <= (high + low) / 2)
{
return PIERCING_LINE;
}
else if (close > open && open < (high + low) / 2 && close >= (high + low) / 2)
{
return THREE_WHITE_SOLDIERS;
}
else if (close < open && open > (high + low) / 2 && close <= (high + low) / 2)
{
return THREE_STARS_IN_THE_SOUTH;
}
else if (close == open && upperShadow < bodySize / 2 && lowerShadow > bodySize / 2)
{
return DRAGONFLY_DOJI;
}
else if (close > open && open > low && close < (high + low) / 2 && open < (high + low) / 2)
{
return THREE_OUTSIDE_UP;
}
else if (close < open && open < high && close > (high + low) / 2 && open > (high + low) / 2)
{
return THREE_OUTSIDE_DOWN;
}
else if (close == open && upperShadow > bodySize / 2 && lowerShadow < bodySize / 2)
{
return GRAVESTONE_DOJI;
}
else if (close > open && close < open + bodySize / 2 && open >= high - bodySize / 2 && close <= low + bodySize / 2)
{
return DARK_CLOUD_COVER;
}
else if (close > open && open < close - bodySize / 2 && open > low + bodySize / 2 && close >= high - bodySize / 2)
{
return THREE_INSIDE_UP;
}
else if (close < open && open > close - bodySize / 2 && open > high - bodySize / 2 && close <= low + bodySize / 2)
{
return THREE_INSIDE_DOWN;
}
else if (open > high && close < low && iOpen(Symbol(), PERIOD_CURRENT, 2) > iHigh(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) < iLow(Symbol(), PERIOD_CURRENT, 2))
{
return ABANDONED_BABY;
}
else if (close < open && iClose(Symbol(), PERIOD_CURRENT, 2) > iClose(Symbol(), PERIOD_CURRENT, 3) && iOpen(Symbol(), PERIOD_CURRENT, 3) > iClose(Symbol(), PERIOD_CURRENT, 2) && iOpen(Symbol(), PERIOD_CURRENT, 3) < iOpen(Symbol(), PERIOD_CURRENT, 2))
{
return THREE_BLACK_CROWS;
}
else if (close > open && open == low && close == high)
{
return MARUBOZU;
}
else if (close < open && close < low && open > high)
{
return KICKING;
}
else if (close < open && close < low && open > high && iClose(Symbol(), PERIOD_CURRENT, 2) > iHigh(Symbol(), PERIOD_CURRENT, 2))
{
return TRI_STAR;
}
else if (close > open && close == high && open < low)
{
return LADDER_BOTTOM;
}
else if (close > open && open > high && iOpen(Symbol(), PERIOD_CURRENT, 2) < iLow(Symbol(), PERIOD_CURRENT, 2))
{
return DOWNSIDE_GAP_THREE_METHODS;
}
else if (close > open && open > high && iOpen(Symbol(), PERIOD_CURRENT, 2) > iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) < iLow(Symbol(), PERIOD_CURRENT, 2))
{
return TASUKI_GAP;
}
else if (close > open && open < low && close > high && iOpen(Symbol(), PERIOD_CURRENT, 2) > iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) < iOpen(Symbol(), PERIOD_CURRENT, 2))
{
return MATCHING_LOW;
}
else if (close < open && open > high && iOpen(Symbol(), PERIOD_CURRENT, 2) < iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) > iOpen(Symbol(), PERIOD_CURRENT, 2))
{
return UPSIDE_GAP_TWO_CROWS;
}
else if (close > open && close < iOpen(Symbol(), PERIOD_CURRENT, 2) && iOpen(Symbol(), PERIOD_CURRENT, 2) > iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) < low)
{
return DOWN_GAP_SIDE_BY_SIDE_WHITE_LINES;
}
else if (close < open && open > iClose(Symbol(), PERIOD_CURRENT, 2) && iOpen(Symbol(), PERIOD_CURRENT, 2) < iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) > high)
{
return UP_GAP_SIDE_BY_SIDE_WHITE_LINES;
}
else if (close > open && open == high && close == low)
{
return LADDER_TOP;
}
else if (close < open && close > low && open < high)
{
return THRUSTING;
}
else if (close > open && close > high && open < low)
{
return CLOSING_MARUBOZU;
}
else if (close > open && open < low && close > high && iOpen(Symbol(), PERIOD_CURRENT, 2) < iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) > iOpen(Symbol(), PERIOD_CURRENT, 2))
{
return UPSIDE_GAP_THREE_METHODS;
}
else if (close < open && close > low && open < high && iClose(Symbol(), PERIOD_CURRENT, 2) < iLow(Symbol(), PERIOD_CURRENT, 2))
{
return TWO_CROWS;
}
else if (close > open && open < low && close > high && iOpen(Symbol(), PERIOD_CURRENT, 2) > iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) < iOpen(Symbol(), PERIOD_CURRENT, 2))
{
return ISLAND_REVERSAL;
}
else
{
return NONE;
}
}
- Post #62,065
- Quote
- Jun 28, 2023 1:20am Jun 28, 2023 1:20am
Dislikedplease coder in the house i need your help to help me correct the errors in this code and help me compile it as ea ,i believe it will help many traders as i have benefited alot from this platform pls dont let this call for help go without been attended to as i have made many of such calls without being attended to.am just a baby coder trying to survive in d big occean of trading forex,pls help me and others who will benefit from this perfect this code,thank u in advance // MACD Expert Advisor with Candlestick Pattern Detection // Parameters: FastEMA...Ignored
Inserted Code
// MACD Expert Advisor with Candlestick Pattern Detection // Parameters: FastEMA = 21, SlowEMA = 13, SignalSMA = 8 input int FastEMA = 21; input int SlowEMA = 13; input int SignalSMA = 8; input double LotSize = 0.01; // Fixed lot size input double StopLossPercentage = 0.5; // Stop loss as a percentage of ADR input double TakeProfitPercentage = 1.0; // Take profit as a percentage of ADR input int NumberOfTrades = 5; // Number of trades to execute input int MagicNumber = 123456; // Unique identifier for trades input string Comment = "MACD EA"; // Comment for trades input double TrailingStopPips = 20; // Trailing stop in pips input bool EnableNewsFilter = true; // Enable economic news filter input int NewsImpactLevel = 2; // Minimum impact level of news to consider input bool EnableATRFilter = true; // Enable ATR filter input double ATRMultiplier = 2.0; // ATR multiplier for filtering input bool EnableCandlestickPattern = true; // Enable candlestick pattern detection input double MaxRiskPercent = 2.0; // Maximum risk per trade as a percentage of account equity input int VolatilityPeriod = 14; // Period for calculating market volatility input double VolatilityThreshold = 0.5; // Minimum volatility level to trade input int TrendConfirmationPeriod = 20; // Period for confirming the trend input bool CloseOnReversal = false; // Close trade on market reversal input string IndicatorNames = ""; // Names of multiple indicators separated by comma input int MaxTradesPerStrategy = 3; // Maximum number of trades per strategy input int MaxTotalTrades = 10; // Maximum total number of trades input bool UseVolatilityFilter = true; // Enable volatility filter input double MinVolatilityPercent = 0.5; // Minimum volatility level as a percentage of average true range (ATR) input bool UseTradeExitStrategy = true; // Enable trade exit strategy input int NewsImpactFilter = 2; // Minimum impact level of news to trade (0 - Low, 1 - Medium, 2 - High) input bool UseDiversification = true; // Enable diversification of trading strategy input int MaxTradesPerSymbol = 1; // Maximum number of trades per symbol // Global variables double macdBuffer[]; double signalBuffer[]; double histogramBuffer[]; // Candlestick pattern enumeration enum CandlestickPattern { BULLISH_ENGULFING, BEARISH_ENGULFING, HAMMER, HANGING_MAN, SHOOTING_STAR, INVERTED_HAMMER, DOJI, SPINNING_TOP, PIERCING_LINE, THREE_WHITE_SOLDIERS, THREE_STARS_IN_THE_SOUTH, DRAGONFLY_DOJI, THREE_OUTSIDE_UP, THREE_OUTSIDE_DOWN, GRAVESTONE_DOJI, DARK_CLOUD_COVER, THREE_INSIDE_UP, THREE_INSIDE_DOWN, ABANDONED_BABY, THREE_BLACK_CROWS, MARUBOZU, KICKING, TRI_STAR, LADDER_BOTTOM, DOWNSIDE_GAP_THREE_METHODS, TASUKI_GAP, MATCHING_LOW, UPSIDE_GAP_TWO_CROWS, DOWN_GAP_SIDE_BY_SIDE_WHITE_LINES, UP_GAP_SIDE_BY_SIDE_WHITE_LINES, LADDER_TOP, THRUSTING, CLOSING_MARUBOZU, UPSIDE_GAP_THREE_METHODS, TWO_CROWS, ISLAND_REVERSAL, NONE }; // Initialization function int OnInit() { // Add indicators IndicatorSetInteger(INDICATOR_DIGITS, Digits); SetIndexStyle(0, DRAW_LINE); SetIndexBuffer(0, macdBuffer); SetIndexStyle(1, DRAW_LINE); SetIndexBuffer(1, signalBuffer); SetIndexStyle(2, DRAW_HISTOGRAM); SetIndexBuffer(2, histogramBuffer); // Set indicator parameters SetIndexShift(0, SlowEMA); SetIndexShift(1, SignalSMA); // Set the necessary indicator buffers for calculation SetIndexBuffer(0, macdBuffer); SetIndexBuffer(1, signalBuffer); SetIndexBuffer(2, histogramBuffer); return INIT_SUCCEEDED; } // Deinitialization function void OnDeinit(const int reason) { // Free indicator buffers ArrayFree(macdBuffer); ArrayFree(signalBuffer); ArrayFree(histogramBuffer); } // Main trading function void OnTick() { // Check for news filter if (EnableNewsFilter) { // Check for upcoming economic news events datetime currentTime = TimeCurrent(); datetime newsTime; int newsImpact; for (int i = 0; i < NewsTotal(); i++) { newsTime = NewsTime(i); newsImpact = NewsImpact(i); // Check if there is an upcoming news event with the desired impact level if (newsTime > currentTime && newsImpact >= NewsImpactLevel) { return; // Skip trading during news events } } } // Calculate MACD values int macdCalc = iMACD(Symbol(), PERIOD_CURRENT, FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE, MODE_MAIN, 0); // Get the current MACD, Signal, and Histogram values double currentMACD = macdBuffer[0]; double currentSignal = signalBuffer[0]; double currentHistogram = histogramBuffer[0]; // Calculate candlestick pattern CandlestickPattern pattern = GetCandlestickPattern(); // Add your trading logic based on the MACD, candlestick pattern, and other parameters // ... } // Function to detect candlestick pattern CandlestickPattern GetCandlestickPattern() { double open = iOpen(Symbol(), PERIOD_CURRENT, 1); double close = iClose(Symbol(), PERIOD_CURRENT, 1); double high = iHigh(Symbol(), PERIOD_CURRENT, 1); double low = iLow(Symbol(), PERIOD_CURRENT, 1); double bodySize = MathAbs(close - open); double upperShadow = high - MathMax(close, open); double lowerShadow = MathMin(close, open) - low; double totalSize = bodySize + upperShadow + lowerShadow; // Check for bearish candlestick patterns if (close > open && close > high - bodySize / 2 && open <= low + bodySize / 2) { return BULLISH_ENGULFING; } else if (close < open && open > high - bodySize / 2 && close <= low + bodySize / 2) { return BEARISH_ENGULFING; } else if (close < open && bodySize > 2 * upperShadow && lowerShadow < upperShadow / 3) { return HAMMER; } else if (close < open && bodySize > 2 * upperShadow && upperShadow < lowerShadow / 3) { return HANGING_MAN; } else if (close < open && bodySize > upperShadow + lowerShadow && upperShadow < lowerShadow / 4) { return SHOOTING_STAR; } else if (close > open && bodySize > upperShadow + lowerShadow && lowerShadow < upperShadow / 4) { return INVERTED_HAMMER; } else if (bodySize < totalSize / 10 && MathAbs(open - close) < bodySize / 3) { return DOJI; } else if (bodySize < totalSize / 3 && upperShadow > bodySize / 2 && lowerShadow > bodySize / 2) { return SPINNING_TOP; } else if (close < open && close > open - bodySize / 2 && close > (high + low) / 2 && open <= (high + low) / 2) { return PIERCING_LINE; } else if (close > open && open < (high + low) / 2 && close >= (high + low) / 2) { return THREE_WHITE_SOLDIERS; } else if (close < open && open > (high + low) / 2 && close <= (high + low) / 2) { return THREE_STARS_IN_THE_SOUTH; } else if (close == open && upperShadow < bodySize / 2 && lowerShadow > bodySize / 2) { return DRAGONFLY_DOJI; } else if (close > open && open > low && close < (high + low) / 2 && open < (high + low) / 2) { return THREE_OUTSIDE_UP; } else if (close < open && open < high && close > (high + low) / 2 && open > (high + low) / 2) { return THREE_OUTSIDE_DOWN; } else if (close == open && upperShadow > bodySize / 2 && lowerShadow < bodySize / 2) { return GRAVESTONE_DOJI; } else if (close > open && close < open + bodySize / 2 && open >= high - bodySize / 2 && close <= low + bodySize / 2) { return DARK_CLOUD_COVER; } else if (close > open && open < close - bodySize / 2 && open > low + bodySize / 2 && close >= high - bodySize / 2) { return THREE_INSIDE_UP; } else if (close < open && open > close - bodySize / 2 && open > high - bodySize / 2 && close <= low + bodySize / 2) { return THREE_INSIDE_DOWN; } else if (open > high && close < low && iOpen(Symbol(), PERIOD_CURRENT, 2) > iHigh(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) < iLow(Symbol(), PERIOD_CURRENT, 2)) { return ABANDONED_BABY; } else if (close < open && iClose(Symbol(), PERIOD_CURRENT, 2) > iClose(Symbol(), PERIOD_CURRENT, 3) && iOpen(Symbol(), PERIOD_CURRENT, 3) > iClose(Symbol(), PERIOD_CURRENT, 2) && iOpen(Symbol(), PERIOD_CURRENT, 3) < iOpen(Symbol(), PERIOD_CURRENT, 2)) { return THREE_BLACK_CROWS; } else if (close > open && open == low && close == high) { return MARUBOZU; } else if (close < open && close < low && open > high) { return KICKING; } else if (close < open && close < low && open > high && iClose(Symbol(), PERIOD_CURRENT, 2) > iHigh(Symbol(), PERIOD_CURRENT, 2)) { return TRI_STAR; } else if (close > open && close == high && open < low) { return LADDER_BOTTOM; } else if (close > open && open > high && iOpen(Symbol(), PERIOD_CURRENT, 2) < iLow(Symbol(), PERIOD_CURRENT, 2)) { return DOWNSIDE_GAP_THREE_METHODS; } else if (close > open && open > high && iOpen(Symbol(), PERIOD_CURRENT, 2) > iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) < iLow(Symbol(), PERIOD_CURRENT, 2)) { return TASUKI_GAP; } else if (close > open && open < low && close > high && iOpen(Symbol(), PERIOD_CURRENT, 2) > iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) < iOpen(Symbol(), PERIOD_CURRENT, 2)) { return MATCHING_LOW; } else if (close < open && open > high && iOpen(Symbol(), PERIOD_CURRENT, 2) < iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) > iOpen(Symbol(), PERIOD_CURRENT, 2)) { return UPSIDE_GAP_TWO_CROWS; } else if (close > open && close < iOpen(Symbol(), PERIOD_CURRENT, 2) && iOpen(Symbol(), PERIOD_CURRENT, 2) > iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) < low) { return DOWN_GAP_SIDE_BY_SIDE_WHITE_LINES; } else if (close < open && open > iClose(Symbol(), PERIOD_CURRENT, 2) && iOpen(Symbol(), PERIOD_CURRENT, 2) < iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) > high) { return UP_GAP_SIDE_BY_SIDE_WHITE_LINES; } else if (close > open && open == high && close == low) { return LADDER_TOP; } else if (close < open && close > low && open < high) { return THRUSTING; } else if (close > open && close > high && open < low) { return CLOSING_MARUBOZU; } else if (close > open && open < low && close > high && iOpen(Symbol(), PERIOD_CURRENT, 2) < iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) > iOpen(Symbol(), PERIOD_CURRENT, 2)) { return UPSIDE_GAP_THREE_METHODS; } else if (close < open && close > low && open < high && iClose(Symbol(), PERIOD_CURRENT, 2) < iLow(Symbol(), PERIOD_CURRENT, 2)) { return TWO_CROWS; } else if (close > open && open < low && close > high && iOpen(Symbol(), PERIOD_CURRENT, 2) > iClose(Symbol(), PERIOD_CURRENT, 2) && iClose(Symbol(), PERIOD_CURRENT, 2) < iOpen(Symbol(), PERIOD_CURRENT, 2)) { return ISLAND_REVERSAL; } else { return NONE; } }
Regret is Brutal
1
- Post #62,066
- Quote
- Edited 4:16am Jun 28, 2023 4:05am | Edited 4:16am
Disliked{quote} You called function NewsTotal, NewsTime & NewsImpact in your code but there is no such function in MQL4 so you need to define the function, though i fixed IMACD error in the code // MACD Expert Advisor with Candlestick Pattern Detection // Parameters: FastEMA = 21, SlowEMA = 13, SignalSMA = 8 input int FastEMA = 21; input int SlowEMA = 13; input int SignalSMA = 8; input double LotSize = 0.01; // Fixed lot size input double StopLossPercentage = 0.5; // Stop loss as a percentage of ADR input double TakeProfitPercentage = 1.0; // Take profit...Ignored
- Post #62,067
- Quote
- Jun 28, 2023 5:02am Jun 28, 2023 5:02am
- | Joined Sep 2020 | Status: Member | 354 Posts
please somebody give TRADE MANAGER EA for MT4
- Post #62,068
- Quote
- Edited 6:00am Jun 28, 2023 5:24am | Edited 6:00am
Disliked{quote} maybe this EA can do what you want. it has hidden/virtual SL & TP. it has breakeven and trailing stop functions. adjusting the normal SL & TP can be done manually with 2 click s of a mouse. please test it on Demo at first. https://www.mql5.com/en/code/19776Ignored
its not working when i zero them and on default its not working, thank you for your effort to help
please if you can help to make it work i marked most important
- Post #62,069
- Quote
- Jun 28, 2023 11:20am Jun 28, 2023 11:20am
Good afternoon.
Please write Expert on the basis of standard terminal indicators AC + AO.
Opening a position when the color matches. Color change feedback.
take + stop.
It is important to work on non-standard charts (Renko, Ranger bars, etc.)
Thank you in advance
Please write Expert on the basis of standard terminal indicators AC + AO.
Opening a position when the color matches. Color change feedback.
take + stop.
It is important to work on non-standard charts (Renko, Ranger bars, etc.)
Thank you in advance
- Post #62,070
- Quote
- Jun 28, 2023 1:13pm Jun 28, 2023 1:13pm
Disliked{quote} thanks for taking intrest to reply me and correcting the errors pls kindly help me correct all the errors,and define the news function as u stated and compile it to a working functioning ea am just a baby coder trying to make profit from the market i was able to write this code via various online studies and am not a professional like u guys pls help me out.pls help me finish the work to become a working ea,honestly this is the best i can do.all i was trying to do is to make it filter the news.thanksIgnored
// MACD Expert Advisor with Candlestick Pattern Detection
// Parameters: FastEMA = 21, SlowEMA = 13, SignalSMA = 8
input int FastEMA = 21;
input int SlowEMA = 13;
input int SignalSMA = 8;
input double LotSize = 0.01; // Fixed lot size
input double StopLossPercentage = 0.5; // Stop loss as a percentage of ADR
input double TakeProfitPercentage = 1.0; // Take profit as a percentage of ADR
input int NumberOfTrades = 5; // Number of trades to execute
input int MagicNumber = 123456; // Unique identifier for trades
input string Comment = "MACD EA"; // Comment for trades
input double TrailingStopPips = 20; // Trailing stop in pips
input bool EnableNewsFilter = true; // Enable economic news filter
input int NewsImpactLevel = 2; // Minimum impact level of news to consider
input bool EnableATRFilter = true; // Enable ATR filter
input double ATRMultiplier = 2.0; // ATR multiplier for filtering
input bool EnableCandlestickPattern = true; // Enable candlestick pattern detection
input double MaxRiskPercent = 2.0; // Maximum risk per trade as a percentage of account equity
input int VolatilityPeriod = 14; // Period for calculating market volatility
input double VolatilityThreshold = 0.5; // Minimum volatility level to trade
input int TrendConfirmationPeriod = 20; // Period for confirming the trend
input bool CloseOnReversal = false; // Close trade on market reversal
input string IndicatorNames = ""; // Names of multiple indicators separated by comma
input int MaxTradesPerStrategy = 3; // Maximum number of trades per strategy
input int MaxTotalTrades = 10; // Maximum total number of trades
input bool UseVolatilityFilter = true; // Enable volatility filter
input double MinVolatilityPercent = 0.5; // Minimum volatility level as a percentage of average true range (ATR)
input bool UseTradeExitStrategy = true; // Enable trade exit strategy
input int NewsImpactFilter = 2; // Minimum impact level of news to trade (0 - Low, 1 - Medium, 2 - High)
input bool UseDiversification = true; // Enable diversification of trading strategy
input int MaxTradesPerSymbol = 1; // Maximum number of trades per symbol
// Global variables
double macdBuffer[];
double signalBuffer[];
double histogramBuffer[];
// Candlestick pattern enumeration
enum CandlestickPattern
{
BULLISH_ENGULFING,
BEARISH_ENGULFING,
HAMMER,
HANGING_MAN,
SHOOTING_STAR,
INVERTED_HAMMER,
DOJI,
SPINNING_TOP,
PIERCING_LINE,
THREE_WHITE_SOLDIERS,
THREE_STARS_IN_THE_SOUTH,
DRAGONFLY_DOJI,
THREE_OUTSIDE_UP,
THREE_OUTSIDE_DOWN,
GRAVESTONE_DOJI,
DARK_CLOUD_COVER,
THREE_INSIDE_UP,
THREE_INSIDE_DOWN,
ABANDONED_BABY,
THREE_BLACK_CROWS,
MARUBOZU,
KICKING,
TRI_STAR,
LADDER_BOTTOM,
DOWNSIDE_GAP_THREE_METHODS,
TASUKI_GAP,
MATCHING_LOW,
ENGULFING,
HARAMI,
MORNING_STAR,
EVENING_STAR,
BELT_HOLD,
COUNTER_ATTACK,
SEPARATING_LINES,
DOJI_STAR,
MEETING_LINES,
KICKING_BULL_BEAR,
STALLED_PATTERN,
UNIQUE_THREE_RIVER_BOTTOM,
UPSIDE_GAP_TWO_CROWS,
HANGING_MAN_AT_NECKLINE,
BELT_HOLD_AT_NECKLINE,
UPSIDE_TASUKI_GAP,
TWO_CROWS,
THREE_CROWS,
ADVANCE_BLOCK,
THREE_METHODS,
SIDE_BY_SIDE_WHITE_LINES,
SIDE_BY_SIDE_BLACK_LINES,
HIGH_WAVE,
SPINNING_TOP_DOJI,
UP_GAP_TWO_CROWS,
DOWN_GAP_THREE_METHODS,
TRISTAR_DOJI,
ABANDONED_BABY_DOJI,
TWO_CROWS_DOJI,
THREE_BLACK_CROWS_DOJI,
THREE_INSIDE_UP_DOJI,
THREE_OUTSIDE_DOWN_DOJI,
GRAVESTONE_DOJI_DOJI,
MORNING_DOJI_STAR,
MORNING_STAR_DOJI,
DRAGONFLY_DOJI_DOJI,
EVENING_DOJI_STAR,
EVENING_STAR_DOJI,
SHOOTING_STAR_DOJI,
HARAMI_CROSS,
HARAMI_DOJI,
HANGING_MAN_DOJI,
BELT_HOLD_DOJI,
UPSIDE_GAP_TWO_CROWS_DOJI,
UPSIDE_GAP_TWO_CROWS_DOJI_DOJI,
TRISTAR_DOJI_DOJI,
HARAMI_DOJI_DOJI,
THREE_METHODS_DOJI,
THREE_METHODS_DOJI_DOJI,
THREE_BLACK_CROWS_DOJI_DOJI,
STALLED_PATTERN_DOJI,
ABANDONED_BABY_DOJI_DOJI,
SIDE_BY_SIDE_WHITE_LINES_DOJI,
SPINNING_TOP_DOJI_DOJI,
THREE_CROWS_DOJI,
THREE_INSIDE_DOWN_DOJI,
THREE_INSIDE_UP_DOJI_DOJI,
BELT_HOLD_DOJI_DOJI,
DOWNSIDE_GAP_THREE_METHODS_DOJI,
THREE_OUTSIDE_DOWN_DOJI_DOJI,
THREE_OUTSIDE_UP_DOJI,
SEPARATING_LINES_DOJI,
HIGH_WAVE_DOJI,
ENGULFING_DOJI,
SIDE_BY_SIDE_BLACK_LINES_DOJI,
LADDER_BOTTOM_DOJI,
UNIQUE_THREE_RIVER_BOTTOM_DOJI,
TWO_CROWS_DOJI_DOJI
};
// Function to check if a given value is within a range
bool isWithinRange(double value, double lowerBound, double upperBound)
{
return value >= lowerBound && value <= upperBound;
}
// Function to check for a bullish engulfing pattern
bool isBullishEngulfing(int index)
{
double prevClose = iClose(NULL, 0, index + 1);
double prevOpen = iOpen(NULL, 0, index + 1);
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
return currentOpen < prevOpen && currentClose > prevClose && currentOpen > prevClose && currentClose < prevOpen;
}
// Function to check for a bearish engulfing pattern
bool isBearishEngulfing(int index)
{
double prevClose = iClose(NULL, 0, index + 1);
double prevOpen = iOpen(NULL, 0, index + 1);
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
return currentOpen > prevOpen && currentClose < prevClose && currentOpen < prevClose && currentClose > prevOpen;
}
// Function to check for a hammer pattern
bool isHammer(int index)
{
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
double currentHigh = iHigh(NULL, 0, index);
double currentLow = iLow(NULL, 0, index);
double bodySize = MathAbs(currentClose - currentOpen);
double upperShadowSize = currentHigh - MathMax(currentOpen, currentClose);
double lowerShadowSize = MathMin(currentOpen, currentClose) - currentLow;
return bodySize < upperShadowSize && bodySize < lowerShadowSize && currentClose > currentOpen && upperShadowSize >= 2 * bodySize;
}
// Function to check for a hanging man pattern
bool isHangingMan(int index)
{
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
double currentHigh = iHigh(NULL, 0, index);
double currentLow = iLow(NULL, 0, index);
double bodySize = MathAbs(currentClose - currentOpen);
double upperShadowSize = currentHigh - MathMax(currentOpen, currentClose);
double lowerShadowSize = MathMin(currentOpen, currentClose) - currentLow;
return bodySize < upperShadowSize && bodySize < lowerShadowSize && currentClose < currentOpen && upperShadowSize >= 2 * bodySize;
}
// Function to check for a shooting star pattern
bool isShootingStar(int index)
{
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
double currentHigh = iHigh(NULL, 0, index);
double currentLow = iLow(NULL, 0, index);
double bodySize = MathAbs(currentClose - currentOpen);
double upperShadowSize = currentHigh - MathMax(currentOpen, currentClose);
double lowerShadowSize = MathMin(currentOpen, currentClose) - currentLow;
return bodySize < upperShadowSize && bodySize < lowerShadowSize && currentClose < currentOpen && lowerShadowSize >= 2 * bodySize;
}
// Function to check for an inverted hammer pattern
bool isInvertedHammer(int index)
{
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
double currentHigh = iHigh(NULL, 0, index);
double currentLow = iLow(NULL, 0, index);
double bodySize = MathAbs(currentClose - currentOpen);
double upperShadowSize = currentHigh - MathMax(currentOpen, currentClose);
double lowerShadowSize = MathMin(currentOpen, currentClose) - currentLow;
return bodySize < upperShadowSize && bodySize < lowerShadowSize && currentClose > currentOpen && lowerShadowSize >= 2 * bodySize;
}
// Function to check for a doji pattern
bool isDoji(int index)
{
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
double currentHigh = iHigh(NULL, 0, index);
double currentLow = iLow(NULL, 0, index);
double bodySize = MathAbs(currentClose - currentOpen);
double totalSize = currentHigh - currentLow;
return bodySize < 0.1 * totalSize;
}
// Function to check for a spinning top pattern
bool isSpinningTop(int index)
{
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
double currentHigh = iHigh(NULL, 0, index);
double currentLow = iLow(NULL, 0, index);
double bodySize = MathAbs(currentClose - currentOpen);
double totalSize = currentHigh - currentLow;
return bodySize < 0.3 * totalSize;
}
// Function to check for a piercing line pattern
bool isPiercingLine(int index)
{
double prevClose = iClose(NULL, 0, index + 1);
double prevOpen = iOpen(NULL, 0, index + 1);
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
double currentHigh = iHigh(NULL, 0, index);
double prevLow = iLow(NULL, 0, index + 1);
double bodySize = MathAbs(currentClose - currentOpen);
double totalSize = currentHigh - prevLow;
return currentOpen < prevClose && currentClose > prevOpen && bodySize >= 0.5 * totalSize && bodySize <= totalSize;
}
// Function to check for a three white soldiers pattern
bool isThreeWhiteSoldiers(int index)
{
double prevClose = iClose(NULL, 0, index + 1);
double prevOpen = iOpen(NULL, 0, index + 1);
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
double currentHigh = iHigh(NULL, 0, index);
double prevLow = iLow(NULL, 0, index + 1);
double bodySize = MathAbs(currentClose - currentOpen);
double totalSize = currentHigh - prevLow;
return currentOpen < prevClose && currentClose > prevOpen && bodySize >= 0.5 * totalSize && bodySize <= totalSize;
}
// Function to check for a three stars in the south pattern
bool isThreeStarsInTheSouth(int index)
{
double prevClose = iClose(NULL, 0, index + 1);
double prevOpen = iOpen(NULL, 0, index + 1);
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
double currentHigh = iHigh(NULL, 0, index);
double prevLow = iLow(NULL, 0, index + 1);
double bodySize = MathAbs(currentClose - currentOpen);
double totalSize = currentHigh - prevLow;
return currentOpen < prevClose && currentClose > prevOpen && bodySize >= 0.5 * totalSize && bodySize <= totalSize;
}
// Function to check for a dragonfly doji pattern
bool isDragonflyDoji(int index)
{
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
double currentHigh = iHigh(NULL, 0, index);
double currentLow = iLow(NULL, 0, index);
double bodySize = MathAbs(currentClose - currentOpen);
double totalSize = currentHigh - currentLow;
return bodySize < 0.1 * totalSize && currentClose == currentHigh && currentOpen == currentLow;
}
// Function to check for a three outside up pattern
bool isThreeOutsideUp(int index)
{
double prevClose = iClose(NULL, 0, index + 1);
double prevOpen = iOpen(NULL, 0, index + 1);
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
return currentClose > prevClose && currentOpen < prevOpen && currentClose > currentOpen && prevClose > prevOpen;
}
// Function to check for a three outside down pattern
bool isThreeOutsideDown(int index)
{
double prevClose = iClose(NULL, 0, index + 1);
double prevOpen = iOpen(NULL, 0, index + 1);
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
return currentClose < prevClose && currentOpen > prevOpen && currentClose < currentOpen && prevClose < prevOpen;
}
// Function to check for a gravestone doji pattern
bool isGravestoneDoji(int index)
{
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
double currentHigh = iHigh(NULL, 0, index);
double currentLow = iLow(NULL, 0, index);
double bodySize = MathAbs(currentClose - currentOpen);
double totalSize = currentHigh - currentLow;
return bodySize < 0.1 * totalSize && currentClose == currentLow && currentOpen == currentHigh;
}
// Function to check for a dark cloud cover pattern
bool isDarkCloudCover(int index)
{
double prevClose = iClose(NULL, 0, index + 1);
double prevOpen = iOpen(NULL, 0, index + 1);
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
double currentHigh = iHigh(NULL, 0, index);
double bodySize = MathAbs(currentClose - currentOpen);
double totalSize = currentHigh - prevClose;
return currentOpen > prevClose && currentClose < prevOpen && bodySize >= 0.5 * totalSize && bodySize <= totalSize;
}
// Function to check for a three inside up pattern
bool isThreeInsideUp(int index)
{
double prevClose = iClose(NULL, 0, index + 1);
double prevOpen = iOpen(NULL, 0, index + 1);
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
return currentClose > prevClose && currentOpen < prevOpen && currentClose < currentOpen && prevClose < prevOpen;
}
// Function to check for a three inside down pattern
bool isThreeInsideDown(int index)
{
double prevClose = iClose(NULL, 0, index + 1);
double prevOpen = iOpen(NULL, 0, index + 1);
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
return currentClose < prevClose && currentOpen > prevOpen && currentClose > currentOpen && prevClose > prevOpen;
}
// Function to check for an abandoned baby pattern
bool isAbandonedBaby(int index)
{
double prevClose = iClose(NULL, 0, index + 1);
double prevOpen = iOpen(NULL, 0, index + 1);
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
double currentLow = iLow(NULL, 0, index);
double prevHigh = iHigh(NULL, 0, index + 1);
return currentOpen > prevHigh && currentClose < prevClose && currentClose > prevOpen && currentLow < prevClose;
}
// Function to check for a morning star pattern
bool isMorningStar(int index)
{
double prevClose = iClose(NULL, 0, index + 2);
double prevOpen = iOpen(NULL, 0, index + 2);
double currentClose = iClose(NULL, 0, index + 1);
double currentOpen = iOpen(NULL, 0, index + 1);
double currentHigh = iHigh(NULL, 0, index + 1);
double prevLow = iLow(NULL, 0, index + 2);
return currentOpen < prevClose && currentClose > prevClose && currentClose > currentOpen && currentClose > prevOpen && currentOpen > prevLow && currentHigh > prevClose;
}
// Function to check for an evening star pattern
bool isEveningStar(int index)
{
double prevClose = iClose(NULL, 0, index + 2);
double prevOpen = iOpen(NULL, 0, index + 2);
double currentClose = iClose(NULL, 0, index + 1);
double currentOpen = iOpen(NULL, 0, index + 1);
double currentHigh = iHigh(NULL, 0, index + 1);
double prevLow = iLow(NULL, 0, index + 2);
return currentOpen > prevClose && currentClose < prevClose && currentClose < currentOpen && currentClose < prevOpen && currentOpen < prevLow && currentHigh < prevClose;
}
// Function to check for a bullish harami pattern
bool isBullishHarami(int index)
{
double prevClose = iClose(NULL, 0, index + 1);
double prevOpen = iOpen(NULL, 0, index + 1);
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
double currentHigh = iHigh(NULL, 0, index);
double currentLow = iLow(NULL, 0, index);
double bodySize = MathAbs(currentClose - currentOpen);
double prevBodySize = MathAbs(prevClose - prevOpen);
return currentClose > currentOpen && currentOpen > prevClose && currentClose < prevOpen && bodySize < prevBodySize && currentHigh > prevOpen && currentLow < prevClose;
}
// Function to check for a bearish harami pattern
bool isBearishHarami(int index)
{
double prevClose = iClose(NULL, 0, index + 1);
double prevOpen = iOpen(NULL, 0, index + 1);
double currentClose = iClose(NULL, 0, index);
double currentOpen = iOpen(NULL, 0, index);
double currentHigh = iHigh(NULL, 0, index);
double currentLow = iLow(NULL, 0, index);
double bodySize = MathAbs(currentClose - currentOpen);
double prevBodySize = MathAbs(prevClose - prevOpen);
return currentOpen > currentClose && currentClose > prevOpen && currentOpen < prevClose && bodySize < prevBodySize && currentHigh > prevClose && currentLow < prevOpen;
}
- Post #62,071
- Quote
- Jun 28, 2023 4:07pm Jun 28, 2023 4:07pm
- Joined May 2009 | Status: Member | 3,358 Posts
Hey,
I found this EA and would like to know if it's possible to have orders executed based on standard Fibonacci Retracement Levels instead of the yellow trigger line which can be only defined by a fixed distance.
EA: https://www.forexfactory.com/thread/...robot-by-steve
The new logic behind this is supposed to be that orders are then executed on x fibonnaci retracement level as soon as price broke one end of the range.
BUY order example
1.) Range = 00:00 - 00:15
2.) Price breaks the low of the range at x time after 00:15
3.) Plot a Fib based on this range
4.) Price reverses back to x Fib level = BUY
SELL order example
1.) Range = 00:00 - 00:15
2.) Price breaks the high of the range at x time after 00:15
3.) Plot a Fib based on this range
4.) Price reverses back to x Fib level = SELL
I found this EA and would like to know if it's possible to have orders executed based on standard Fibonacci Retracement Levels instead of the yellow trigger line which can be only defined by a fixed distance.
EA: https://www.forexfactory.com/thread/...robot-by-steve
The new logic behind this is supposed to be that orders are then executed on x fibonnaci retracement level as soon as price broke one end of the range.
BUY order example
1.) Range = 00:00 - 00:15
2.) Price breaks the low of the range at x time after 00:15
3.) Plot a Fib based on this range
4.) Price reverses back to x Fib level = BUY
SELL order example
1.) Range = 00:00 - 00:15
2.) Price breaks the high of the range at x time after 00:15
3.) Plot a Fib based on this range
4.) Price reverses back to x Fib level = SELL
Wax On, Wax Off
- Post #62,072
- Quote
- Jun 28, 2023 4:21pm Jun 28, 2023 4:21pm
- Joined Apr 2019 | Status: MEMBER | 88 Posts
Let me use this opportunity to say thank you and God continue to bless all great coder.
BestTraderEv, BlueRain, CJA, Hanover, Jblanked, Jeanlouie, Tintep, Zbig, and all the amazing Coders,
We appreciate you all.
1
- Post #62,073
- Quote
- Jun 28, 2023 4:23pm Jun 28, 2023 4:23pm
- Joined Apr 2019 | Status: MEMBER | 88 Posts
DislikedDear BestTraderEv, BlueRain, CJA, Hanover, Jblanked, Jeanlouie, Tintep, Zbig, and all the amazing Coders, I wanted to take a moment to express my deepest gratitude for each one of you. Your dedication and selflessness in adding value to the lives of traders on the Forex Factory forum, particularly through the <I will code your EAs and Indicators for no charge> have made an incredible impact. Through your generous contributions of time and expertise, you have not only created, modified, and re-modified the indicators and requests we submitted, but...Ignored
1
- Post #62,074
- Quote
- Jun 29, 2023 5:46am Jun 29, 2023 5:46am
Hi Coders,
is anybody so kind to add an MovAvg on this VolumeColor Indicator?
VolumeMA as reference.
Thanks alot.
Greetings Thorsten
is anybody so kind to add an MovAvg on this VolumeColor Indicator?
VolumeMA as reference.
Thanks alot.
Greetings Thorsten
Attached File(s)
VolumeColor.mq4
4 KB
|
159 downloads
volumeMA.mq4
7 KB
|
150 downloads
- Post #62,075
- Quote
- Jun 29, 2023 2:29pm Jun 29, 2023 2:29pm
""
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Blue
extern int StartHour=0;
extern int EndHour=22;
extern int FontSize=0;
extern color TextColor=Silver;
double UpperCh[], LowerCh[];
int init()
{
IndicatorDigits(Digits);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,UpperCh);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,LowerCh);
return(0);
}
int deinit()
{
ObjectsDeleteAll();
return(0);
}
int start()
{
if(Bars<=3) return(0);
int ExtCountedBars=IndicatorCounted();
if (ExtCountedBars<0) return(-1);
int pos=Bars-2;
if(ExtCountedBars>2) pos=Bars-ExtCountedBars-1;
while(pos>0)
{
datetime EndTime=StrToTime(TimeToStr(Time[pos],TIME_DATE)+" "+DoubleToStr(EndHour,0)+":00");
if (Time[pos]>=EndTime && Time[pos+1]<EndTime)
{
double MaxPrice=High[pos];
double MinPrice=Low[pos];
datetime StartTime=StrToTime(TimeToStr(Time[pos],TIME_DATE)+" "+DoubleToStr(StartHour,0)+":00");
if (StartHour>EndHour) StartTime=StartTime-86400;
int pos_=pos;
while (pos_<Bars && Time[pos_]>=StartTime)
{
MinPrice=MathMin(MinPrice, Low[pos_]);
MaxPrice=MathMax(MaxPrice, High[pos_]);
pos_++;
}
int i;
for (i=pos_-1;i>=pos;i--)
{
UpperCh[i]=MaxPrice;
LowerCh[i]=MinPrice;
}
if (pos!=pos_-1)
{
string ObjName="ChannelSizeLabel "+TimeToStr(Time[pos],TIME_DATE);
string LabelText=""+DoubleToStr((MaxPrice-MinPrice)/Point,0);
if (ObjectFind(ObjName)==-1)
{
ObjectCreate(ObjName, OBJ_TEXT, 0, Time[pos], MinPrice);
}
else
{
ObjectSet(ObjName,OBJPROP_PRICE1,MinPrice);
}
ObjectSetText(ObjName, LabelText, FontSize, "Times New Roman", TextColor);
}
}
else
{
UpperCh[pos]=EMPTY_VALUE;
LowerCh[pos]=EMPTY_VALUE;
}
pos--;
}
return(0);
}
""
Could some one guide me to fix it?
The purpose of indicator is to draw horizontal trend lines at the high and low of Yesterday's Daily chart data. Next it displays High and Low Horizontal lines inside 15 minutes, 30 minutes and 1 hour time frame. It works fine in real time.
Problem: There is a bug inside the code.
Due to this reason, the indicator automatically deletes all kinds of vertical and horizontal trendlines, drawn manually by a human hand after a few minutes time.
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Blue
extern int StartHour=0;
extern int EndHour=22;
extern int FontSize=0;
extern color TextColor=Silver;
double UpperCh[], LowerCh[];
int init()
{
IndicatorDigits(Digits);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,UpperCh);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,LowerCh);
return(0);
}
int deinit()
{
ObjectsDeleteAll();
return(0);
}
int start()
{
if(Bars<=3) return(0);
int ExtCountedBars=IndicatorCounted();
if (ExtCountedBars<0) return(-1);
int pos=Bars-2;
if(ExtCountedBars>2) pos=Bars-ExtCountedBars-1;
while(pos>0)
{
datetime EndTime=StrToTime(TimeToStr(Time[pos],TIME_DATE)+" "+DoubleToStr(EndHour,0)+":00");
if (Time[pos]>=EndTime && Time[pos+1]<EndTime)
{
double MaxPrice=High[pos];
double MinPrice=Low[pos];
datetime StartTime=StrToTime(TimeToStr(Time[pos],TIME_DATE)+" "+DoubleToStr(StartHour,0)+":00");
if (StartHour>EndHour) StartTime=StartTime-86400;
int pos_=pos;
while (pos_<Bars && Time[pos_]>=StartTime)
{
MinPrice=MathMin(MinPrice, Low[pos_]);
MaxPrice=MathMax(MaxPrice, High[pos_]);
pos_++;
}
int i;
for (i=pos_-1;i>=pos;i--)
{
UpperCh[i]=MaxPrice;
LowerCh[i]=MinPrice;
}
if (pos!=pos_-1)
{
string ObjName="ChannelSizeLabel "+TimeToStr(Time[pos],TIME_DATE);
string LabelText=""+DoubleToStr((MaxPrice-MinPrice)/Point,0);
if (ObjectFind(ObjName)==-1)
{
ObjectCreate(ObjName, OBJ_TEXT, 0, Time[pos], MinPrice);
}
else
{
ObjectSet(ObjName,OBJPROP_PRICE1,MinPrice);
}
ObjectSetText(ObjName, LabelText, FontSize, "Times New Roman", TextColor);
}
}
else
{
UpperCh[pos]=EMPTY_VALUE;
LowerCh[pos]=EMPTY_VALUE;
}
pos--;
}
return(0);
}
""
Could some one guide me to fix it?
The purpose of indicator is to draw horizontal trend lines at the high and low of Yesterday's Daily chart data. Next it displays High and Low Horizontal lines inside 15 minutes, 30 minutes and 1 hour time frame. It works fine in real time.
Problem: There is a bug inside the code.
Due to this reason, the indicator automatically deletes all kinds of vertical and horizontal trendlines, drawn manually by a human hand after a few minutes time.
- Post #62,076
- Quote
- Jun 29, 2023 3:04pm Jun 29, 2023 3:04pm
- Joined Dec 2010 | Status: Member | 1,882 Posts
Disliked...indicator automatically deletes all kinds of vertical and horizontal trendlines, drawn manually by a human hand after a few minutes time.Ignored
- Post #62,077
- Quote
- Jun 29, 2023 3:07pm Jun 29, 2023 3:07pm
I have no idea about it, that is why I asked for help!
- Post #62,078
- Quote
- Jun 29, 2023 3:37pm Jun 29, 2023 3:37pm
Hello coders,
Any one can help convert the Daily_Open_line-Mod-X to Colsing time? Now instead of Open Price, I want Closing Price.
Thanks
Any one can help convert the Daily_Open_line-Mod-X to Colsing time? Now instead of Open Price, I want Closing Price.
Thanks
Attached File(s)
Daily_Open_Line_mod-x.mq4
3 KB
|
131 downloads
- Post #62,079
- Quote
- Jun 29, 2023 4:10pm Jun 29, 2023 4:10pm
Hi everyone
Can anyone of you write me a program that shows Current running equity on the chart.
Can anyone of you write me a program that shows Current running equity on the chart.
- Post #62,080
- Quote
- Jun 29, 2023 4:32pm Jun 29, 2023 4:32pm
- Joined Aug 2006 | Status: Member | 4,769 Posts
DislikedHello coders, Any one can help convert the Daily_Open_line-Mod-X to Colsing time? Now instead of Open Price, I want Closing Price. Thanks {file}Ignored
Attached File(s)
common_sr.mq4
38 KB
|
201 downloads
The Only Limit, is the One that you Set Yourself - Felix Baumgartner
3