Repainting indicators - page 23

 
Tomcat98:
Hi , Thats this one but I think it repaints.

Sorry , I cannot attach a file so I send the code in-situ.

Have a good trading week.

Tomcat

//+------------------------------------------------------------------+

//| AMA.mq4 |

//| Copyright 2012, MetaQuotes Software Corp. |

//| MetaTrader 4 Trading Platform / MetaQuotes Software Corp. |

//+------------------------------------------------------------------+

#property copyright ""

#property link ""

#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 Red

extern int Before = 7;

extern int Forward = 7;

extern int Price = 0;

double AMABuffer[];

// ---INIT----

int init() {

IndicatorDigits(Digits);

SetIndexStyle(0, DRAW_LINE);

SetIndexBuffer(0, AMABuffer);

return (0);

}

// ----DEINIT----

int deinit() {

return (0);

}

// ----Start----

int start() {

double Pos;

double Dev;

if (Bars <= 3) return (0);

int indicator_counted = IndicatorCounted();

if (indicator_counted < 0) return (-1);

int i = Bars - 2 - Before;

if (indicator_counted > 2) i = Bars - indicator_counted - 1;

while (i > 0) {

Pos = 0;

Dev = 0;

for (int ama_pos = i + Before; ama_pos > i - Forward; ama_pos--) {

if (ama_pos >= 0) {

Pos += iMA(NULL, 0, 1, 0, MODE_SMA, Price, ama_pos);

Dev++;

}

}

if (Dev > 0.0) AMABuffer = Pos / Dev;

else AMABuffer = EMPTY_VALUE;

i--;

}

return (0);

}

//----

In the indicator if Before and Forward parameters are the same you get a kind of a centered SMA. In any case when Forward parameter is > 1 it will recalculate (repaint). If it is set to 1 then it is equal to SMA. So in each case when Forward > 1 it is a repainting indicator

 
Tomcat98:
Hi , Thats this one but I think it repaints.

Sorry , I cannot attach a file so I send the code in-situ.

Have a good trading week.

Tomcat

Thanks Tomcat98 for the source now everything is clear that what is this indicator all about!

This indicator does not work on current bar, would you please fix it ?

Best Regards

secretcode

 
secretcode:
Thanks Tomcat98 for the source now everything is clear that what is this indicator all about!

This indicator does not work on current bar, would you please fix it ?

Best Regards

secretcode

secretcode

This one calculates current bar too. All the things said in two post posted 2 posts ago are still valid for it

Files:
ama.mq4  2 kb
 
mladen:
secretcode This one calculates current bar too. All the things said in two post posted 2 posts ago are still valid for it

Thanks a lot Mladen for modified indicator

Now we will see action on current bar too !

Regards,

 
secretcode:
Thanks a lot Mladen for modified indicator

Now we will see action on current bar too !

Regards,

Just don't forget that when Forward is set to > 1 it will recalculate (repaint)

 

PS: found one error in that "AMA" code. It is corrected now

Files:
ama_1.mq4  2 kb
 
mladen:
PS: found one error in that "AMA" code. It is corrected now

Thanks very much Mladen.

Have a good trading week.

Sincerely;

Tomcat98

 
mladen:
PS: found one error in that "AMA" code. It is corrected now

Thanks You Mladen for correction

Do you think it's useful if (:)) AMA & AMACD indicators recode with Triangular Moving Average (TMA) ?

Since TMA also recalculates so don't know if it will look similar or different !

sincerely

secretcode

 
secretcode:
Thanks You Mladen for correction

Do you think it's useful if (:)) AMA & AMACD indicators recode with Triangular Moving Average (TMA) ?

Since TMA also recalculates so don't know if it will look similar or different !

sincerely

secretcode

secretcode

Don't know. It would need to be tested in order to find out if it would be useful and I even did not test the AMACD yet enough to say something conclusive about it

 
mladen:
secretcode Don't know. It would need to be tested in order to find out if it would be useful and I even did not test the AMACD yet enough to say something conclusive about it

Ok, Thanks Mladen for your kind response

Since this indicator AMA is quite similar to TMA (main chart) so just curious how it will look as MACD if it use TMA !

Best Regards,

Files:
amacd.png  53 kb
Reason: