...and here is the file...
Fixed
...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
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);
}
//+------------------------------------------------------------------+