Download MetaTrader 5

Elder's Market Thermometer

To add comments, please log in or register
mikep
116
mikep  

Hello All,

I'm trying to program Elder's Market Thermometer and have the basic calculations and drawing correct to measure "temperature".

However, actually getting the indicator to draw a MA on top seems to be an issue.

I've attached a screen shot where I just used the temperature then manually overlayed a MA ontop vs the bottom where I tried my hand at programming it into the indicator automatically.

It's part of a larger system (all based on Elder's 3 screens) and seems to work quite well.

I'm using it to exit trades when the temperature is 3.5 times the MA.

I'm also playing with it to enter trades - if temperature is 3 times the MA, take trade in direction of longer TF (only if price is below chart MA for a long, for example).

The code is super simple, but even so I can't figure it out - can someone take 3 minutes to check it out and fix the issue?

I've attached a screen shot to show the issue.

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Black

#property indicator_color2 Red

//---- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

extern int ThermoMAPeriod = 13;

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

SetIndexStyle(0,DRAW_HISTOGRAM);

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);

SetIndexBuffer(1,ExtMapBuffer2);

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

int i,limit;

double thermo, ma;

limit=Bars-1;

for(i=0;i<limit;i++) {

thermo = MathMax(iHigh(NULL,0,i) - iHigh(NULL,0,i+1), iLow(NULL,0,i+1) - iLow(NULL,0,i));

if (thermo < 0) {thermo = 0;}

ma = iMAOnArray(thermo,0,ThermoMAPeriod,0,MODE_EMA,i);

ExtMapBuffer1=thermo;

ExtMapBuffer2=ma;

}

return(0);

}

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

Files:
mikep
116
mikep  

...and here is the file...

HerbertH
83
HerbertH  

Fixed

mikep:
...and here is the file...

2 problems found:

- iMAOnArray can only be used on an array and you were using the simple variable thermo instead.

- iMAOnArray can only be used on a prepared (filled) array. So it can only be executed after the first loop.

Cheers,

Herbert

Michel
476
Michel  

the array is "ExtMapBuffer1", not "thermo" !

Michel
476
Michel  

Herberth,

You are faster !

but you also can do this (from left to right):

for(i=limit-1;i>=0;i--) {

thermo = MathMax(iHigh(NULL,0,i) - iHigh(NULL,0,i+1), iLow(NULL,0,i+1) - iLow(NULL,0,i));

if (thermo < 0) {thermo = 0;}

ExtMapBuffer1=thermo;

ExtMapBuffer2=iMAOnArray(ExtMapBuffer1,0,ThermoMAPeriod,0,MODE_EMA,i);

}

It seems better as value of bar i+1 is used to calculate value of bar i

HerbertH
83
HerbertH  
Michel:
Herberth,

You are faster !

but you also can do this (from left to right):

for(i=limit-1;i>=0;i--) {

thermo = MathMax(iHigh(NULL,0,i) - iHigh(NULL,0,i+1), iLow(NULL,0,i+1) - iLow(NULL,0,i));

if (thermo < 0) {thermo = 0;}

ExtMapBuffer1=thermo;

ExtMapBuffer2=iMAOnArray(ExtMapBuffer1,0,ThermoMAPeriod,0,MODE_EMA,i);

}
It seems better as value of bar i+1 is used to calculate value of bar i

Correct Michel it's always better to go from left to right, one important reason

for that is to prevent re-painting of the indi.

Regards

mikep
116
mikep  

Thanks for the quick response!!

I appreciate it, now I can review my mistakes and hopefully not repeat them!

Mike

Sergey Golubev
Moderator
100322
Sergey Golubev  

Elders market thermometer - from "Come in my trading room" - a real classic: good indicator coded by mladen.

Sergey Golubev
Moderator
100322
Sergey Golubev  

All John Ehlers

1. All John Ehlers Indicators... - the thread 
   1.1. LowPassFilter indicator - the post
   1.2. Non-Linear Kalman Filter indicator - the post
   1.3. BandPassIndicator indicator - the post 
   1.4. KalmanBands indicator - the post
   1.5. Gaussian Filter - indicator for MetaTrader 5
   1.6. Adaptive Laguerre filter trend for MetaTrader 5
   1.7. Adaptive Laguerre Filter indicator for MetaTrader 5
   1.8. Adaptive Laguerre filter 2 for MetaTrader 5
   1.9. Adaptive Laguerre indicator for MetaTrader 5
   1.10. Laguerre indicator for Metatrader 5 
2. Elder's Market Thermometer duscussion thread
3. Elders market thermometer - from "Come in my trading room" - a real classic: the thread

To add comments, please log in or register