Page 1 of 1

Custom Pine Script v5 Code: XAG Scalp Pro Engine

Posted: Mon Aug 03, 2026 3:45 pm
by FTtrader
Hi guys,

To successfully scalp XAG/USD (Silver), you need an indicator that accounts for its unique characteristics: higher intraday volatility, wider relative spreads compared to major currency pairs, and sharp momentum bursts that often trap breakout traders.Standard moving averages or default oscillators (like a 14-period RSI) are often too slow or generate excessive false signals on 1-minute (M1) or 5-minute (M5) charts.Below is a complete, production-ready Pine Script v5 custom indicator for TradingView, tailored specifically for XAG/USD scalping. It combines a Hull Moving Average (HMA) for low-lag trend tracking with an ATR-based Volatility Band (Keltner-style) to filter out choppy market noise and highlight explosive breakout windows. Custom Pine Script v5 Code: XAG Scalp Pro EngineOpen your TradingView chart, go to the Pine Editor tab at the bottom, paste the code below, and click "Add to Chart".

Code: Select all

//@version=5
indicator("XAG Scalp Pro Engine", overlay=true, precision=3)

// --- INPUTS ---
// Core Trend Settings
hmaSource   = input.source(close, title="HMA Source")
hmaLength   = input.int(9, title="HMA Period (Fast Trend)", minval=1)

// Volatility & Filter Settings
atrLength   = input.int(14, title="ATR Length for Bands")
atrMult     = input.float(1.5, title="ATR Multiplier (Width)", step=0.1)

// Session Filters (UTC default, adjust to your broker time - e.g., London/NY overlap)
useSession  = input.bool(true, title="Filter by Active Trading Session?")
tradeSession= input.session("0700-1600", title="Active Session (UTC)")

// --- CALCULATIONS ---
// 1. Hull Moving Average for lightning-fast direction without lag
f_hma(src, length) =>
    ta.wma(2 * ta.wma(src, length / 2) - ta.wma(src, length), math.round(math.sqrt(length)))

trendLine = f_hma(hmaSource, hmaLength)

// 2. Trend Direction Determination
isBullish = trendLine > trendLine[1]
isBearish = trendLine < trendLine[1]

// 3. ATR Volatility Bands for Breakout / Pullback detection
atrValue = ta.atr(atrLength)
upperBand = trendLine + (atrValue * atrMult)
lowerBand = trendLine - (atrValue * atrMult)

// 4. Session Time Check
inSession = not useSession or not na(time(timeframe.period, tradeSession + ":234560"))

// --- SIGNAL GENERATION ---
// Scalp triggers: Price piercing the volatility band while HMA changes direction
longSignal  = ta.crossover(close, lowerBand) and isBullish and inSession
shortSignal = ta.crossunder(close, upperBand) and isBearish and inSession

// --- PLOTTING ---
// Plot HMA Trend Line
barColor = isBullish ? color.green : color.red
plot(trendLine, title="Fast HMA", color=barColor, linewidth=2)

// Plot ATR Volatility Channels
uPlot = plot(upperBand, title="Upper Volatility Band", color=color.new(color.blue, 50))
lPlot = plot(lowerBand, title="Lower Volatility Band", color=color.new(color.blue, 50))
fill(uPlot, lPlot, color=color.new(color.blue, 95), title="Channel Background")

// Visual Chart Signals
plotshape(longSignal, title="Scalp Buy", location=location.belowbar, style=shape.triangleup, size=size.small, color=color.green, text="BUY")
plotshape(shortSignal, title="Scalp Sell", location=location.abovebar, style=shape.triangledown, size=size.small, color=color.red, text="SELL")

