• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 3:35am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 3:35am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Adding Line to Indicator 0 replies

100pips EA problem 9 replies

Maximum Risk 2% - 5% PerTrade (100pips SL) 1 reply

5M Channel Scalping - 100pips \ week 38 replies

Adding an indicator to an indicator 10 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 2
Attachments: Adding MovingAverage+100pips line to my MA indicator
Exit Attachments

Adding MovingAverage+100pips line to my MA indicator

  • Post #1
  • Quote
  • First Post: Jun 17, 2008 11:50am Jun 17, 2008 11:50am
  •  Johny-Raa
  • | Joined Jun 2008 | Status: Member | 12 Posts
Hello,

I'm trying to add another line to my MA indicator but I'm not sure how to do this very simple thing.

I just want to have another line that look exactly like my Moving Average but + a number of ticks/pips. I attach an image to make it clear.

How do I add it to this simple MA indicator code? :

Inserted Code
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Green
extern int period=5;
double SMA[];
double sum=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0, SMA);
   SetIndexLabel(0,"Sma");
   SetIndexStyle(0,DRAW_LINE);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   int limit;
   if(counted_bars < 0) 
        return(-1);
   if(counted_bars > 0) 
        counted_bars--;
   limit=Bars-counted_bars-1;
   for(int i=limit; i >=0; i--) 
   {
      sum=0;
      for(int j=i+period-1;j>=i; j--)
      {
          sum+=Close[j];
      }
      SMA[i]=sum/period;
   }
return(0);
}

In my other software that I use (eSignal) it's simlple as this code:

Inserted Code
var MA;
function main()
{ 
MA = sma(200);
var MAextra = MA;
return new array(MA, MAextra+100);
}

Any help will be much appreciated.

Kind Regards,

Johny-Raa.
Attached Image (click to enlarge)
Click to Enlarge

Name: 200ma.png
Size: 33 KB
  • Post #2
  • Quote
  • Jun 17, 2008 12:07pm Jun 17, 2008 12:07pm
  •  FXNewbie1
  • | Joined May 2008 | Status: Member | 38 Posts
Not sure if this is right, but have you tried:
SMA[i]=sum/period;+100


And:
var MAextra = MA+100;?
 
 
  • Post #3
  • Quote
  • Jun 17, 2008 1:07pm Jun 17, 2008 1:07pm
  •  magnumfreak
  • Joined Nov 2007 | Status: Trying manual mode again | 2,210 Posts
There are two ways to go about this:

1. Don't make your own indicator for a moving average. Use the one included with mt4 and then add a level at +100.
2. Create one with your indicator by adding another indicator buffer and then adding 100 pips to the moving average buffer. In order to do this over all currencies you will need to add 100*Point to each value in the original indicator buffer.
 
 
  • Post #4
  • Quote
  • Jun 17, 2008 7:10pm Jun 17, 2008 7:10pm
  •  Johny-Raa
  • | Joined Jun 2008 | Status: Member | 12 Posts
FXNewbie1 & magnumfreak, Thank you both for your posts.

FXNewbie1, I tried that but It didnt work.

magnumfreak, I tried both ways but I'm not familiar enough with MetaTrader language so I have errors... I know this is a very simple thing to do but still I have no luck.

Can you please show me the lines that I need to add and where I need to add them ? or maybe you can add them for me..
Thanks again for the help,

Kind Regards,

Johny-Raa.
 
 
  • Post #5
  • Quote
  • Jun 17, 2008 7:39pm Jun 17, 2008 7:39pm
  •  magnumfreak
  • Joined Nov 2007 | Status: Trying manual mode again | 2,210 Posts
Try this, it is set up for a simple moving average with a 100 pip offset for the second line.
Attached File
File Type: mq4 MAChannel.mq4   2 KB | 498 downloads
 
 
  • Post #6
  • Quote
  • Last Post: Jun 18, 2008 1:26pm Jun 18, 2008 1:26pm
  •  Johny-Raa
  • | Joined Jun 2008 | Status: Member | 12 Posts
magnumfreak, You have no idea how much I appreciate your help. Thank you very much!

Kind Regards,

Johny-Raa.
 
 
  • Platform Tech
  • /
  • Adding MovingAverage+100pips line to my MA indicator
  • Reply to Thread
0 traders viewing now
Top of Page
Forex Factory Blog Updated: Alerting All Members
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2022