This interesting moving average alert indicator is not updating as it should...

1
Hello everyone I am new to the forum so greet all those who are part of it.

the indicator in question gives the opportunity to insert the bars to be scanned for the alert, the problem is that if I insert a number of bars higher than the history, the indicator no longer updates or even disappears.
I tried to modify it and I deleted some include files that didn't do much good.

Anyone know how to fix this?
I saw that there are some very good programmers in the forum ...


Re: This interesting moving average alert indicator is not updating as it should...

2
frenk wrote: Thu Feb 11, 2021 6:16 am Hello everyone I am new to the forum so greet all those who are part of it.

the indicator in question gives the opportunity to insert the bars to be scanned for the alert, the problem is that if I insert a number of bars higher than the history, the indicator no longer updates or even disappears.
I tried to modify it and I deleted some include files that didn't do much good.

Anyone know how to fix this?
I saw that there are some very good programmers in the forum ...
Maybe this one Averages

Re: This interesting moving average alert indicator is not updating as it should...

3
Thanks for the prompt reply, I have already seen this very comprehensive moving average indicator.
I wanted to use the SMMA and I believe that the average indicator 9.4 and earlier with longer averages of the type 200 or 400 tends to twist on the price and then start, also in this case with not very long histories it tends not to give optimal values, in practice, the average starts from the candle, while the indicator I posted is like the standard moving average smoothed of MT, if possible I wanted to try to fix and maybe improve mine.

I hope there is more help

I also insert the vidya because it can be useful for someone
These users thanked the author frenk for the post:
Gautam


Re: This interesting moving average alert indicator is not updating as it should...

6
ChuChu Rocket wrote: Sat Feb 13, 2021 12:13 am

Are you not able to use the other Moving Average indicators posted above or in the link posted by Mrtools?
Hi,

Of course I know how to use them and I have also made the previous versions available but in a not too long history D1 or W1 or MN some of the moving averages such as the SMMA do not work as well as the standard MT SMMA (the reason I wrote in the previous post) .
If it is possible to solve the problem of the Moving Average With Alert indicator, in the future it would be interesting to be able to insert the Vidya CMO 1.1, making a single indicator.

Re: This interesting moving average alert indicator is not updating as it should...

7
I resume this post to ask if someone who knows the MT4 language can help me insert in the classic moving average vidya a further smoothing with the classic moving averages Simple, Exponential, Smoothed, Linear Weighted.
I tried but my programming level is at the beginning, I put the code of the classic Vidya.
Thanks to whoever intervenes

//+------------------------------------------------------------------+
//| Vidya Prova.mq4 |
//| Io |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 clrMagenta
#property indicator_width1 0
#property strict

//
//
//
//
//

extern int CmoPeriod1 = 15; // CMO period
extern int SmoothPeriod1 = 15; // Smoothing period
extern int MA = 15; // Smoothing SMA
extern ENUM_APPLIED_PRICE Price1 = PRICE_CLOSE; // Price

double val[],valda[],valdb[],slope[];

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
IndicatorBuffers(4);
SetIndexBuffer(0,val);
SetIndexBuffer(1,valda);
SetIndexBuffer(2,valdb);
SetIndexBuffer(3,slope);
return(0);
}

//
//
//
//
//

int start()
{
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit = MathMin(Bars-counted_bars,Bars-1);

//
//
//
//
//

if (slope[limit]==-1) CleanPoint(limit,valda,valdb);
for(int i=limit; i>=0; i--)
{

val= iVidya(iMA(NULL,0,1,0,MODE_SMA,Price1,i),CmoPeriod1,SmoothPeriod1,i,0);
valda = EMPTY_VALUE;
valdb = EMPTY_VALUE;
slope = (i<Bars-1) ? (val>val[i+1]) ? 1 : (val<val[i+1]) ? -1 : slope[i+1] : 0;
if (slope==-1) PlotPoint(i,valda,valdb,val);
}
return(0);
}

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//

#define _vidyaInstances 1
#define _vidyaInstancesSize 2
double vidya_work[][_vidyaInstances*_vidyaInstancesSize];
#define vidya_price 0
#define vidya_value 1

double iVidya(double price, int cmoPeriods, int smoothPeriod, int i, int instanceNo=0)
{
if (ArrayRange(vidya_work,0)!=Bars) ArrayResize(vidya_work,Bars); int r = Bars-i-1; int s = instanceNo*_vidyaInstancesSize;

//
//
//
//
//

vidya_work[r][s+vidya_price] = price;
double sumUp = 0;
double sumDo = 0;
for (int j=0; j < cmoPeriods && (r-j-1)>=0; j++)
{
double diff = vidya_work[r-j][s+vidya_price]-vidya_work[r-j-1][s+vidya_price];
if (diff > 0)
sumUp += diff;
else sumDo -= diff;
}
double k = ((sumUp+sumDo)!=0) ? MathAbs((sumUp-sumDo)/(sumUp+sumDo)): 1;

vidya_work[r][s+vidya_value] = (r>0) ? vidya_work[r-1][s+vidya_value]+(k*2.00/(1.00+MathMax(smoothPeriod,1)))*(vidya_work[r][s+vidya_price]-vidya_work[r-1][s+vidya_value]) : price;
return(vidya_work[r][s+vidya_value]);
}

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
//

void CleanPoint(int i,double& first[],double& second[])
{
if ((second != EMPTY_VALUE) && (second[i+1] != EMPTY_VALUE))
second[i+1] = EMPTY_VALUE;
else
if ((first != EMPTY_VALUE) && (first[i+1] != EMPTY_VALUE) && (first[i+2] == EMPTY_VALUE))
first[i+1] = EMPTY_VALUE;
}

//
//
//
//
//

void PlotPoint(int i,double& first[],double& second[],double& from[])
{
if (i>=Bars-2) return;
if (first[i+1] == EMPTY_VALUE)
{
if (first[i+2] == EMPTY_VALUE)
{ first = from[i]; first[i+1] = from[i+1]; second[i] = EMPTY_VALUE; }
else { second[i] = from[i]; second[i+1] = from[i+1]; first[i] = EMPTY_VALUE; }
}
else { first[i] = from[i]; second[i] = EMPTY_VALUE; }
}

Re: This interesting moving average alert indicator is not updating as it should...

8
[quote=frenk post_id=1295442964 time=1630184060 user_id=4943193]
I resume this post to ask if someone who knows the MT4 language can help me insert in the classic moving average vidya a further smoothing with the classic moving averages Simple, Exponential, Smoothed, Linear Weighted.
I tried but my programming level is at the beginning, I put the code of the classic Vidya.
Thanks to whoever intervenes

And try more Vidya from Vidya and MA . So as not to run twice.:) (Switching from Vidya to MA in the code.)


Who is online

Users browsing this forum: boytoy, Efegocmen, Facebook [Crawler], Google [Bot], Krunal Gajjar, kvak, LittleCaro, ssscary, thomdel and 107 guests