Forex Forum - EarnForex
Serving Traders Since 2005
 

Go Back   Forex Forum - EarnForex > MetaTrader > MetaTrader Indicators

MetaTrader Indicators Post and discuss the MetaTrader indicators here.

Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 7th January 2010, 05:49
Default Avatar
Junior Member
 
Join Date: Jan 2010
Location: italy
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Enivid View Post
Not exactly, but it looks similar. Do you have the code?
Yes,thi is the code only histogram.
1)Add the code (CCI_HISTO.mql5), to chart
2)Insert in indicator (CCI_HIsto) separate windows one CCI indicator standard at 14 period.
3)Insert in indicator (CCI_HIsto) separate windows one CCI indicator standard at 7 period.

I think you see that my programming is not perfect but it works
I would want to improve the CCI inserting other instructions: you can help?
Thanks
Attached Files
File Type: mq5 CCI_HISTO.mq5 (5.1 KB, 6 views)
Reply With Quote
  #12 (permalink)  
Old 7th January 2010, 09:17
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,446
Thanks: 6
Thanked 8 Times in 7 Posts
Default

I can try to help .
Reply With Quote
  #13 (permalink)  
Old 7th January 2010, 10:42
Default Avatar
Junior Member
 
Join Date: Jan 2010
Location: italy
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Enivid View Post
I can try to help .
I would like Insert inside of the indicator the value of CCI like the example.
I am interested above all the procedure for viewing... for the values we ca n't.
Thanks for help.

Example :
http://clip2net.com/clip/m19204/1262...-clip-25kb.png
Reply With Quote
  #14 (permalink)  
Old 11th January 2010, 07:22
Default Avatar
Junior Member
 
Join Date: Jan 2010
Location: italy
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Reply With Quote
  #15 (permalink)  
Old 11th January 2010, 08:12
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,446
Thanks: 6
Thanked 8 Times in 7 Posts
Default

Quote:
Originally Posted by intraforex View Post
I would like Insert inside of the indicator the value of CCI like the example.
I am interested above all the procedure for viewing... for the values we ca n't.
Thanks for help.

Example :
http://clip2net.com/clip/m19204/1262...-clip-25kb.png
I am not sure that you can insert text labels into the separate indicator window.
Reply With Quote
  #16 (permalink)  
Old 11th January 2010, 14:16
Default Avatar
Member
 
Join Date: Dec 2009
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Enivid View Post
I am not sure that you can insert text labels into the separate indicator window.

ObjectCreate(0, "myobject_name", OBJ_LABEL, 1, 0, 0);

This expression should create the object in the indicator window, but this feature is not working (yet).
Reply With Quote
  #17 (permalink)  
Old 13th January 2010, 15:20
Default Avatar
Junior Member
 
Join Date: Jan 2010
Location: italy
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How can I assign to a variable the price of the close of a candle or bar ?
thanks.
Reply With Quote
  #18 (permalink)  
Old 13th January 2010, 17:45
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,446
Thanks: 6
Thanked 8 Times in 7 Posts
Default

Quote:
Originally Posted by intraforex View Post
How can I assign to a variable the price of the close of a candle or bar ?
thanks.
In indicator's event handler OnCalculate() you have an access to array Close[], so you can just write:

double a = Close[0];

to assign the close value of the latest candle (the first if it's not set as tiemseries) to variable "a".
Reply With Quote
  #19 (permalink)  
Old 25th January 2010, 07:17
Default Avatar
Junior Member
 
Join Date: Jan 2010
Location: italy
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Someone helps me with this simple indicator?
Arrow Green when MA1>MA2
Arrow Red when MA1<MA2
MQL5 Code:
#property copyright "2009, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window

#property indicator_buffers 2
#property indicator_plots  2

#property indicator_label1  "ARROW1"
#property indicator_type1   DRAW_ARROW
#property indicator_style1  STYLE_SOLID
#property indicator_color1  Green
#property indicator_width1  1

#property indicator_label2  "ARROW2"
#property indicator_type2   DRAW_ARROW
#property indicator_style2  STYLE_SOLID
#property indicator_color2  Red
#property indicator_width2  1
//--- input parameters
 
double  MA1;
double  MA2;
double Arrow1[];
double Arrow2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
 SetIndexBuffer(0,Arrow1,INDICATOR_DATA);
 SetIndexBuffer(1,Arrow2,INDICATOR_DATA);
 //--- indicator name
IndicatorSetString(INDICATOR_SHORTNAME,"TEST");

//---- OnInit done
MA1=iMA(Symbol(),0,34,0,MODE_EMA,PRICE_CLOSE);
MA2=iMA(Symbol(),0,10,0,MODE_EMA,PRICE_CLOSE);
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
//---

 int i ;
  for(i=1;i<=rates_total;i--);
 
 if (MA2>MA1);
     {Arrow1[i]; }
 
 if (MA2<MA1);
    {Arrow2[i]; }  
 
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
Where is error ?
thanks to all
Reply With Quote
  #20 (permalink)  
Old 25th January 2010, 08:20
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,446
Thanks: 6
Thanked 8 Times in 7 Posts
Default

1. With iMA() function you get only indicator handle, not the buffer. You should copy the buffer to get the actual vales:

MQL5 Code:
  double MA1Buffer[];
   CopyBuffer(MA1, 0, 0, rates_total, MA1Buffer);
  double MA2Buffer[];
   CopyBuffer(MA2, 0, 0, rates_total, MA2Buffer);

Do this inside your OnCalculate() handler.

2. Then you need compare the buffer values rather than handles when determining the arrow. You also need to give your arrow buffers the actual values rather than just stating them:
MQL5 Code:
 if (MA2Buffer[i]>MA1MABuffer[i]);
     {Arrow1[i] = MA2Buffer[i]; }
 
 if (MA2Buffer[i]<MA1Buffer[i]);
    {Arrow2[i] = MA2Buffer[i]; }

3. When you have this working you may want to modify this code to draw arrows only on MA cross, not on all bars, but I don't know if that's relevant for you.
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Murrey Math Line X Enivid MetaTrader Indicators 10 29th May 2011 10:34
Automatic Trend Line Alerts for MetaTrader 4 AutoTrader MetaTrader Expert Advisors 0 19th September 2009 15:34
Trend Line Indicator for MetaTrader 4 TrendLineTrader MetaTrader Indicators 0 11th September 2009 10:02
Gold Double Top SwingTrdr Technical Analysis 0 7th September 2009 06:21
Weekly Unemployment Claims In Line mercaforex Fundamental Analysis 0 23rd July 2009 11:00


All times are GMT. The time now is 07:02.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Inactive Reminders By Icora Web Design

SEO by vBSEO 3.3.2