Forex
Google
New signals service!

Go Back   Forex Trading > Downloads > Indicators - Metatrader 4


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-28-2007, 09:47 AM
mikep's Avatar
Member
 
Join Date: Jun 2006
Posts: 87
mikep is on a distinguished road
Elder's Market Thermometer

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.

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);
  }
//+------------------------------------------------------------------+
Attached Images
File Type: gif marketthermo test.gif (14.9 KB, 553 views)
__________________
--------------------------------------------------
"Treat people as if they were what they ought to be and help them become what they are capable of being." Goethe
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-28-2007, 09:49 AM
mikep's Avatar
Member
 
Join Date: Jun 2006
Posts: 87
mikep is on a distinguished road
...and here is the file...
Attached Files
File Type: mq4 Market Thermometer v2.mq4 (2.0 KB, 49 views)
__________________
--------------------------------------------------
"Treat people as if they were what they ought to be and help them become what they are capable of being." Goethe
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-28-2007, 11:00 AM
HerbertH's Avatar
Member
 
Join Date: May 2006
Posts: 88
HerbertH is on a distinguished road
Fixed

Quote:
Originally Posted by mikep View Post
...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
Attached Files
File Type: mq4 Market Thermometer v2.mq4 (2.0 KB, 79 views)
__________________
Better being out, wishing to be in than being in and wishing to be out.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-28-2007, 11:09 AM
Senior Member
 
Join Date: Feb 2006
Posts: 513
Michel is on a distinguished road
the array is "ExtMapBuffer1", not "thermo" !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 06-28-2007, 11:15 AM
Senior Member
 
Join Date: Feb 2006
Posts: 513
Michel is on a distinguished road
Herberth,
You are faster !
but you also can do this (from left to right):
PHP Code:
   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[i]=thermo;
     
     
ExtMapBuffer2[i]=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

Last edited by Michel; 06-28-2007 at 11:18 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 06-28-2007, 11:32 AM
HerbertH's Avatar
Member
 
Join Date: May 2006
Posts: 88
HerbertH is on a distinguished road
Quote:
Originally Posted by Michel View Post
Herberth,
You are faster !
but you also can do this (from left to right):
PHP Code:
   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[i]=thermo;
     
     
ExtMapBuffer2[i]=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
__________________
Better being out, wishing to be in than being in and wishing to be out.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 06-28-2007, 01:56 PM
mikep's Avatar
Member
 
Join Date: Jun 2006
Posts: 87
mikep is on a distinguished road
Thanks for the quick response!!

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 08-22-2008, 10:10 AM
Administrator
 
Join Date: Sep 2005
Posts: 15,954
Blog Entries: 65
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
Elders market thermometer - from "Come in my trading room" - a real classic: good indicator coded by mladen.
__________________
My blog on TSD
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
When Does Market Open? mikejody General Discussion 2 01-01-2007 06:20 PM
What a morning market. goover General Discussion 29 06-13-2006 02:50 AM


All times are GMT. The time now is 12:44 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.