My indicator "iCUSTOM" template

MQL4 Experts

Trabalho concluído

Tempo de execução 37 segundos

Termos de Referência

i have an indicator called "MA_Direction_SingleBuffer", and then create another indicator called "TrendStrength_BuyOnly" to calcualate the values of  "MA_Direction_SingleBuffer", until here, it seems work well  ( i am not sure, but at least both are work well when i put them in chart), now i want to create a EA, that can read the value of "TrendStrength_BuyOnly" for every bar, but doesn't work, so i wonld like someone help me to fix them, and tell me what's wrong with my code, pls make sure you can fix it before take this job

Here are the indicators and EA



MA_Direction_SingleBuffe

//+------------------------------------------------------------------+
//|     MA_Direction_SingleBuffer_MQL4.mq4                          |
//|      |
//|   適用於 MQL4,便於 EA 調用 buffer[0],與圖表分色並存           |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Lime    // Up
#property indicator_color2 Red     // Down
#property indicator_color3 Gray    // Flat
#property strict

input int MAPeriod = 14;

// Buffers for plotting (only one active per bar)
double bufferUp[];    // buffer 0 - EA 調用此值
double bufferDown[];  // buffer 1 - 僅視覺繪圖用
double bufferFlat[];  // buffer 2 - 僅視覺繪圖用

//+------------------------------------------------------------------+
int OnInit()
  {
   IndicatorShortName("MA_Direction_SingleBuffer");

   SetIndexBuffer(0, bufferUp);
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 2);
   SetIndexLabel(0, "Slope");

   SetIndexBuffer(1, bufferDown);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 2);
   SetIndexLabel(1, "Down");

   SetIndexBuffer(2, bufferFlat);
   SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 1);
   SetIndexLabel(2, "Flat");

   return INIT_SUCCEEDED;
  }
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
   if (rates_total < MAPeriod + 2)
      return 0;

   int start = MathMax(prev_calculated - 1, 1);

   for (int i = start; i < rates_total - 1; i++)
     {
      double ma_now = iMA(NULL, 0, MAPeriod, 0, MODE_SMA, PRICE_CLOSE, i);
      double ma_prev = iMA(NULL, 0, MAPeriod, 0, MODE_SMA, PRICE_CLOSE, i + 1);
      double slope = ma_now - ma_prev;

      // 寫入主輸出 buffer(供 EA 調用)
      bufferUp[i] = slope;

      // 視覺分色(其他兩 buffer 只為圖表用)
      if (slope > 0)
        {
         bufferDown[i] = 0;
         bufferFlat[i] = 0;
        }
      else if (slope < 0)
        {
         bufferDown[i] = slope;
         bufferFlat[i] = 0;
         bufferUp[i] = 0;
        }
      else
        {
         bufferDown[i] = 0;
         bufferFlat[i] = 0.0000001;  // 微量顯示灰色線
         bufferUp[i] = 0;
        }
     }

   return rates_total;
  }


TrendStrength_BuyOnly

//+------------------------------------------------------------------+
//|     TrendStrength_BuyOnly.mq4                                    |
//|     計算近 LookbackBars 根 MA 斜率的趨勢強度(做多為主)         |
//|     資料來源:MA_Direction_SingleBuffer 的 buffer[0]            |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_width1 2
#property indicator_label1 "TrendStrength_BuyOnly"
#property strict

// --- 輸入參數
input int MAPeriod = 14;                 // 傳給 MA_Direction_SingleBuffer 用
input int LookbackBars = 90;            // 回顧 K 線數量
input double SlopeThreshold = 0.05;     // 視為有效斜率的門檻

// --- 指標 buffer
double TrendStrengthBuffer[];

//+------------------------------------------------------------------+
int OnInit()
  {
   IndicatorShortName("TrendStrength_BuyOnly");

   SetIndexBuffer(0, TrendStrengthBuffer);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexLabel(0, "Buy Trend Strength");

   return INIT_SUCCEEDED;
  }
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
   if (rates_total < LookbackBars + 1)
      return 0;

   int start = MathMax(prev_calculated - 1, LookbackBars);

   for (int i = start; i < rates_total - 1; i++)
     {
      double score = 0;

      for (int j = 0; j < LookbackBars; j++)
        {
         double slope = iCustom(NULL, 0, "MA_Direction_SingleBuffer", MAPeriod, 0, i + j);

         if (slope > SlopeThreshold)
            score += slope;
         else if (slope < -SlopeThreshold)
            score -= MathAbs(slope) * 0.5;
         else
            score -= 0.1; // 側向或雜訊
        }

      TrendStrengthBuffer[i] = score;
     }

   return rates_total;
  }
//+------------------------------------------------------------------+


EA

//+------------------------------------------------------------------+
//|                                      TrendStrengthReader_EA.mq4  |
//|                       Copyright 2025, The Blue Teams Academy     |
//|                  https://www.TheBlueTeamsAcademy.com             |
//+------------------------------------------------------------------+
#property strict
#property copyright "Copyright 2025, The Blue Teams Academy"
#property link      "https://www.TheBlueTeamsAcademy.com"
#property version   "1.00"

//--- 變數宣告
double TrendStrengthValue;
datetime OpenTime = 0;

//+------------------------------------------------------------------+
//| Expert 初始化                                                    |
//+------------------------------------------------------------------+
int OnInit()
  {
   Print("✅ TrendStrengthReader_EA initialized.");
   OpenTime = iTime(Symbol(), PERIOD_CURRENT, 0);
   return INIT_SUCCEEDED;
  }

