Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
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.
Code:
#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[i]=thermo;
ExtMapBuffer2[i]=ma;
}
return(0);
}
//+------------------------------------------------------------------+
__________________
--------------------------------------------------
"Treat people as if they were what they ought to be and help them become what they are capable of being." Goethe
__________________
--------------------------------------------------
"Treat people as if they were what they ought to be and help them become what they are capable of being." Goethe
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
__________________ Better being out wishing to be in, than being in wishing to be out.....
I appreciate it, now I can review my mistakes and hopefully not repeat them!
Mike
__________________
--------------------------------------------------
"Treat people as if they were what they ought to be and help them become what they are capable of being." Goethe