4hVegas_Chart Indicator For MT4
The 4hVegas_Chart Indicator For MT4 has two distinctive curves colored as blue and green. If the green curve crosses above the blue curve consider it as a bullish reversal signal. On the contrary, if the blue curve crosses below the green curve, you need to look for short signals. But make sure you are not taking a high risk even though it can help you to find high-quality trades.
Installing the 4hVegas_Chart Indicator For MT4
After you downloaded the indicator via the form above you need to unzip the zip-file. Then you need to copy the file 4hVegasMetaTrader4hChart.mq4 into the folder MQL4\Indicators of your MT4 installation. After that please restart MT4 and then you will be able to see the indicator in the list of indicators.
Parameters of the 4hVegas_Chart Indicator For MT4
The 4hVegas_Chart Indicator For MT4 has 5 parameters to configure.
extern bool Alerts=true;
extern bool PrintTags=True;
extern bool LogTrades=False;
extern int MA1=55;
extern int MA2=8;
Buffers of the 4hVegas_Chart Indicator For MT4
The 4hVegas_Chart Indicator For MT4 provides 4 buffers.
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexBuffer(3,ExtMapBuffer4);
Main Parts Of The Code
int start()
{
int limit;
int counted_bars=IndicatorCounted();
double SMA55;
double SMA55Prev;
double SMA8;
double SMA8Prev;
string ValueIndex;
string Direction;
bool BuyPrimed;
bool SellPrimed;
bool Bought1;
bool Bought2;
bool Bought3;
bool Sold1;
bool Sold2;
bool Sold3;
double BoughtAt;
double SoldAt;
int TagCount;
string TagName;
int i;
int j;
double RangeLimit;
bool InTrade=False;
int PandL=0;
bool FullTrade;
int LastTagOffsetAbove;
int CumulativeTagOffsetAbove;
int LastTagOffsetBelow;
int CumulativeTagOffsetBelow;
int LotsRemaining;
double SMA8Interpolated;
// Count all bars every time (bad for performance, but good for testing)
if (PrintTags)
{
limit=Bars;
}
else
{
if(counted_bars lt 0) return(-1);
if(counted_bars gt 0) counted_bars--;
limit=Bars-counted_bars;
}
// Clean up for redraw
ObjectsDeleteAll(0);
TagCount=0;
LastTagOffsetAbove=limit - 10;
LastTagOffsetBelow=limit - 10;
//---- main loop
for(i=limit-1; i gt =0; i--)
{
//---- ma_shift set to 0 because SetIndexShift called abowe
SMA55=iMA(NULL,0,MA1,0,MODE_SMA,PRICE_MEDIAN,i);
SMA8 =iMA(NULL,0,MA2,0,MODE_SMA,PRICE_CLOSE,i);
SMA55Prev=iMA(NULL,0,MA1,1,MODE_SMA,PRICE_MEDIAN,i);
SMA8Prev =iMA(NULL,0,MA2,1,MODE_SMA,PRICE_CLOSE,i);
//
ExtMapBuffer1[i]=SMA8;
ExtMapBuffer2[i]=SMA55;
ExtMapBuffer3[i]=0;
ExtMapBuffer4[i]=0;
//
Direction="----";
ValueIndex=TimeToStr(Time[i]-(TimeDayOfWeek(Time[i])*86400),TIME_DATE);
if(GlobalVariableGet(Symbol() + "-ThisWeekDirection-" + ValueIndex) gt 0.0 )
{
Direction="UP ";
}
if(GlobalVariableGet(Symbol() + "-ThisWeekDirection-" + ValueIndex) lt 0.0 )
{
Direction="DOWN";
}
if (!InTrade)
{
// ------------- TRADE ENTRY --------------
// Check the MA8/55 Crossovers
if(Direction=="DOWN" )
{
// Check the SMA8 SM55 Crossover and prime the Sell signal
if (( SMA8 gt SMA55)&& (SMA8Prev lt SMA55Prev))
{
SellPrimed=True;
BuyPrimed=False;
}
// Trigger the sell signal
if(SMA8 lt SMA8Prev )
{
if (SellPrimed)
{
// We are opening a primed trade, do full lots
FullTrade=True;
}
else
{
// Otherwise do half lots
FullTrade=False;
}
// Find the height of the tag - this should not cover any bars
RangeLimit=High[i];
for( j=i - 7;j lt i + 7;j++)
{
if (High[j] gt RangeLimit)
{
RangeLimit=High[j];
}
}
SellPrimed=False;
Sold1=True;
Sold2=True;
Sold3=True;
// We have to calculate the value at which we would have triggered the signal
// This is done by finding equality of SMA8Prev and SMA8
SMA8Interpolated=SMA8Prev*8 - (Close[i+0]+Close[i+1]+Close[i+2]+Close[i+3]+Close[i+4]+Close[i+5]+Close[i+6]);
SoldAt=SMA8Interpolated;
InTrade=True;
ExtMapBuffer3[i]=SoldAt;
// Put the tag on the chart
if (PrintTags)
{
if((LastTagOffsetAbove - i) lt 10 )
{
CumulativeTagOffsetAbove=CumulativeTagOffsetAbove + 15;
}
else
{
CumulativeTagOffsetAbove=0;
}
LastTagOffsetAbove=i;
TagName="Entry" + TagCount;
ObjectCreate(TagName, OBJ_TEXT, 0, Time[i], RangeLimit+(70-CumulativeTagOffsetAbove)*Point);
ObjectSetText(TagName, "SELL " + TagCount + " (" + DoubleToStr(SoldAt,4) + ")", 8, "Arial", White);
}
if(LogTrades )
{
if(FullTrade )
{
Print("Trade " + TagCount + " : " + Symbol() + ": SELL 100% " + DoubleToStr(Close[i],4) + " at " + TimeToStr(Time[i]));
}
else
{
Print("Trade " + TagCount + " : " + Symbol() + ": SELL 50% " + DoubleToStr(Close[i],4) + " at " + TimeToStr(Time[i]));
}
}
if (Alerts)
{
if(i==0 )
{
Alert("["+TimeToStr(CurTime())+"] " + Symbol() + ": Sell! Quote ("+Bid+":"+Ask+")");
}
}
}
}
if(Direction=="UP " )
{
// Check the SMA8 SM55 Crossover and prime the Buy signal
if (( SMA8 lt SMA55)&& (SMA8Prev gt SMA55Prev))
{
BuyPrimed=True;
SellPrimed=False;
}
// Trigger the Buy signal or unprime the trigger
if(SMA8 gt SMA8Prev )
{
if (BuyPrimed)
{
// We are opening a primed trade, do full lots
FullTrade=True;
}
else
{
// Otherwise do half lots
FullTrade=False;
}
// Find the height of the tag - this should not cover any bars
RangeLimit=Low[i];
for( j=i - 7;j lt i + 7;j++)
{
if (Low[j] lt RangeLimit)
{
RangeLimit=Low[j];
}
}
BuyPrimed=False;
Bought1=True;
Bought2=True;
Bought3=True;
// We have to calculate the value at which we would have triggered the signal
// This is done by finding equality of SMA8Prev and SMA8
SMA8Interpolated=SMA8Prev*8 - (Close[i+0]+Close[i+1]+Close[i+2]+Close[i+3]+Close[i+4]+Close[i+5]+Close[i+6]);
BoughtAt=SMA8Interpolated;
InTrade=True;
ExtMapBuffer4[i]=BoughtAt;
//----
if (PrintTags)
{
if((LastTagOffsetBelow - i) lt 10 )
{
CumulativeTagOffsetBelow=CumulativeTagOffsetBelow + 15;
}
else
{
CumulativeTagOffsetBelow=0;
}
LastTagOffsetBelow=i;
TagName="Entry" + TagCount;
ObjectCreate(TagName, OBJ_TEXT, 0, Time[i], RangeLimit - (70 - CumulativeTagOffsetBelow)*Point);
ObjectSetText(TagName, "BUY " + TagCount + " (" + DoubleToStr(BoughtAt,4) + ")", 8, "Arial", White);
}
if(LogTrades )
{
if(FullTrade )
{
Print("Trade " + TagCount + " : " + Symbol() + ": BUY 100% " + DoubleToStr(Close[i],4) + " at " + TimeToStr(Time[i]));
}
else
{
Print("Trade " + TagCount + " : " + Symbol() + ": BUY 50% " + DoubleToStr(Close[i],4) + " at " + TimeToStr(Time[i]));
}
}
if (Alerts)
{
if(i==0 )
{
Alert("["+TimeToStr(CurTime())+"] " + Symbol() + ": Buy! Quote ("+Bid+":"+Ask+")");
}
}
}
}
}
else
{
// ------------- TRADE EXIT --------------
if (Sold1 || Sold2 || Sold3)
{
// Trade Exit on SMA slope change
if(SMA8 gt SMA8Prev)
{
// Find how many lots there are open
LotsRemaining=0;
if (Sold1)
{
LotsRemaining++;
}
if (Sold2)
{
LotsRemaining++;
}
if (Sold3)
{
LotsRemaining++;
}
// Find the height of the tag - this should not cover any bars
RangeLimit=Low[i];
for( j=i - 7;j lt i + 7;j++)
{
if (Low[j] lt RangeLimit)
{
RangeLimit=Low[j];
}
}
if (PrintTags)
{
// Put the tag on the chart
ExtMapBuffer4[i]=Close[i];
if((LastTagOffsetBelow - i) lt 10 )
{
CumulativeTagOffsetBelow=CumulativeTagOffsetBelow + 15;
}
else
{
CumulativeTagOffsetBelow=0;
}
LastTagOffsetBelow=i;
TagName="Exit" + TagCount;
ObjectCreate(TagName, OBJ_TEXT, 0, Time[i], RangeLimit-(70-CumulativeTagOffsetBelow)*Point );
ObjectSetText(TagName, "EXIT " + TagCount + " (" + LotsRemaining + " Lots for " + DoubleToStr((SoldAt-Close[i])/Point,0) + ")", 8, "Arial", White);
}
if(LogTrades )
{
if(FullTrade )
{
Print("Trade " + TagCount + " : " + Symbol() + ": EXIT 100% " + DoubleToStr(Close[i],4) + " at " + TimeToStr(Time[i]) + " (" + DoubleToStr((SoldAt-Close[i])/Point,0) + ")");
}
else
{
Print("Trade " + TagCount + " : " + Symbol() + ": EXIT 50% " + DoubleToStr(Close[i],4) + " at " + TimeToStr(Time[i]) + " (" + DoubleToStr((SoldAt-Close[i])/Point,0) + ")");
}
}
if (Alerts)
{
if(i==0 )
{
Alert("["+TimeToStr(CurTime())+"] " + Symbol() + ": Exit Shorts! PandL ("+DoubleToStr((SoldAt-Close[i])/Point,0)+")");
}
}
if(FullTrade )
{
PandL=PandL + ((SoldAt-Close[i])/Point)*LotsRemaining;
}