// --- ALERTS ---
alertcondition(longSignal, title="XAG Scalp BUY Alert", message="XAG/USD Bullish Scalp Setup Triggered!")
alertcondition(shortSignal, title="XAG Scalp SELL Alert", message="XAG/USD Bearish Scalp Setup Triggered!")
How to Use This Indicator for XAG/USD ScalpingTimeframe: Best optimized for M1 or M5 charts. Optimal Trading Hours: Silver liquidity spikes during the London and New York session overlap (roughly 12:00 UTC to 16:00 UTC). Use the built-in session filter to avoid quiet Asian-session chop where spreads can eat up scalping margins.Execution Logic:LONG (Buy): Wait for a red-to-green HMA flip, combined with a price push or bounce near the lower volatility band. Look for the green "BUY" shape.SHORT (Sell): Look for a green-to-red HMA shift accompanied by rejection near the upper volatility band. Look for the red "SELL" shape.Risk Management Tip for Silver: XAG/USD moves aggressively in ticks. Because of the spread overhead, target quick scalps of 8 to 15 pips with a tight stop-loss placed just beyond the opposite volatility band line.

Re: Custom Pine Script v5 Code: XAG Scalp Pro Engine

Posted: Mon Aug 03, 2026 3:46 pm
by FTtrader
And here i prepared for MT4 traders:

MQL4 Code: XAG Scalp Pro Engine

Open MT4 and press F4 to open the MetaEditor.

Go to File > New > Custom Indicator, name it XAG_Scalp_Pro, and click through to create a blank file.

Paste the code below over everything, compile it (F7), and attach it to your XAG/USD M1 or M5 chart.

Code: Select all

//+------------------------------------------------------------------+
//|                                           XAG_Scalp_Pro.mq4      |
//|                                  Custom Scalping Engine for MT4  |
//+------------------------------------------------------------------+
#property copyright "Custom Scalp Engine"
#property link      ""
#property version   "1.00"
#property strict

#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Lime     // Bullish HMA
#property indicator_color2 Red      // Bearish HMA
#property indicator_color3 DodgerBlue // Upper Band
#property indicator_color4 DodgerBlue // Lower Band
#property indicator_color5 Lime     // Buy Arrow
#property indicator_color6 Red      // Sell Arrow

// --- INPUT PARAMETERS ---
input int    InpHmaPeriod = 9;          // HMA Period (Fast Trend)
input int    InpAtrPeriod = 14;         // ATR Period for Bands
input double InpAtrMult   = 1.5;        // ATR Multiplier (Width)
input bool   InpUseSound  = true;       // Enable Push/Audio Alerts

// --- INDICATOR BUFFERS ---
double HmaBufferUp[];
double HmaBufferDn[];
double UpperBandBuffer[];
double LowerBandBuffer[];
double BuySignalBuffer[];
double SellSignalBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   // Mapping Buffers
   SetIndexBuffer(0, HmaBufferUp); SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(1, HmaBufferDn); SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(2, UpperBandBuffer); SetIndexStyle(2, DRAW_LINE, STYLE_DASH, 1);
   SetIndexBuffer(3, LowerBandBuffer); SetIndexStyle(3, DRAW_LINE, STYLE_DASH, 1);
   SetIndexBuffer(4, BuySignalBuffer); SetIndexStyle(4, DRAW_ARROW, STYLE_SOLID, 2); SetIndexArrow(4, 233);
   SetIndexBuffer(5, SellSignalBuffer); SetIndexStyle(5, DRAW_ARROW, STYLE_SOLID, 2); SetIndexArrow(5, 234);

   IndicatorShortName("XAG Scalp Pro Engine");
   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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 volume &volume[],
                const spread &spread[])
{
   int limit = rates_total - prev_calculated;
   if (prev_calculated > 0) limit++;
   if (limit > rates_total - InpHmaPeriod * 2) limit = rates_total - InpHmaPeriod * 2;
   if (limit < 0) limit = 0;

   // Calculate Hull Moving Average and ATR Bands loop
   for (int i = limit; i >= 0; i--)
   {
      double hma = CalculateHMA(i, InpHmaPeriod, close);
      double atr = iATR(NULL, 0, InpAtrPeriod, i);
      
      double upper = hma + (atr * InpAtrMult);
      double lower = hma - (atr * InpAtrMult);

      UpperBandBuffer[i] = upper;
      LowerBandBuffer[i] = lower;

      // HMA Direction Check
      double prev_hma = (i + 1 < rates_total) ? CalculateHMA(i + 1, InpHmaPeriod, close) : hma;
      
      if (hma >= prev_hma)
      {
         HmaBufferUp[i] = hma;
         HmaBufferDn[i] = EMPTY_VALUE;
      }
      else
      {
         HmaBufferDn[i] = hma;
         HmaBufferUp[i] = EMPTY_VALUE;
      }

      // Signal Triggers (Check on closed bar [1] to avoid repainting during formation)
      BuySignalBuffer[i]  = EMPTY_VALUE;
      SellSignalBuffer[i] = EMPTY_VALUE;

      if (i == 1)
      {
         bool isBullish = (hma > prev_hma);
         bool isBearish = (hma < prev_hma);
         
         bool longSignal  = (close[1] <= lower && isBullish);
         bool shortSignal = (close[1] >= upper && isBearish);

         if (longSignal)
         {
            BuySignalBuffer[1] = low[1] - (atr * 0.5);
            if (InpUseSound) Alert("XAG/USD Scalp BUY Signal on ", Symbol(), " (M", Period(), ")");
         }
         else if (shortSignal)
         {
            SellSignalBuffer[1] = high[1] + (atr * 0.5);
            if (InpUseSound) Alert("XAG/USD Scalp SELL Signal on ", Symbol(), " (M", Period(), ")");
         }
      }
   }

   return(rates_total);
}

