saishala wrote: ↑Sat Apr 01, 2023 5:06 am
I have a request for you.
Of course, I'm light years behind people like kvak, mrtools, xard777 and you.
And not even with chatGPT would I be able to do what I ask of you.
You have a wonderful indicator called v2vVWAP that is based on MIDAS (I'm devoted).
Wouldn't it be possible for there to be an alarm and phone notification when a candle crosses or/and touch the last outer/exterior/last lines and the central MIDAS Vwap???? You could do it?
Please
Best not to assume and even though it is April 1 this is not a joke.
write a VWAP indicator based on MIDAS that will send alerts and notifications when a line is crossed.
AI
Here's an example code for an MT4 indicator that calculates the Volume Weighted Average Price (VWAP) based on the Market Interpretation/Data Analysis System (MIDAS) method and sends alerts and notifications when the VWAP line is crossed.
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 1
#property indicator_type1 DRAW_LINE
#property indicator_color1 CLR_ROYALBLUE
#property indicator_style1 STYLE_SOLID
#property indicator_width1 2
//Inputs
extern int DayStartHour = 8;
extern int DayEndHour = 17;
extern int PeriodsBack = 100;
//Global Variables
double VWAPBuf[];
double LineBuf[];
datetime lastAlertTime;
//Indicator Initialization function
int init()
{
string vwapsymbol;
vwapsymbol="VWAP("+Symbol()+","+IntegerToString(PeriodsBack)+","+IntegerToString(DayStartHour)+","+IntegerToString(DayEndHour)+")";
SetIndexBuffer(0, LineBuf);
SetIndexBuffer(1, VWAPBuf);
IndicatorDigits(Digits+1);
SetIndexLabel(0, "MIDAS VWAP");
SetIndexLabel(1, "");
SetIndexShift(1, PeriodsBack);
lastAlertTime = 0;
return(0);
}
//Indicator Calculation function
int start()
{
int i, counted_bars = IndicatorCounted();
datetime vwapAlertTime = 0;
for(i = Bars - 1 - PeriodsBack; i >= 0; i--)
{
double pVolume = 0, pValue = 0;
datetime pTime, startOfDay, endOfDay;
int numBars = 0;
// Get start and end of day time
if(TimeHour(Time
) >= DayStartHour && TimeHour(Time) < DayEndHour)
{
startOfDay = Time;
endOfDay = startOfDay + (DayEndHour - TimeHour(startOfDay)) * 3600;
}
else if(TimeHour(Time) < DayStartHour)
{
startOfDay = Time - (TimeHour(Time) - DayStartHour) * 3600;
endOfDay = startOfDay + (DayEndHour - DayStartHour) * 3600;
}
else
{
startOfDay = Time + (24 - TimeHour(Time) + DayStartHour) * 3600;
endOfDay = startOfDay + (DayEndHour - DayStartHour) * 3600;
}
for(int j = Bars - 1; j >= 0; j--)
{
if(Time[j] < startOfDay)
{
break;
}
if(Time[j] <= endOfDay)
{
pVolume += Volume[j];
pValue += Volume[j] * ((High[j] + Low[j] + Close[j])/3);
numBars++;
}
}
// Calculate VWAP
double vwap = pValue / pVolume;
VWAPBuf = vwap;
if (i == Bars - 1 - PeriodsBack) {
LineBuf = vwap;
}
else {
LineBuf[i] = LineBuf[i+1];
}
if (High[i] >= VWAPBuf[i] && Low[i] < VWAPBuf[i] && Time[i] > lastAlertTime) {
Alert(vwapsymbol + " has crossed at " + DoubleToString(VWAPBuf[i], Digits) + " on " + TimeToString(Time[i]));
Notification(vwapsymbol + " has crossed at " + DoubleToString(VWAPBuf[i], Digits) + " on " + TimeToString(Time[i]));
lastAlertTime = Time[i];
vwapAlertTime = Time[i];
}
}
if (vwapAlertTime > 0) {
Comment(vwapsymbol + " has crossed at " + DoubleToString(VWAPBuf[i], Digits) + " on " + TimeToString(vwapAlertTime));
return(0);
} else {
Comment("");
}
return (0);
}
The indicator will calculate the VWAP based on the MIDAS method using the inputs provided (DayStartHour, DayEndHour, and PeriodsBack). The VWAP line is plotted as a blue line on the chart. The indicator will scan the historical data and send an alert and notification if the price crosses the VWAP line. The lastAlertTime variable is used to prevent multiple alerts from being sent for the same cross. The calculated VWAP value is also displayed in the alerts and notifications. The lastAlertTime variable is reset when the chart is refreshed.