v
vincent Prince
2026.11.08 15:33

#property copyright "Copilot" #property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 #property indicator_label1 "BuySignal" #property indicator_type1 DRAW_ARROW #property indicator_color1 clrLimeGreen #property indicator_style1 STYLE_SOLID #property indicator_width1 2 #property indicator_label2 "SellSignal" #property indicator_type2 DRAW_ARROW #property indicator_color2 clrTomato #property indicator_style2 STYLE_SOLID #property indicator_width2 2 double BuyBuffer[]; double SellBuffer[]; int emaFastHandle; int emaSlowHandle; int emaTrendHandle; int rsiHandle; int adxHandle; int atrHandle; bool prevBuySignal = false; bool prevSellSignal = false; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { SetIndexBuffer(0, BuyBuffer, INDICATOR_DATA); SetIndexBuffer(1, SellBuffer, INDICATOR_DATA); PlotIndexSetInteger(0, PLOT_ARROW, 233); // upward arrow PlotIndexSetInteger(1, PLOT_ARROW, 234); // downward arrow SetIndexEmptyValue(0, EMPTY_VALUE); SetIndexEmptyValue(1, EMPTY_VALUE); IndicatorSetString(INDICATOR_SHORTNAME, "ProScalp Pulse"); emaFastHandle = iMA(_Symbol, _Period, 8, 0, MODE_EMA, PRICE_CLOSE); emaSlowHandle = iMA(_Symbol, _Period, 21, 0, MODE_EMA, PRICE_CLOSE); emaTrendHandle = iMA(_Symbol, _Period, 55, 0, MODE_EMA, PRICE_CLOSE); rsiHandle = iRSI(_Symbol, _Period, 7, PRICE_CLOSE); adxHandle = iADX(_Symbol, _Period, 14); atrHandle = iATR(_Symbol, _Period, 14); if(emaFastHandle == INVALID_HANDLE || emaSlowHandle == INVALID_HANDLE || emaTrendHandle == INVALID_HANDLE || rsiHandle == INVALID_HANDLE || adxHandle == INVALID_HANDLE || atrHandle == INVALID_HANDLE) { Print("Failed to create indicator handles."); return INIT_FAILED; } return INIT_SUCCEEDED; } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { IndicatorRelease(emaFastHandle); IndicatorRelease(emaSlowHandle); IndicatorRelease(emaTrendHandle); IndicatorRelease(rsiHandle); IndicatorRelease(adxHandle); 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 < 100) return rates_total; ArraySetAsSeries(BuyBuffer, true); ArraySetAsSeries(SellBuffer, true); double emaFast[], emaSlow[], emaTrend[], rsi[], adx[], atr[]; ArraySetAsSeries(emaFast, true); ArraySetAsSeries(emaSlow, true); ArraySetAsSeries(emaTrend, true); ArraySetAsSeries(rsi, true); ArraySetAsSeries(adx, true); ArraySetAsSeries(atr, true); int copiedFast = CopyBuffer(emaFastHandle, 0, 0, rates_total, emaFast); int copiedSlow = CopyBuffer(emaSlowHandle, 0, 0, rates_total, emaSlow); int copiedTrend = CopyBuffer(emaTrendHandle, 0, 0, rates_total, emaTrend); int copiedRSI = CopyBuffer(rsiHandle, 0, 0, rates_total, rsi); int copiedADX = CopyBuffer(adxHandle, 0, 0, rates_total, adx); int copiedATR = CopyBuffer(atrHandle, 0, 0, rates_total, atr); if(copiedFast < rates_total || copiedSlow < rates_total || copiedTrend < rates_total || copiedRSI < rates_total || copiedADX < rates_total || copiedATR < rates_total) { Print("Not enough data for all indicator buffers."); return rates_total; } for(int i = 0; i < rates_total; i++) { BuyBuffer[i] = EMPTY_VALUE; SellBuffer[i] = EMPTY_VALUE; bool buySignal = false; bool sellSignal = false; // Trend condition: bullish alignment if(emaFast[i] > emaSlow[i] && emaSlow[i] > emaTrend[i] && close[i] > emaTrend[i]) { // Momentum: RSI in bullish zone, not overextended if(rsi[i] > 50.0 && rsi[i] < 70.0) { // Trend strength: ADX above threshold if(adx[i] > 20.0) { // Volatility filter: avoid flat markets if(atr[i] > 0.0) { buySignal = true; } } } } // Trend condition: bearish alignment if(emaFast[i] < emaSlow[i] && emaSlow[i] < emaTrend[i] && close[i] < emaTrend[i]) { if(rsi[i] < 50.0 && rsi[i] > 30.0) { if(adx[i] > 20.0) { if(atr[i] > 0.0) { sellSignal = true; } } } } if(buySignal) { BuyBuffer[i] = low[i] - (2 * _Point); if(!prevBuySignal) { Alert("ProScalp Pulse BUY: ", _Symbol, " ", EnumToString(_Period)); } } else if(sellSignal) { SellBuffer[i] = high[i] + (2 * _Point); if(!prevSellSignal) { Alert("ProScalp Pulse SELL: ", _Symbol, " ", EnumToString(_Period)); } } prevBuySignal = buySignal; prevSellSignal = sellSignal; } return rates_total; }