//+------------------------------------------------------------------+
//| Custom Hull Moving Average Calculation Function                   |
//+------------------------------------------------------------------+
double CalculateHMA(int shift, int period, const double &price_array[])
{
   int halfPeriod = (int)MathRound(period / 2);
   int sqrtPeriod = (int)MathRound(MathSqrt(period));
   
   double wma_half = CalculateWMA(shift, halfPeriod, price_array);
   double wma_full = CalculateWMA(shift, period, price_array);
   
   double diff = 2.0 * wma_half - wma_full;
   
   // Create an array slice for the final WMA of the difference
   double temp_array[];
   ArrayResize(temp_array, sqrtPeriod + 5);
   
   for(int i = 0; i <= sqrtPeriod; i++)
   {
      int s = shift + i;
      double wh = CalculateWMA(s, halfPeriod, price_array);
      double wf = CalculateWMA(s, period, price_array);
      temp_array[i] = 2.0 * wh - wf;
   }
   
   double hma = 0;
   double weightSum = 0;
   for(int i = 0; i < sqrtPeriod; i++)
   {
      int weight = sqrtPeriod - i;
      hma += temp_array[i] * weight;
      weightSum += weight;
   }
   
   return (weightSum > 0) ? (hma / weightSum) : diff;
}

//+------------------------------------------------------------------+
//| Weighted Moving Average (WMA) Helper                             |
//+------------------------------------------------------------------+
double CalculateWMA(int shift, int period, const double &price_array[])
{
   double sum = 0;
   double weightSum = 0;
   for(int i = 0; i < period; i++)
   {
      int weight = period - i;
      sum += price_array[shift + i] * weight;
      weightSum += weight;
   }
   return (weightSum > 0) ? (sum / weightSum) : price_array[shift];
}
//+------------------------------------------------------------------+
Key Optimizations for XAG/USD Scalping in MT4:
Zero Repaint Signal Logic: Trade signals lock strictly onto the completed candle ([1]) so backtesting or visual alerts never misrepresent execution performance.

Silver Volatility Tuning: The ATR multi-channel automatically tightens during silver consolidation and widens dynamically when London/New York session momentum expansion breaks out.

Re: Custom Pine Script v5 Code: XAG Scalp Pro Engine

Posted: Mon Aug 03, 2026 3:47 pm
by FTtrader
And here for MT5 traders:

MQL5 Code: XAG Scalp Pro Engine
To use this in MT5:

Open MT5 and press F4 to open the MetaEditor.

Go to File > New > Expert Advisor (template) or Custom Indicator, name it XAG_Scalp_Pro_MT5, select Indicator, and click through to create a blank file.

