_HPCS_Tenth_MT4_Indi_V01_WE
Download scriptThis custom indicator is designed to provide visual trading signals on your MetaTrader 4 charts by analyzing momentum and price trends. It automates the process of identifying potential entry points by comparing two specific data streams: the main momentum line and its corresponding signal line.
How the Logic Works
The tool operates by scanning historical and real-time price data to detect "crossovers." It focuses on a specific technical oscillator (the Stochastic Oscillator) which measures where the current price sits relative to a recent range of prices.
1. Identifying Buy Signals (Green Arrows) The script continuously monitors the relationship between the main momentum line and the signal line. When the main line crosses above the signal line, it suggests that upward momentum is gaining strength. When this occurs, the indicator places a Green Arrow slightly below the current price candle to highlight a potential buying opportunity.
2. Identifying Sell Signals (Red Arrows) Conversely, the script looks for instances where the main momentum line drops below the signal line. This shift indicates that downward pressure is becoming dominant. When this happens, the indicator places a Red Arrow slightly above the current price candle to signal a potential selling opportunity.
Visual Presentation on Your Chart
To keep your trading workspace clear and actionable, the script handles all the visual heavy lifting:
- Buy Signals: Displayed as solid green arrows positioned just under the "Low" of a candle.
- Sell Signals: Displayed as solid red arrows positioned just above the "High" of a candle.
Key Technical Behavior
- Historical Analysis: The script is designed to automatically scan back through your chart history, placing arrows on past candles so you can backtest its accuracy visually before using it in live trading.
- Real-Time Updates: As new price ticks arrive, the indicator calculates the current state of the momentum lines to provide up-to-the-minute signals on the most recent candles.
- Precision Placement: The arrows are offset by a small margin (5 points) from the actual price candles. This ensures that the symbols do not overlap with the price bars, maintaining high visibility for the trader.
//+------------------------------------------------------------------+
//| _HPCS_Tenth_MT4_Indi_V01_WE.mq4 |
//| Copyright 2021, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
double gd_Arr_SellSignal[], gd_Arr_BuySignal[]/*gd_Arr_NeutralSignal[]*/;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,gd_Arr_SellSignal);
SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,3,clrRed);
SetIndexArrow(0,253);
SetIndexBuffer(1,gd_Arr_BuySignal);
SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,3,clrGreen);
SetIndexArrow(1,254);
/*
SetIndexBuffer(1,gd_Arr_NeutralSignal);
SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,3,clrWhite);
SetIndexArrow(1,168);
*/
//---
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 long &volume[],
const int &spread[])
{
//---
if(prev_calculated == 0)
{
for(int i = Bars-2 ; i>=0 ; i--)
{
if(iStochastic(Symbol(),PERIOD_CURRENT,5,3,3,MODE_SMA,0,MODE_MAIN,i)>iStochastic(Symbol(),PERIOD_CURRENT,5,3,3,MODE_SMA,0,MODE_SIGNAL,i))
{
gd_Arr_BuySignal[i] = Low[i]-Point()*5;
}
if(iStochastic(Symbol(),PERIOD_CURRENT,5,3,3,MODE_SMA,0,MODE_MAIN,i)<iStochastic(Symbol(),PERIOD_CURRENT,5,3,3,MODE_SMA,0,MODE_SIGNAL,i))
{
gd_Arr_SellSignal[i]= High[i]+Point()*5;
}
/* if(iStochastic(Symbol(),PERIOD_CURRENT,5,3,3,MODE_SMA,0,MODE_MAIN,i) == iStochastic(Symbol(),PERIOD_CURRENT,5,3,3,MODE_SMA,0,MODE_SIGNAL,i))
{
gd_Arr_NeutralSignal[i] = Open[i];
}*/
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Comments