Forex
Google
New signals service!

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Questions


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 07-13-2006, 07:57 PM
Aaragorn's Avatar
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
Adding moving average lines to chart

I am new with drawing objects. I have an EA that uses three moving averages for trades...

I have some issues with the strategy tester always drawing two moving average lines on the charts when I open them after a test...they are not the right ma lines...

so...

I want to add the code to my EA to make it draw the MA lines I'm using as well as place the trades...

I don't really know what I'm doing with this, when I put this code in the EA it stops placing trades in the tester....

PHP Code:
   int    counted_bars=IndicatorCounted();
   
     
string ShortemaS;
     
string ShortemaL;
     
string Ctrendema;
 
//---- check for possible errors
   
if (counted_bars<0) return(-1);
//---- last counted bar will be recounted
   
if (counted_bars>0counted_bars--;
   
   
int pos=Bars-counted_bars;
   
     
 
   while(
pos>=0)
     {    
         
ExtMapBuffer1[pos]= iMA(NULL0ShortemaS0MODE_EMAPRICE_CLOSECurrent 0);
         
ExtMapBuffer2[pos]= iMA(NULL0ShortemaL0MODE_EMAPRICE_CLOSECurrent 0);
         
ExtMapBuffer3[pos]= iMA(NULL0Ctrendema0MODE_EMAPRICE_CLOSECurrent 0);
 
         
pos--;
     }   
     
//---- indicator line
          
SetIndexStyle(0,DRAW_LINESTYLE_SOLID2Green);
          
SetIndexBuffer(0,ExtMapBuffer1);
          
SetIndexStyle(0,DRAW_LINESTYLE_SOLID2Yellow);
          
SetIndexBuffer(0,ExtMapBuffer2);
          
SetIndexStyle(0,DRAW_LINESTYLE_SOLID2Red);
          
SetIndexBuffer(0,ExtMapBuffer3);
      return(
0); 
It doesn't draw the lines either so I know I've not got it hooked up right.

please advise.

Last edited by Aaragorn; 07-13-2006 at 08:19 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-14-2006, 05:41 AM
Member
 
Join Date: Mar 2006
Posts: 49
pipeline is on a distinguished road
I haven't tried it but in my mind EAs are not designed to draw stuff on the chart, indicators are. So I draw non built-in MAs with an indicator.

You have declared but not initialized your string variables: they're empty strings (""). So the iCustom() won't know which .ex4 file to open.

I see no reason why the "indicator line" section sould be in start{} rather than in init{}.
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 Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding price to MA on chart techtrader Indicators - Metatrader 4 0 03-06-2007 10:06 PM
Adding Histogram to a Chart aparsai Metatrader 4 4 07-07-2006 08:13 PM
Error adding EA to chart GoatT Expert Advisors - Metatrader 4 10 06-08-2006 01:59 AM
How to calculate Moving Average of a Moving Average babarmughal Expert Advisors - Metatrader 4 2 05-15-2006 11:11 AM


All times are GMT. The time now is 05:09 AM.



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