Alım-satım robotlarını ücretsiz olarak nasıl indirebileceğinizi izleyin
Bizi Telegram üzerinde bulun!
Fan sayfamıza katılın
Komut dosyasını ilginç mi buldunuz?
Öyleyse bir link gönderin -
başkalarının da faydalanmasını sağlayın
Komut dosyasını beğendiniz mi? MetaTrader 5 terminalinde deneyin
Göstergeler

Target Trend v3 Indicator - MetaTrader 5 için gösterge

Görüntülemeler:
295
Derecelendirme:
(2)
Yayınlandı:
MQL5 Freelance Bu koda dayalı bir robota veya göstergeye mi ihtiyacınız var? Freelance üzerinden sipariş edin Freelance'e git
#property copyright "Ahmed Ibrahim - Target Trend"
#property version   "1.02"
#property indicator_chart_window


#property indicator_buffers 6
#property indicator_plots   3

//--- Buy Arrow (Filled)
#property indicator_label1  "Buy Signal"
#property indicator_type1   DRAW_ARROW
#property indicator_color1  C'6,182,144'
#property indicator_width1  4

//--- Sell Arrow (Filled)
#property indicator_label2  "Sell Signal"
#property indicator_type2   DRAW_ARROW
#property indicator_color2  C'182,112,6'
#property indicator_width2  4

//--- Trend Trailing Stop Line (Color Line)
#property indicator_label3  "Trend Line"
#property indicator_type3   DRAW_COLOR_LINE
// Define the two colors for the line: Index 0 = Bullish, Index 1 = Bearish
#property indicator_color3  C'6,182,144', C'182,112,6' 
#property indicator_style3  STYLE_SOLID
#property indicator_width3  2

//+------------------------------------------------------------------+
//| Input Parameters                                                 |
//+------------------------------------------------------------------+
input int InpLength    = 10; 
input int InpLookback  = 4;  

//+------------------------------------------------------------------+
//| Indicator Buffers                                                |
//+------------------------------------------------------------------+
double BuyBuffer[];
double SellBuffer[];
double TrendBuffer[];
double TrendColorBuffer[]; // Buffer for the line colors
double TrendState[];       
double AtrSmaBuffer[];     

int g_atr_handle, g_sma_high_handle, g_sma_low_handle;

//+------------------------------------------------------------------+
int OnInit()
{
   SetIndexBuffer(0, BuyBuffer,        INDICATOR_DATA);
   SetIndexBuffer(1, SellBuffer,       INDICATOR_DATA);
   SetIndexBuffer(2, TrendBuffer,      INDICATOR_DATA);
   SetIndexBuffer(3, TrendColorBuffer, INDICATOR_COLOR_INDEX); // Links to Plot 3
   SetIndexBuffer(4, TrendState,       INDICATOR_CALCULATIONS);
   SetIndexBuffer(5, AtrSmaBuffer,     INDICATOR_CALCULATIONS);

   // Codes 233 and 234 are filled Wingdings arrows
   PlotIndexSetInteger(0, PLOT_ARROW, 233); 
   PlotIndexSetInteger(1, PLOT_ARROW, 234);

   PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, 0.0);
   PlotIndexSetDouble(1, PLOT_EMPTY_VALUE, 0.0);
   PlotIndexSetDouble(2, PLOT_EMPTY_VALUE, 0.0);

   g_atr_handle      = iATR(_Symbol, _Period, 200);
   g_sma_high_handle = iMA(_Symbol, _Period, InpLength, 0, MODE_SMA, PRICE_HIGH);
   g_sma_low_handle  = iMA(_Symbol, _Period, InpLength, 0, MODE_SMA, PRICE_LOW);

   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[])
{
   const int ATR_PERIOD     = 200;
   const int ATR_SMA_PERIOD = 200;
   const int MIN_BARS       = ATR_PERIOD + ATR_SMA_PERIOD + InpLength + 2;

   if(rates_total < MIN_BARS) return 0;

   if(BarsCalculated(g_atr_handle) < rates_total ||
      BarsCalculated(g_sma_high_handle) < rates_total ||
      BarsCalculated(g_sma_low_handle) < rates_total)
      return prev_calculated;

   double atr_vals[], sma_h[], sma_l[];
   if(CopyBuffer(g_atr_handle, 0, 0, rates_total, atr_vals) != rates_total ||
      CopyBuffer(g_sma_high_handle, 0, 0, rates_total, sma_h) != rates_total ||
      CopyBuffer(g_sma_low_handle, 0, 0, rates_total, sma_l) != rates_total)
      return prev_calculated;

   int compute_start;
   if(prev_calculated <= 0) {
      compute_start = MIN_BARS - 2;
      TrendState[compute_start] = 0.0;
   } else {
      compute_start = MathMax(MIN_BARS - 2, prev_calculated - 1 - InpLookback);
   }

   // Pass 1: ATR SMA
   for(int i = compute_start; i < rates_total; i++) {
      double sum = 0.0;
      for(int k = 0; k < ATR_SMA_PERIOD; k++) sum += atr_vals[i - k];
      AtrSmaBuffer[i] = (sum / ATR_SMA_PERIOD) * 0.8;
   }

   // Pass 2: Trend and Colors
   for(int i = compute_start + 1; i < rates_total; i++) {
      double atr_cur  = AtrSmaBuffer[i];
      double sma_high_cur  = sma_h[i] + atr_cur;
      double sma_low_cur   = sma_l[i] - atr_cur;
      
      double sma_high_prev = sma_h[i - 1] + AtrSmaBuffer[i-1];
      double sma_low_prev  = sma_l[i - 1] - AtrSmaBuffer[i-1];

      bool crossover  = (close[i] > sma_high_cur) && (close[i - 1] <= sma_high_prev);
      bool crossunder = (close[i] < sma_low_cur)  && (close[i - 1] >= sma_low_prev);

      double prev_trend = TrendState[i - 1];
      double cur_trend  = prev_trend;

      if(crossover)  cur_trend =  1.0;
      if(crossunder) cur_trend = -1.0;

      TrendState[i] = cur_trend;

      if(cur_trend == 1.0) {
         TrendBuffer[i] = sma_low_cur;
         TrendColorBuffer[i] = 0.0; // Bullish Color (Index 0)
      } else if(cur_trend == -1.0) {
         TrendBuffer[i] = sma_high_cur;
         TrendColorBuffer[i] = 1.0; // Bearish Color (Index 1)
      } else {
         TrendBuffer[i] = 0.0;
         TrendColorBuffer[i] = EMPTY_VALUE;
      }

      BuyBuffer[i]  = 0.0;
      SellBuffer[i] = 0.0;

      if(cur_trend == 1.0 && prev_trend != 1.0)
         BuyBuffer[i] = low[i] - atr_cur * 2.0;

      if(cur_trend == -1.0 && prev_trend != -1.0)
         SellBuffer[i] = high[i] + atr_cur * 2.0;
   }

   return rates_total;
}

Last Structure Indicator :  LSB Explorer Last Structure Indicator : LSB Explorer

This is an experimental Last Structure Break (LSB) price action indicator that uncovers meaningful market structures and potential trading edges through intelligent support and resistance analysis.

ExMachina SafeScalping ExMachina SafeScalping

ExMachina Safe Scalping is a professional-grade Expert Advisor built for conservative breakout scalping on Gold (XAUUSD), Silver (XAGUSD), and Forex majors.

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

MACD Signals MACD Signals

Indicator edition for new platform.