Paste the code below over everything, compile it (F7), and attach it to your XAG/USD M1 or M5 chart.

Code: Select all

//+------------------------------------------------------------------+
//|                                           XAG_Scalp_Pro_MT5.mq5  |
//|                                  Custom Scalping Engine for MT5  |
//+------------------------------------------------------------------+
#property copyright "Custom Scalp Engine"
#property link      ""
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_plots   6

// --- PLOT STYLES ---
// Plot 0: Bullish HMA
#property indicator_label1  "HMA Up"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrLime
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2

// Plot 1: Bearish HMA
#property indicator_label2  "HMA Down"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  2

// Plot 2: Upper Band
#property indicator_label3  "Upper Band"
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrDodgerBlue
#property indicator_style3  STYLE_DASH
#property indicator_width3  1

// Plot 3: Lower Band
#property indicator_label4  "Lower Band"
#property indicator_type4   DRAW_LINE
#property indicator_color4  clrDodgerBlue
#property indicator_style4  STYLE_DASH
#property indicator_width4  1

// Plot 4: Buy Signal Arrow
#property indicator_label5  "Buy Signal"
#property indicator_type5   DRAW_ARROW
#property indicator_color5  clrLime
#property indicator_width5  3

// Plot 5: Sell Signal Arrow
#property indicator_label6  "Sell Signal"
#property indicator_type6   DRAW_ARROW
#property indicator_color6  clrRed
#property indicator_width6  3

// --- INPUT PARAMETERS ---
input group "--- Core Trend Settings ---"
input int    InpHmaPeriod = 9;          // HMA Period (Fast Trend)

input group "--- Volatility Settings ---"
input int    InpAtrPeriod = 14;         // ATR Period for Bands
input double InpAtrMult   = 1.5;        // ATR Multiplier (Width)

input group "--- Alert Settings ---"
input bool   InpUseSound  = true;       // Enable Push/Audio Alerts

// --- INDICATOR BUFFERS ---
double HmaUpBuffer[];
double HmaDnBuffer[];
double UpperBandBuffer[];
double LowerBandBuffer[];
double BuySignalBuffer[];
double SellSignalBuffer[];

// --- HANDLES ---
int atrHandle;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   // Map Buffers to Plots
   SetIndexBuffer(0, HmaUpBuffer, INDICATOR_DATA);
   SetIndexBuffer(1, HmaDnBuffer, INDICATOR_DATA);
   SetIndexBuffer(2, UpperBandBuffer, INDICATOR_DATA);
   SetIndexBuffer(3, LowerBandBuffer, INDICATOR_DATA);
   SetIndexBuffer(4, BuySignalBuffer, INDICATOR_DATA);
   SetIndexBuffer(5, SellSignalBuffer, INDICATOR_DATA);

   // Set Arrow Codes (Wingdings 233 = Up Arrow, 234 = Down Arrow)
   PlotIndexSetInteger(4, PLOT_ARROW, 233);
   PlotIndexSetInteger(5, PLOT_ARROW, 234);

   // Initialize ATR handle
   atrHandle = iATR(_Symbol, _Period, InpAtrPeriod);
   if(atrHandle == INVALID_HANDLE)
   {
      Print("Failed to create ATR handle.");
      return(INIT_FAILED);
   }

   IndicatorSetString(INDICATOR_SHORTNAME, "XAG Scalp Pro Engine (MT5)");
   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   IndicatorRelease(atrHandle);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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 < InpHmaPeriod * 2 || rates_total < InpAtrPeriod) return(0);

   // Copy ATR values safely to array
   double atrValues[];
   ArraySetAsSeries(atrValues, true);
   if(CopyBuffer(atrHandle, 0, 0, rates_total, atrValues) <= 0) return(0);

   int limit = (prev_calculated > 0) ? rates_total - prev_calculated + 1 : rates_total - InpHmaPeriod * 2;
   if(limit > rates_total - 1) limit = rates_total - 1;

   // Main calculation loop
   for(int i = limit; i >= 0; i--)
   {
      // Calculate current and previous HMA
      double hma     = CalculateHMA(i, InpHmaPeriod, close);
      double prev_hma = (i + 1 < rates_total) ? CalculateHMA(i + 1, InpHmaPeriod, close) : hma;
      double atr     = atrValues[i];

      double upper = hma + (atr * InpAtrMult);
      double lower = hma - (atr * InpAtrMult);

      UpperBandBuffer[i] = upper;
      LowerBandBuffer[i] = lower;

      // Color mapping for HMA line
      if(hma >= prev_hma)
      {
         HmaUpBuffer[i] = hma;
         HmaDnBuffer[i] = EMPTY_VALUE;
      }
      else
      {
         HmaDnBuffer[i] = hma;
         HmaUpBuffer[i] = EMPTY_VALUE;
      }

      // Reset signal buffers
      BuySignalBuffer[i]  = EMPTY_VALUE;
      SellSignalBuffer[i] = EMPTY_VALUE;

      // Evaluate signals strictly on bar [1] to avoid repainting during real-time formation
      if(i == 1)
      {
         bool isBullish = (hma > prev_hma);
         bool isBearish = (hma < prev_hma);
         
         bool longSignal  = (close[1] <= lower && isBullish);
         bool shortSignal = (close[1] >= upper && isBearish);

         if(longSignal)
         {
            BuySignalBuffer[1] = low[1] - (atr * 0.5);
            if(InpUseSound) PlaySound("alert.wav");
         }
         else if(shortSignal)
         {
            SellSignalBuffer[1] = high[1] + (atr * 0.5);
            if(InpUseSound) PlaySound("alert.wav");
         }
      }
   }

   return(rates_total);
}

