My indicator.. can anyone help make my script into mt4 please? You will really like it!
Code: Select all
//+------------------------------------------------------------------+
//| BBMA OA by Jimbo - GOD MODE FULL |
//+------------------------------------------------------------------+
#property indicator_chart_window
// ===== INPUT =====
input int BB_Period = 20;
input double BB_Deviation = 2.0;
input int EMA50_Period = 50;
input int EMA200_Period = 200;
input bool EnableAlert = true;
input bool ShowZone = true;
// ===== FUNCTION =====
double EMA(int tf,int p){ return iMA(NULL,tf,p,0,MODE_EMA,PRICE_CLOSE,0); }
double CLOSE(int tf){ return iClose(NULL,tf,0); }
// ===== INIT =====
int OnInit(){ return(INIT_SUCCEEDED); }
// ===== MAIN =====
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[])
{
int i=0;
// ===== CORE =====
double ema50 = iMA(NULL,0,EMA50_Period,0,MODE_EMA,PRICE_CLOSE,i);
double ema200= iMA(NULL,0,EMA200_Period,0,MODE_EMA,PRICE_CLOSE,i);
double ma5H = iMA(NULL,0,5,0,MODE_LWMA,PRICE_HIGH,i);
double ma5L = iMA(NULL,0,5,0,MODE_LWMA,PRICE_LOW,i);
double ma10H = iMA(NULL,0,10,0,MODE_LWMA,PRICE_HIGH,i);
double ma10L = iMA(NULL,0,10,0,MODE_LWMA,PRICE_LOW,i);
double upperBB = iBands(NULL,0,BB_Period,0,BB_Deviation,PRICE_CLOSE,MODE_UPPER,i);
double lowerBB = iBands(NULL,0,BB_Period,0,BB_Deviation,PRICE_CLOSE,MODE_LOWER,i);
double midBB = iBands(NULL,0,BB_Period,0,BB_Deviation,PRICE_CLOSE,MODE_MAIN,i);
// ===== MTF =====
double h4 = CLOSE(PERIOD_H4);
double h1 = CLOSE(PERIOD_H1);
double m15= CLOSE(PERIOD_M15);
double h4e = EMA(PERIOD_H4,EMA50_Period);
double h1e = EMA(PERIOD_H1,EMA50_Period);
double m15e= EMA(PERIOD_M15,EMA50_Period);
string H4 = (h4>h4e)?"BULL STR":"BEAR STR";
string H1 = (h1>h1e)?"BULL":"BEAR";
string M15= (m15>m15e)?"BULL":"BEAR";
// ===== BBMA STRUCTURE =====
bool EXTREME_BUY = (low[i] < lowerBB);
bool EXTREME_SELL= (high[i] > upperBB);
bool MHV_BUY = (close[i] > midBB && low[i] <= midBB);
bool MHV_SELL= (close[i] < midBB && high[i] >= midBB);
bool CSAK_BUY = (close[i] > midBB);
bool CSAK_SELL= (close[i] < midBB);
bool CSM_BUY = (close[i] > upperBB);
bool CSM_SELL= (close[i] < lowerBB);
// ===== SCORE (%) =====
int score=0;
if(EXTREME_BUY || EXTREME_SELL) score+=20;
if(MHV_BUY || MHV_SELL) score+=20;
if(CSAK_BUY || CSAK_SELL) score+=20;
if(CSM_BUY || CSM_SELL) score+=20;
// ===== RE-ENTRY =====
bool buyRe = (close[i] > ema50 && close[i] <= ma10L);
bool sellRe= (close[i] < ema50 && close[i] >= ma10H);
if(buyRe || sellRe) score+=20;
int percent = score;
// ===== GRADE =====
string grade="C";
if(percent>=80) grade="A+";
else if(percent>=60) grade="A";
else if(percent>=40) grade="B";
// ===== WARNING =====
bool warning=false;
if(buyRe && m15<m15e) warning=true;
if(sellRe && m15>m15e) warning=true;
bool invalid=false;
if(buyRe && close[i]<midBB) invalid=true;
if(sellRe && close[i]>midBB) invalid=true;
// ===== FAKE BREAKOUT =====
double candleSize = high[0] - low[0];
double bodySize = MathAbs(close[0] - open[0]);
bool fakeBreakout = (candleSize > bodySize*3);
// ===== GOD MODE FILTER =====
bool godMode=false;
if(percent>=85 &&
((H4=="BULL STR" && H1=="BULL" && M15=="BULL") ||
(H4=="BEAR STR" && H1=="BEAR" && M15=="BEAR")) &&
(buyRe || sellRe) &&
!warning &&
!invalid &&
!fakeBreakout)
{
godMode=true;
}
// ===== ENTRY =====
string ENTRY="NONE";
if(godMode)
{
if(buyRe) ENTRY="🔥 SNIPER BUY";
if(sellRe) ENTRY="🔥 SNIPER SELL";
}
// ===== PRICE / TP SL =====
double entryPrice = close[0];
double SL=0, TP1=0, TP2=0;
if(buyRe)
{
SL = ma10L;
TP1 = entryPrice + (entryPrice - SL)*2;
TP2 = entryPrice + (entryPrice - SL)*3;
}
if(sellRe)
{
SL = ma10H;
TP1 = entryPrice - (SL - entryPrice)*2;
TP2 = entryPrice - (SL - entryPrice)*3;
}
// ===== DRAW ZONE =====
if(ShowZone)
{
string z="ZONE";
ObjectDelete(z);
color c=clrLime;
if(warning) c=clrOrange;
if(invalid) c=clrMaroon;
if(buyRe)
ObjectCreate(z,OBJ_RECTANGLE,0,Time[10],ma10L,Time[0],ma5L);
if(sellRe)
ObjectCreate(z,OBJ_RECTANGLE,0,Time[10],ma5H,Time[0],ma10H);
ObjectSetInteger(0,z,OBJPROP_COLOR,c);
}
// ===== DASHBOARD =====
Comment(
"=== BBMA OA GOD MODE ===\n",
"H4: ",H4,"\n",
"H1: ",H1,"\n",
"M15: ",M15,"\n",
"ENTRY: ",ENTRY,"\n",
"CONFIDENCE: ",percent,"%\n",
"PRICE: ",DoubleToString(entryPrice,2),"\n",
"SL: ",DoubleToString(SL,2),"\n",
"TP1: ",DoubleToString(TP1,2),"\n",
"TP2: ",DoubleToString(TP2,2)
);
// ===== ALERT =====
static datetime last;
if(EnableAlert && Time[0]!=last && godMode)
{
Alert(Symbol()," 🔥 SNIPER ",
"Entry:",DoubleToString(entryPrice,2),
" SL:",DoubleToString(SL,2),
" TP1:",DoubleToString(TP1,2),
" TP2:",DoubleToString(TP2,2),
" ",percent,"%");
last=Time[0];
}
return(rates_total);
}