Please help i have 2errors and cant figure out how to correct it ........
//+------------------------------------------------------------------+
//| 200EMA CROSS 365 EMA 1MINUTE.mq4 |
//| Copyright
2005, Jason Robinson (jnrtrading) |
//| http://jnrtrading.co.uk |
//+------------------------------------------------------------------+
#property copyright "Copyright
2005, Jason Robinson (jnrtrading)"
#property link "http://jnrtrading.co.uk"
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 clrBlue
#property indicator_color2 clrBlue
#property indicator_color3 clrTeal
#property indicator_color4 clrBrown
#property indicator_color5 clrBrown
#property indicator_color6 clrRed
enum enAlertBar
{
CURR=0, // Alert on current Bar
CLOSED=1, // Alert on closed Bar
};
// --- Function Prototypes ---
void DrawMiniHLine(string name, datetime startTime, datetime endTime, double price, color col, int style);
void V_line(string name, datetime openPrice, color col);
string Tf_as_string(ENUM_TIMEFRAMES period);
string MAMethod_as_string(ENUM_MA_METHOD p, int len=0);
int AlertOnce(string alert_msg, int ref, int tf);
// Multi-level Buffers (Up)
double CrossUpLvl1[];
double CrossUpLvl2[];
double CrossUpLvl3[];
// Multi-level Buffers (Down)
double CrossDownLvl1[];
double CrossDownLvl2[];
double CrossDownLvl3[];
extern ENUM_MA_METHOD FasterMode = 1; // 0=sma, 1=ema, 2=smma, 3=lwma
extern int FasterMA = 200; // 200 EMA Target
extern ENUM_MA_METHOD SlowerMode = 1; // 0=sma, 1=ema, 2=smma, 3=lwma
extern int SlowerMA = 365; // 365 EMA Target
// Target Matrix Rules
extern int StopLoss_Pips = 20; // Custom rule parameter
extern int TakeProfit_Pips = 100; // Custom rule parameter
// Multi-level thresholds based on distance between lines
extern double Level2_Threshold_Multiplier = 1.0;
extern double Level3_Threshold_Multiplier = 2.0;
input enAlertBar AlertBar = CLOSED;
input bool AlertPopUp = false; // PopUp Alerts?
input bool AlertSound = false; // SoundOnly Alerts?
input bool AlertEMail = false; // EMail Alerts?
input bool AlertNotify = false; // Push Notifications?
double alertTag;
string message;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
// Set up Level 1 (Small Arrows)
SetIndexStyle(0, DRAW_ARROW, 0, 1);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUpLvl1);
SetIndexStyle(3, DRAW_ARROW, 0, 1);
SetIndexArrow(3, 234);
SetIndexBuffer(3, CrossDownLvl1);
// Set up Level 2 (Medium Arrows)
SetIndexStyle(1, DRAW_ARROW, 0, 3);
SetIndexArrow(1, 233);
SetIndexBuffer(1, CrossUpLvl2);
SetIndexStyle(4, DRAW_ARROW, 0, 3);
SetIndexArrow(4, 234);
SetIndexBuffer(4, CrossDownLvl2);
// Set up Level 3 (Large Arrows)
SetIndexStyle(2, DRAW_ARROW, 0, 5);
SetIndexArrow(2, 233);
SetIndexBuffer(2, CrossUpLvl3);
SetIndexStyle(5, DRAW_ARROW, 0, 5);
SetIndexArrow(5, 234);
SetIndexBuffer(5, CrossDownLvl3);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectsDeleteAll(0, "trend_", -1, -1);
ObjectsDeleteAll(0, "lvl_", -1, -1);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int limit, i, counter;
double fasterMAnow, slowerMAnow, fasterMAprevious, slowerMAprevious, fasterMAafter, slowerMAafter;
double Range, AvgRange;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i = limit; i >= 0; i--) {
CrossUpLvl1[i] = EMPTY_VALUE;
CrossUpLvl2[i] = EMPTY_VALUE;
CrossUpLvl3[i] = EMPTY_VALUE;
CrossDownLvl1[i] = EMPTY_VALUE;
CrossDownLvl2[i] = EMPTY_VALUE;
CrossDownLvl3[i] = EMPTY_VALUE;
Range=0;
AvgRange=0;
for (counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;
fasterMAnow = iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i);
fasterMAprevious = iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i+1);
fasterMAafter = iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i-1);
slowerMAnow = iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_CLOSE, i);
slowerMAprevious = iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_CLOSE, i+1);
slowerMAafter = iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_CLOSE, i-1);
double maSpread = MathAbs(fasterMAnow - slowerMAnow);
// Calculate Pip values dynamically depending on asset digits
double pipsValue = Point;
if(Digits == 3 || Digits == 5) pipsValue = Point * 10;
string lvlStr = "Level 1";
bool targetTrade = false;
double entryPrice = 0;
double stopLoss = 0;
double takeProfit = 0;
datetime endLineTime = 0;
//--- BULLISH MULTI-LEVEL CROSSOVER (BUY ENTRY)
if ( (fasterMAnow > slowerMAnow) && (fasterMAprevious < slowerMAprevious) && (fasterMAafter > slowerMAafter))
{
lvlStr = "Level 1";
targetTrade = false;
if(maSpread >= (Range * Level3_Threshold_Multiplier)) {
CrossUpLvl3[i] = Low[i] - Range*0.5;
lvlStr = "Level 3 (EXTREME)";
targetTrade = true;
}
else if(maSpread >= (Range * Level2_Threshold_Multiplier)) {
CrossUpLvl2[i] = Low[i] - Range*0.5;
lvlStr = "Level 2 (Strong)";
targetTrade = true;
}
else {
CrossUpLvl1[i] = Low[i] - Range*0.5;
}
V_line("trend_buy"+TimeToStr(Time[i]), Time[i],clrBlue);
// Draw Level Targets on the chart for trades
if(targetTrade)
{
entryPrice = Close[i];
stopLoss = entryPrice - (StopLoss_Pips * pipsValue);
takeProfit = entryPrice + (TakeProfit_Pips * pipsValue);
endLineTime = Time[i] + PeriodSeconds() * 15;
DrawMiniHLine("lvl_B_Entry_"+TimeToStr(Time[i]), Time[i], endLineTime, entryPrice, clrWhite, STYLE_SOLID);
DrawMiniHLine("lvl_B_SL_"+TimeToStr(Time[i]), Time[i], endLineTime, stopLoss, clrRed, STYLE_DASH);
DrawMiniHLine("lvl_B_TP_"+TimeToStr(Time[i]), Time[i], endLineTime, takeProfit, clrGreen, STYLE_DASH);
}
if ( alertTag!=Time[i])
{
message="Buy Alert ["+lvlStr+"] on: "+Symbol()+" "+Tf_as_string(PERIOD_CURRENT)+" "+MAMethod_as_string(FasterMode)+"("+IntegerToString(FasterMA)+") crossed above "+MAMethod_as_string(SlowerMode)+"("+IntegerToString(SlowerMA)+")";
AlertOnce(message,AlertBar,_Period);
}
alertTag = Time[i];
}
//--- BEARISH MULTI-LEVEL CROSSOVER (SELL ENTRY)
else if ((fasterMAnow < slowerMAnow) && (fasterMAprevious > slowerMAprevious) && (fasterMAafter < slowerMAafter))
{
lvlStr = "Level 1";
targetTrade = false;
if(maSpread >= (Range * Level3_Threshold_Multiplier)) {
CrossDownLvl3[i] = High[i] + Range*0.5;
lvlStr = "Level 3 (EXTREME)";
targetTrade = true;
}
else if(maSpread >= (Range * Level2_Threshold_Multiplier)) {
CrossDownLvl2[i] = High[i] + Range*0.5;
lvlStr = "Level 2 (Strong)";
targetTrade = true;
}
else {
CrossDownLvl1[i] = High[i] + Range*0.5;
}
V_line("trend_sell"+TimeToStr(Time[i]), Time[i],clrRed);
// Draw Level Targets on the chart for trades
if(targetTrade)
{
entryPrice = Close[i];
stopLoss = entryPrice + (StopLoss_Pips * pipsValue);
takeProfit = entryPrice - (TakeProfit_Pips * pipsValue);
endLineTime = Time[i] + PeriodSeconds() * 15;
DrawMiniHLine("lvl_S_Entry_"+TimeToStr(Time[i]), Time[i], endLineTime, entryPrice, clrWhite, STYLE_SOLID);
DrawMiniHLine("lvl_S_SL_"+TimeToStr(Time[i]), Time[i], endLineTime, stopLoss, clrRed, STYLE_DASH);
DrawMiniHLine("lvl_S_TP_"+TimeToStr(Time[i]), Time[i], endLineTime, takeProfit, clrGreen, STYLE_DASH);
}
if ( alertTag!=Time[i])
{
message="Sell Alert ["+lvlStr+"] on: "+Symbol()+" "+Tf_as_string(PERIOD_CURRENT)+" "+MAMethod_as_string(FasterMode)+"("+IntegerToString(FasterMA)+") crossed below "+MAMethod_as_string(SlowerMode)+"("+IntegerToString(SlowerMA)+")";
AlertOnce(message,AlertBar,_Period);
}
alertTag = Time[i];
}
}
return(0);
}
//+------------------------------------------------------------------+
//| Helper to draw small horizontal line segments |
//+------------------------------------------------------------------+
void DrawMiniHLine(string name, datetime startTime, datetime endTime, double price, color col, int style)
{
if(ObjectFind(0, name) < 0)
{
ObjectCreate(0, name, OBJ_TREND, 0, startTime, price, endTime, price);
ObjectSetInteger(0, name, OBJPROP_STYLE, style);
ObjectSetInteger(0, name, OBJPROP_COLOR, col);
ObjectSetInteger(0, name, OBJPROP_WIDTH, 2);
';' - unexpected end of program 200EMA CROSS 365 EMA 1MINUTE TIMEFRAME.mq4 259 50
'{' - unbalanced parentheses 200EMA CROSS 365 EMA 1MINUTE TIMEFRAME.mq4 253 1
ERROR ON LINE 259 AND 253
//+------------------------------------------------------------------+
//| 200EMA CROSS 365 EMA 1MINUTE.mq4 |
//| Copyright
//| http://jnrtrading.co.uk |
//+------------------------------------------------------------------+
#property copyright "Copyright
#property link "http://jnrtrading.co.uk"
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 clrBlue
#property indicator_color2 clrBlue
#property indicator_color3 clrTeal
#property indicator_color4 clrBrown
#property indicator_color5 clrBrown
#property indicator_color6 clrRed
enum enAlertBar
{
CURR=0, // Alert on current Bar
CLOSED=1, // Alert on closed Bar
};
// --- Function Prototypes ---
void DrawMiniHLine(string name, datetime startTime, datetime endTime, double price, color col, int style);
void V_line(string name, datetime openPrice, color col);
string Tf_as_string(ENUM_TIMEFRAMES period);
string MAMethod_as_string(ENUM_MA_METHOD p, int len=0);
int AlertOnce(string alert_msg, int ref, int tf);
// Multi-level Buffers (Up)
double CrossUpLvl1[];
double CrossUpLvl2[];
double CrossUpLvl3[];
// Multi-level Buffers (Down)
double CrossDownLvl1[];
double CrossDownLvl2[];
double CrossDownLvl3[];
extern ENUM_MA_METHOD FasterMode = 1; // 0=sma, 1=ema, 2=smma, 3=lwma
extern int FasterMA = 200; // 200 EMA Target
extern ENUM_MA_METHOD SlowerMode = 1; // 0=sma, 1=ema, 2=smma, 3=lwma
extern int SlowerMA = 365; // 365 EMA Target
// Target Matrix Rules
extern int StopLoss_Pips = 20; // Custom rule parameter
extern int TakeProfit_Pips = 100; // Custom rule parameter
// Multi-level thresholds based on distance between lines
extern double Level2_Threshold_Multiplier = 1.0;
extern double Level3_Threshold_Multiplier = 2.0;
input enAlertBar AlertBar = CLOSED;
input bool AlertPopUp = false; // PopUp Alerts?
input bool AlertSound = false; // SoundOnly Alerts?
input bool AlertEMail = false; // EMail Alerts?
input bool AlertNotify = false; // Push Notifications?
double alertTag;
string message;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
// Set up Level 1 (Small Arrows)
SetIndexStyle(0, DRAW_ARROW, 0, 1);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUpLvl1);
SetIndexStyle(3, DRAW_ARROW, 0, 1);
SetIndexArrow(3, 234);
SetIndexBuffer(3, CrossDownLvl1);
// Set up Level 2 (Medium Arrows)
SetIndexStyle(1, DRAW_ARROW, 0, 3);
SetIndexArrow(1, 233);
SetIndexBuffer(1, CrossUpLvl2);
SetIndexStyle(4, DRAW_ARROW, 0, 3);
SetIndexArrow(4, 234);
SetIndexBuffer(4, CrossDownLvl2);
// Set up Level 3 (Large Arrows)
SetIndexStyle(2, DRAW_ARROW, 0, 5);
SetIndexArrow(2, 233);
SetIndexBuffer(2, CrossUpLvl3);
SetIndexStyle(5, DRAW_ARROW, 0, 5);
SetIndexArrow(5, 234);
SetIndexBuffer(5, CrossDownLvl3);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectsDeleteAll(0, "trend_", -1, -1);
ObjectsDeleteAll(0, "lvl_", -1, -1);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int limit, i, counter;
double fasterMAnow, slowerMAnow, fasterMAprevious, slowerMAprevious, fasterMAafter, slowerMAafter;
double Range, AvgRange;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i = limit; i >= 0; i--) {
CrossUpLvl1[i] = EMPTY_VALUE;
CrossUpLvl2[i] = EMPTY_VALUE;
CrossUpLvl3[i] = EMPTY_VALUE;
CrossDownLvl1[i] = EMPTY_VALUE;
CrossDownLvl2[i] = EMPTY_VALUE;
CrossDownLvl3[i] = EMPTY_VALUE;
Range=0;
AvgRange=0;
for (counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;
fasterMAnow = iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i);
fasterMAprevious = iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i+1);
fasterMAafter = iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i-1);
slowerMAnow = iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_CLOSE, i);
slowerMAprevious = iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_CLOSE, i+1);
slowerMAafter = iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_CLOSE, i-1);
double maSpread = MathAbs(fasterMAnow - slowerMAnow);
// Calculate Pip values dynamically depending on asset digits
double pipsValue = Point;
if(Digits == 3 || Digits == 5) pipsValue = Point * 10;
string lvlStr = "Level 1";
bool targetTrade = false;
double entryPrice = 0;
double stopLoss = 0;
double takeProfit = 0;
datetime endLineTime = 0;
//--- BULLISH MULTI-LEVEL CROSSOVER (BUY ENTRY)
if ( (fasterMAnow > slowerMAnow) && (fasterMAprevious < slowerMAprevious) && (fasterMAafter > slowerMAafter))
{
lvlStr = "Level 1";
targetTrade = false;
if(maSpread >= (Range * Level3_Threshold_Multiplier)) {
CrossUpLvl3[i] = Low[i] - Range*0.5;
lvlStr = "Level 3 (EXTREME)";
targetTrade = true;
}
else if(maSpread >= (Range * Level2_Threshold_Multiplier)) {
CrossUpLvl2[i] = Low[i] - Range*0.5;
lvlStr = "Level 2 (Strong)";
targetTrade = true;
}
else {
CrossUpLvl1[i] = Low[i] - Range*0.5;
}
V_line("trend_buy"+TimeToStr(Time[i]), Time[i],clrBlue);
// Draw Level Targets on the chart for trades
if(targetTrade)
{
entryPrice = Close[i];
stopLoss = entryPrice - (StopLoss_Pips * pipsValue);
takeProfit = entryPrice + (TakeProfit_Pips * pipsValue);
endLineTime = Time[i] + PeriodSeconds() * 15;
DrawMiniHLine("lvl_B_Entry_"+TimeToStr(Time[i]), Time[i], endLineTime, entryPrice, clrWhite, STYLE_SOLID);
DrawMiniHLine("lvl_B_SL_"+TimeToStr(Time[i]), Time[i], endLineTime, stopLoss, clrRed, STYLE_DASH);
DrawMiniHLine("lvl_B_TP_"+TimeToStr(Time[i]), Time[i], endLineTime, takeProfit, clrGreen, STYLE_DASH);
}
if ( alertTag!=Time[i])
{
message="Buy Alert ["+lvlStr+"] on: "+Symbol()+" "+Tf_as_string(PERIOD_CURRENT)+" "+MAMethod_as_string(FasterMode)+"("+IntegerToString(FasterMA)+") crossed above "+MAMethod_as_string(SlowerMode)+"("+IntegerToString(SlowerMA)+")";
AlertOnce(message,AlertBar,_Period);
}
alertTag = Time[i];
}
//--- BEARISH MULTI-LEVEL CROSSOVER (SELL ENTRY)
else if ((fasterMAnow < slowerMAnow) && (fasterMAprevious > slowerMAprevious) && (fasterMAafter < slowerMAafter))
{
lvlStr = "Level 1";
targetTrade = false;
if(maSpread >= (Range * Level3_Threshold_Multiplier)) {
CrossDownLvl3[i] = High[i] + Range*0.5;
lvlStr = "Level 3 (EXTREME)";
targetTrade = true;
}
else if(maSpread >= (Range * Level2_Threshold_Multiplier)) {
CrossDownLvl2[i] = High[i] + Range*0.5;
lvlStr = "Level 2 (Strong)";
targetTrade = true;
}
else {
CrossDownLvl1[i] = High[i] + Range*0.5;
}
V_line("trend_sell"+TimeToStr(Time[i]), Time[i],clrRed);
// Draw Level Targets on the chart for trades
if(targetTrade)
{
entryPrice = Close[i];
stopLoss = entryPrice + (StopLoss_Pips * pipsValue);
takeProfit = entryPrice - (TakeProfit_Pips * pipsValue);
endLineTime = Time[i] + PeriodSeconds() * 15;
DrawMiniHLine("lvl_S_Entry_"+TimeToStr(Time[i]), Time[i], endLineTime, entryPrice, clrWhite, STYLE_SOLID);
DrawMiniHLine("lvl_S_SL_"+TimeToStr(Time[i]), Time[i], endLineTime, stopLoss, clrRed, STYLE_DASH);
DrawMiniHLine("lvl_S_TP_"+TimeToStr(Time[i]), Time[i], endLineTime, takeProfit, clrGreen, STYLE_DASH);
}
if ( alertTag!=Time[i])
{
message="Sell Alert ["+lvlStr+"] on: "+Symbol()+" "+Tf_as_string(PERIOD_CURRENT)+" "+MAMethod_as_string(FasterMode)+"("+IntegerToString(FasterMA)+") crossed below "+MAMethod_as_string(SlowerMode)+"("+IntegerToString(SlowerMA)+")";
AlertOnce(message,AlertBar,_Period);
}
alertTag = Time[i];
}
}
return(0);
}
//+------------------------------------------------------------------+
//| Helper to draw small horizontal line segments |
//+------------------------------------------------------------------+
void DrawMiniHLine(string name, datetime startTime, datetime endTime, double price, color col, int style)
{
if(ObjectFind(0, name) < 0)
{
ObjectCreate(0, name, OBJ_TREND, 0, startTime, price, endTime, price);
ObjectSetInteger(0, name, OBJPROP_STYLE, style);
ObjectSetInteger(0, name, OBJPROP_COLOR, col);
ObjectSetInteger(0, name, OBJPROP_WIDTH, 2);
';' - unexpected end of program 200EMA CROSS 365 EMA 1MINUTE TIMEFRAME.mq4 259 50
'{' - unbalanced parentheses 200EMA CROSS 365 EMA 1MINUTE TIMEFRAME.mq4 253 1
ERROR ON LINE 259 AND 253