//+------------------------------------------------------------------+
//| Custom Hull Moving Average Calculation Function                  |
//+------------------------------------------------------------------+
double CalculateHMA(int shift, int period, const double &price_array[])
{
   int halfPeriod = (int)MathRound(period / 2);
   int sqrtPeriod = (int)MathRound(MathSqrt(period));
   
   double wma_half = CalculateWMA(shift, halfPeriod, price_array);
   double wma_full = CalculateWMA(shift, period, price_array);
   
   double diff = 2.0 * wma_half - wma_full;
   
   double temp_array[];
   ArrayResize(temp_array, sqrtPeriod + 5);
   
   for(int i = 0; i <= sqrtPeriod; i++)
   {
      int s = shift + i;
      double wh = CalculateWMA(s, halfPeriod, price_array);
      double wf = CalculateWMA(s, period, price_array);
      temp_array[i] = 2.0 * wh - wf;
   }
   
   double hma = 0;
   double weightSum = 0;
   for(int i = 0; i < sqrtPeriod; i++)
   {
      int weight = sqrtPeriod - i;
      hma += temp_array[i] * weight;
      weightSum += weight;
   }
   
   return (weightSum > 0) ? (hma / weightSum) : diff;
}

//+------------------------------------------------------------------+
//| Weighted Moving Average (WMA) Helper                             |
//+------------------------------------------------------------------+
double CalculateWMA(int shift, int period, const double &price_array[])
{
   double sum = 0;
   double weightSum = 0;
   for(int i = 0; i < period; i++)
   {
      int weight = period - i;
      sum += price_array[shift + i] * weight;
      weightSum += weight;
   }
   return (weightSum > 0) ? (sum / weightSum) : price_array[shift];
}
Key Performance Benefits in MT5:
Native Multi-Threading & Native Handles: Leverages MT5's optimized internal iATR cache handle to process historical ticks smoothly without lagging lower-timeframe charts.

Strict Bar Lock ([1]): Just like the MT4 architecture, execution checks lock onto the finalized previous candle to guarantee zero repainting on active silver scalps.

Re: Custom Pine Script v5 Code: XAG Scalp Pro Engine

Posted: Mon Aug 03, 2026 3:49 pm
by FTtrader
And here it is for IC traders:

cTrader C# Code: XAG Scalp Pro EngineTo use this in IC Markets cTrader:Open your cTrader platform and launch cTrader Algo (or press Alt + B).Click New -> Indicator, name it XagsScalpPro, and paste the code below over the template.Click Build. It will instantly show up in your main cTrader platform under custom indicators.

Code: Select all

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class XagsScalpPro : Indicator
    {
        [Parameter("HMA Period", DefaultValue = 9, MinValue = 1)]
        public int HmaPeriod { get; set; }

        [Parameter("ATR Period", DefaultValue = 14, MinValue = 1)]
        public int AtrPeriod { get; set; }

        [Parameter("ATR Multiplier", DefaultValue = 1.5, MinValue = 0.1, Step = 0.1)]
        public double AtrMult { get; set; }

        [Parameter("Enable Alerts", DefaultValue = true)]
        public bool EnableAlerts { get; set; }

        [Output("HMA Up", LineColor = "Lime", PlotType = PlotType.Line, Thickness = 2)]
        public IndicatorDataSeries HmaUp { get; set; }

        [Output("HMA Down", LineColor = "Red", PlotType = PlotType.Line, Thickness = 2)]
        public IndicatorDataSeries HmaDn { get; set; }

        [Output("Upper Band", LineColor = "DodgerBlue", PlotType = PlotType.Line, LineStyle = LineStyle.Dash, Thickness = 1)]
        public IndicatorDataSeries UpperBand { get; set; }

        [Output("Lower Band", LineColor = "DodgerBlue", PlotType = PlotType.Line, LineStyle = LineStyle.Dash, Thickness = 1)]
        public IndicatorDataSeries LowerBand { get; set; }

        [Output("Buy Signal", PlotType = PlotType.Points, Color = "Lime", Thickness = 3)]
        public IndicatorDataSeries BuySignal { get; set; }

        [Output("Sell Signal", PlotType = PlotType.Points, Color = "Red", Thickness = 3)]
        public IndicatorDataSeries SellSignal { get; set; }

        private HullMovingAverage _hma;
        private AverageTrueRange _atr;

        protected override void Initialize()
        {
            _hma = Indicators.GetIndicator<HullMovingAverage>(MarketSeries.Close, HmaPeriod);
            _atr = Indicators.GetIndicator<AverageTrueRange>(AtrPeriod, MovingAverageType.Simple);
        }

        public override void Calculate(int index)
        {
            double hmaValue = _hma.Result[index];
            double prevHma = index > 0 ? _hma.Result[index - 1] : hmaValue;
            double atrValue = _atr.Result[index];

            UpperBand[index] = hmaValue + (atrValue * AtrMult);
            LowerBand[index] = hmaValue - (atrValue * AtrMult);

            // Color Coding HMA
            if (hmaValue >= prevHma)
            {
                HmaUp[index] = hmaValue;
                HmaDn[index] = double.NaN;
            }
            else
            {
                HmaDn[index] = hmaValue;
                HmaUp[index] = double.NaN;
            }

            // Zero-repainting signal execution evaluated strictly on the closed bar [index - 1]
            if (index == MarketSeries.Close.Count - 2)
            {
                bool isBullish = hmaValue > prevHma;
                bool isBearish = hmaValue < prevHma;

                bool longSignal = MarketSeries.Close[index] <= LowerBand[index] && isBullish;
                bool shortSignal = MarketSeries.Close[index] >= UpperBand[index] && isBearish;

                if (longSignal)
                {
                    BuySignal[index] = MarketSeries.Low[index] - (atrValue * 0.5);
                    if (EnableAlerts)
                    {
                        Notifications.PlaySound("alert.wav");
                    }
                }
                else if (shortSignal)
                {
                    SellSignal[index] = MarketSeries.High[index] + (atrValue * 0.5);
                    if (EnableAlerts)
                    {
                        Notifications.PlaySound("alert.wav");
                    }
                }
            }
        }
    }
}

Re: Custom Pine Script v5 Code: XAG Scalp Pro Engine

Posted: Mon Aug 03, 2026 3:49 pm
by FTtrader
Please let me know, what do you think about it.
Take a care and have a nice day.