//+------------------------------------------------------------------+
//| OnTick                                                            |
//+------------------------------------------------------------------+
void OnTick()
  {
   if (IsNewBar())
     {
      TrendStrengthValue = iCustom(Symbol(), PERIOD_CURRENT, "TrendStrength_BuyOnlyv2", 0, 1);

      if (TrendStrengthValue == EMPTY_VALUE)
         Print("❌ EMPTY_VALUE at bar 1 (未有資料填入)");
      else if (TrendStrengthValue == 0.0)
         Print("⚠️ Zero value at bar 1 (可能資料不足或斜率弱)");
      else
         Print("✅ TrendStrength (Bar 1): ", DoubleToString(TrendStrengthValue, 5));
     }
  }

//+------------------------------------------------------------------+
//| 判斷是否為新K線                                                  |
//+------------------------------------------------------------------+
bool IsNewBar()
  {
   datetime newTime = iTime(Symbol(), PERIOD_CURRENT, 0);
   if (newTime != OpenTime)
     {
      OpenTime = newTime;
      return true;
     }
   return false;
  }
//+------------------------------------------------------------------+













Respondido

1
Desenvolvedor 1
Classificação
(270)
Projetos
338
29%
Arbitragem
36
28% / 64%
Expirado
10
3%
Carregado
2
Desenvolvedor 2
Classificação
(16)
Projetos
35
23%
Arbitragem
4
0% / 50%
Expirado
2
6%
Trabalhando
3
Desenvolvedor 3
Classificação
(268)
Projetos
602
34%
Arbitragem
65
20% / 57%
Expirado
147
24%
Trabalhando
Publicou: 1 artigo, 22 códigos
4
Desenvolvedor 4
Classificação
(7)
Projetos
8
13%
Arbitragem
6
33% / 33%
Expirado
0
Livre
5
Desenvolvedor 5
Classificação
(1)
Projetos
2
0%
Arbitragem
2
0% / 50%
Expirado
0
Livre
6
Desenvolvedor 6
Classificação
(851)
Projetos
1461
72%
Arbitragem
122
29% / 48%
Expirado
356
24%
Trabalhando
Publicou: 3 artigos
7
Desenvolvedor 7
Classificação
(43)
Projetos
62
23%
Arbitragem
10
20% / 50%
Expirado
10
16%
Trabalhando
8
Desenvolvedor 8
Classificação
Projetos
0
0%
Arbitragem
0
Expirado
0
Livre
9
Desenvolvedor 9
Classificação
(169)
Projetos
180
46%
Arbitragem
3
33% / 33%
Expirado
1
1%
Trabalhando
10
Desenvolvedor 10
Classificação
(20)
Projetos
26
38%
Arbitragem
6
33% / 50%
Expirado
0
Livre
11
Desenvolvedor 11
Classificação
(10)
Projetos
15
27%
Arbitragem
0
Expirado
3
20%
Livre
12
Desenvolvedor 12
Classificação
(298)
Projetos
478
40%
Arbitragem
105
40% / 24%
Expirado
82
17%
Carregado
Publicou: 2 códigos
Pedidos semelhantes
DESCRIPTION: I have a trading bot (Pips Sure EA v2.1) that operates on MT4, but I do not own the original .mq4 source code file. I need an experienced MQL4 developer to build a clean, optimized clone from scratch so that I can own the source code for long-term updates. WHAT I WILL PROVIDE: 1. The compiled .ex4 bot file. 2. The companion custom indicator file used by the bot (HiLo.ex4). 3. Detailed screenshots of all
Senior MQL5 + Python Quant Developer Needed – Institutional AI Trading Platform I'm looking for a highly experienced quantitative developer (or small team) to build an institutional-grade algorithmic trading platform for MetaTrader 5 and Python . This is not a simple Expert Advisor. It is a complete trading platform consisting of an MQL5 execution engine, Python AI research environment, machine learning pipeline, and
I need a trading robot for MetaTrader 5 that works on mobile for XAUUSD. === TRADING RULES === Symbol: XAUUSD Timeframe: M15 Trading Hours: 10:00 to 18:00 server time only Buy: When 10 EMA crosses above 50 EMA Sell: When 10 EMA crosses below 50 EMA Close opposite position when new signal appears === RISK MANAGEMENT === Risk per trade: 1% of account balance Stop Loss: 300 points / $3.00 Take Profit: 600 points / $6.00
Jona copilot v12 30 - 40 USD
Hi, I'm interested in ordering an MT4 trading bot. Before we begin, could you please send me the technical specifications and requirements you'll need? Specifically, I'd like to know: - The trading strategy the bot will use. - The currency pairs or instruments it will trade. - The timeframes it supports. - Risk management features (lot sizing, stop loss, take profit, trailing stop, maximum drawdown). - Whether it
Please programm liquidity sweep based on my 0/1 conditions. I will contact selected candidates, btw, Maybe you did already liquidity sweep, it would be very nice, you will have better understanding what I mean, source of code required
I need an ea send news low medium or high to my telegram channel or group with topic news news news news news n n n j j i i i o
I have few EAs that I want to place on market, but I can't due to some errors, please help me, because I am not a programmer. Source of code required, bug free version, ony my computer it must works not only on your computer
Hello dear all developers, I will find here python programmers? I would like to create an Expert Advisor, if you can you can convert, because I already have Expert Advisor written in mql5 or maybe you will create a bridge? it's up to you, but I need 1:1 copy
Hello! I am searching a professional programmer for regular works. I don't care if you have 1 projects done or 1000, show me your skills. I need to create an EA based on Zig Zag indicator and candlestick patterns, EA must works on all time frames, source of code required
My EA have bug 30+ USD
Expert Advisor have a bug, I tried to fix it somehow with searching on google, but I couldn't fix find a solution. Please fix it, I will send you erorr type, what line etc. Only serious programmers, not amateur please. My time is precious

Informações sobre o projeto

Orçamento
30+ USD