uni cross
Download scriptThis script functions as a visual trading signal indicator designed to identify potential "Buy" and "Sell" opportunities on a financial chart. It works by analyzing the relationship between two distinct moving averages—specifically a fast-moving average referred to as the "Snake" and a smoother, more balanced moving average known as the "T3_clean."
Core Logic and Mechanics
The primary goal of the script is to detect when these two moving averages cross over one another. By tracking the price trends of both indicators simultaneously, the tool identifies momentum shifts:
- Buy Signals: The script looks for specific conditions where the "Snake" average moves above a certain threshold relative to the "T3_clean" average. When the current position of the Snake moves from below to above the T3 line, it triggers a signal.
- Sell Signals: Conversely, the script monitors for moments when the "Snake" drops below the "T3_clean" average. When the trend shifts downward significantly, it identifies a potential selling opportunity.
Customization and Flexibility
The tool includes several adjustable parameters to allow users to tailor the sensitivity of the signals:
- Sensitivity Adjustments: Users can modify the periods (the length of time the averages look back) for both indicators to make the signals faster or slower.
- Offset Buffers: There are options to include a "Delta" or margin, ensuring that a signal is only triggered when there is a significant enough gap between the two lines, which helps filter out minor market noise.
- Visual Aids: Once a crossover is detected, the script places visual markers (arrows) directly on the chart at specific distances above or below the price candles to make it easy for the trader to see the entry point.
User Notifications
To ensure traders can react quickly to market changes, the script features a comprehensive alert system. Depending on the user's preferences, it can provide notifications in three different ways:
- Audible Alerts: Playing a specific sound file when a cross occurs.
- Pop-up Alerts: Sending a text notification directly on the trading platform screen.
- On-Chart Comments: Displaying a written summary on the chart area, including the current price (Ask/Bid), the date, the time, and the specific currency pair being traded.
//+------------------------------------------------------------------+
//| uni cross.mq4 |
//| Copyright ?2009, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2009, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_color1 Aqua
#property indicator_color2 Yellow
#property indicator_width1 2
#property indicator_width2 2
extern bool UseSound = False;
extern bool TypeChart = False;
extern bool UseAlert = false;
extern string NameFileSound = "alert.wav";
extern int T3Period = 14;
extern int T3Price = PRICE_CLOSE;
extern double b = 0.618;
extern int Snake_HalfCycle =5; // Snake_HalfCycle = 4...10 or other
extern int Inverse = 0; //0=T3 crossing Snake, 1=Snake crossing T3
extern int DeltaForSell = 0;
extern int DeltaForBuy = 0;
extern int jarak = 50;
#property indicator_buffers 2
//---- input parameters
//---- buffers
double UpBuffer[];
double DnBuffer[];
double alertBar;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
// IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW,EMPTY);
SetIndexStyle(1,DRAW_ARROW,EMPTY);
SetIndexBuffer(0,UpBuffer);
SetIndexBuffer(1,DnBuffer);
SetIndexArrow(0,233);
SetIndexArrow(1,234);
SetIndexLabel(0,"Up Signal");
SetIndexLabel(1,"Down Signal");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars<0) counted_bars=0;
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(int i = 0 ;i < limit ;i++)
{
if( Inverse == 0)
double pwma5 = iCustom(Symbol(),0,"Snake",Snake_HalfCycle,0,i+1);
double cwma5 = iCustom(Symbol(),0,"Snake",Snake_HalfCycle,0,i);
double pwma50 = iCustom(Symbol(),0,"T3_clean",T3Period,T3Price,b,0,i+1);
double cwma50 = iCustom(Symbol(),0,"T3_clean",T3Period,T3Price,b,0,i);
/* if( Inverse == 1)
pwma5 = iCustom(Symbol(),0,"T3_clean",T3Period,T3Price,b,0,i+1);
cwma5 = iCustom(Symbol(),0,"T3_clean",T3Period,T3Price,b,0,i);
pwma50 = iCustom(Symbol(),0,"Snake",Snake_HalfCycle,0,i+1);
cwma50 = iCustom(Symbol(),0,"Snake",Snake_HalfCycle,0,i);
*/
if( cwma5 > (cwma50 +(DeltaForBuy*Point)) && pwma5 <= pwma50)
{
UpBuffer[i] = iLow(Symbol(),0,i)-(jarak*Point);
DnBuffer[i] = EMPTY_VALUE;
if (UseSound==1) PlaySound(NameFileSound);
if (UseAlert==1 && Bars>alertBar) {Alert(Symbol(), "Buy signal", Period());alertBar = Bars;}
if (TypeChart==1) Comment ("Buy signal at Ask=",Ask,", Bid=",Bid,", Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime())," Symbol=",Symbol()," Period=",Period());
}
else if( pwma5 >= pwma50 && cwma5 < (cwma50 - (DeltaForSell*Point)))
{
UpBuffer[i] = EMPTY_VALUE;
DnBuffer[i] = iHigh(Symbol(),0,i)+(jarak*Point);
if (UseSound==1) PlaySound(NameFileSound);
if (UseAlert==1 && Bars>alertBar) {Alert(Symbol(), "Sell signal", Period());alertBar = Bars;}
if (TypeChart==1) Comment ("Sell signal at Ask=",Ask,", Bid=",Bid,", Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime())," Symbol=",Symbol()," Period=",Period());
}
else
{
DnBuffer[i] = EMPTY_VALUE;
UpBuffer[i] = EMPTY_VALUE;
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments