zigzag+ fibo ea

 
Hello. I've been making the same profit for a long time. Introduction: fibo 23,6 Snow: fibo 38,2 stoploss: fibo 0 rollback: fibo 0 martingel damage. can you make this system ea?
 
omerbas86:

Forum on trading, automated trading systems and testing trading strategies

EA using ZIGZAG

Sergey Golubev, 2018.04.10 16:07

Zigzag EA performance



 

Auto Fibo - indicator for MetaTrader 4 

Auto Fibo - indicator for MetaTrader 4

This indicator is designed to draw a Fibonacci retracement, using as a basis the ZigZag indicator.

 

Fibo Retracement Trader - expert for MetaTrader 5 

This simple Expert Advisor was created to illustrate the capabilities of trading the Fibonacci levels. The EA uses the standard ZigZag indicator (from the standard MetaTrader delivery) as the basis for placing the grid.

 

ZigZag EA - expert for MetaTrader 5 

ZigZag EA - expert for MetaTrader 5

The EA applies data from the ZigZag custom indicator. This indicator is used to define the channel. Buy Stop and Sell Stop pending orders are placed along the channel borders. After a pending order is activated, trailing can be enabled for a position. Stop loss and take profit values are specified in Fibo levels (0.0%, 23.6%, 38.2%, 50%, 61.8%, 100%, 161.8%, 261.8% and 423.6%).

 
omerbas86:

This is an English language forum.

Please only post in English.

I have used the translation tool to edit your initial post.

 
Keith Watford :

Bu bir İngilizce dili forumudur.

Lütfen sadece İngilizce olarak yazınız.

Çeviri aracını ilk yayınınızı yapabiliyor için kullandım.

thank you.

 
Sergey Golubev :

Otomatik Fibo - MetaTrader 4 için gösterge 

Yeah. needs to open an automated process

 
Sergey Golubev:

No ea good working to now

 
Sergey Golubev:

i tried sveral ways to backtest it but it cant backtest, may be its due to the MT4 build. Can you pls look in it. Thanks

 

TRY THIS 

//+------------------------------------------------------------------+
//|                                 Zigzagy Auto Fibo EA.mq4         |
//|                        Converted from Indicator to EA            |
//+------------------------------------------------------------------+
#property strict
// Input parameters
input int ExtDepth = 90;          // ZigZag depth
input int ExtDeviation = 5;       // ZigZag deviation
input int ExtBackstep = 3;        // ZigZag backstep
input double LotSize = 0.1;       // Fixed lot size
input int StopLoss = 100;         // Stop loss in points
input int TakeProfit = 200;       // Take profit in points
input bool UseFiboExpansion = true; // Use Fibo expansion for TP
input double RiskPercent = 2.0;   // Risk percentage per trade
// Global variables
double ZigzagBuffer[];
double HighMapBuffer[];
double LowMapBuffer[];
int lastTradeDirection = 0;       // 1 = Buy, -1 = Sell, 0 = No trade
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
    // Initialize buffers
    ArraySetAsSeries(ZigzagBuffer, true);
    ArraySetAsSeries(HighMapBuffer, true);
    ArraySetAsSeries(LowMapBuffer, true);
    return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
    // Clean up
}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
    // Update ZigZag buffers
    UpdateZigZagBuffers();
    // Get latest ZigZag points
    int pos1 = FindZigZagPoint(1); // Latest swing point
    int pos2 = FindZigZagPoint(2); // Previous swing point
    if (pos1 == -1 || pos2 == -1) return; // Not enough data
    // Calculate Fibonacci levels
    double high = HighMapBuffer[pos1];
    double low = LowMapBuffer[pos2];
    double fibo236 = low + (high - low) * 0.236;
    double fibo382 = low + (high - low) * 0.382;
    double fibo618 = low + (high - low) * 0.618;
    // Trading logic
    if (lastTradeDirection != 1 && Close[1] > fibo618) // Buy condition
    {
        OpenTrade(OP_BUY);
        lastTradeDirection = 1;
    }
    else if (lastTradeDirection != -1 && Close[1] < fibo382) // Sell condition
    {
        OpenTrade(OP_SELL);
        lastTradeDirection = -1;
    }
}
//+------------------------------------------------------------------+
//| Update ZigZag buffers                                            |
//+------------------------------------------------------------------+
void UpdateZigZagBuffers()
{
    // Logic to update ZigZag, HighMap, and LowMap buffers
    // (Copy from the original indicator code)
}
//+------------------------------------------------------------------+
//| Find ZigZag point by index                                       |
//+------------------------------------------------------------------+
int FindZigZagPoint(int index)
{
    int count = 0;
    for (int i = 0; i < Bars; i++)
    {
        if (ZigzagBuffer[i] != 0)
        {
            count++;
            if (count == index) return i;
        }
    }
    return -1;
}
//+------------------------------------------------------------------+
//| Open a trade                                                     |
//+------------------------------------------------------------------+
void OpenTrade(int direction)
{
    double sl = 0, tp = 0;
    double price = (direction == OP_BUY) ? Ask : Bid;
    // Calculate stop loss and take profit
    if (StopLoss > 0) sl = (direction == OP_BUY) ? price - StopLoss * Point : price + StopLoss * Point;
    if (TakeProfit > 0) tp = (direction == OP_BUY) ? price + TakeProfit * Point : price - TakeProfit * Point;
    // Use Fibo expansion for TP if enabled
    if (UseFiboExpansion)
    {
        double expansion = CalculateFiboExpansion();
        tp = (direction == OP_BUY) ? price + expansion : price - expansion;
    }
    // Calculate lot size based on risk
    double lot = CalculateLotSize(StopLoss);
    // Open the trade
    int ticket = OrderSend(Symbol(), direction, lot, price, 3, sl, tp, "Zigzagy Auto Fibo EA", 0, 0, clrNONE);
    if (ticket < 0) Print("Error opening trade: ", GetLastError());
}
//+------------------------------------------------------------------+
//| Calculate lot size based on risk                                 |
//+------------------------------------------------------------------+
double CalculateLotSize(int slPoints)
{
    double riskAmount = AccountBalance() * RiskPercent / 100.0;
    double tickValue = MarketInfo(Symbol(), MODE_TICKVALUE);
    double lot = riskAmount / (slPoints * tickValue);
    return MathMin(lot, MarketInfo(Symbol(), MODE_MAXLOT));
}
//+------------------------------------------------------------------+
//| Calculate Fibonacci expansion                                    |
//+------------------------------------------------------------------+
double CalculateFiboExpansion()
{
    // Logic to calculate Fibo expansion (e.g., 161.8% of the prior wave)
    return 0.0; // Replace with actual calculation
}
//+------------------------------------------------------------------+