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
  #1 (permalink)  
Old 11th January 2011, 16:09
Default Avatar
Junior Member
 
Join Date: Jan 2010
Location: italy
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default CCI alert

Hi all,
anyone tried to make an alarm at the cross of the zero line of the CCI for Metatrader5 ?
I want to create a alert but I do not know how it works: someone can 'help me?
Thanks.
Reply With Quote
  #2 (permalink)  
Old 11th January 2011, 20:40
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,542
Thanks: 18
Thanked 20 Times in 16 Posts
Default

You need to create a custom indicator that uses the standard CCI indicator. You need to check the current value of CCI and the previous value of CCI - if the current is >= 0, while the previous is < 0 then an alert should be issued. If the current value is < 0 and the previous value is >= 0 then an alert should be issued.
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #3 (permalink)  
Old 13th January 2011, 05:06
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
You need to create a custom indicator that uses the standard CCI indicator. You need to check the current value of CCI and the previous value of CCI - if the current is >= 0, while the previous is < 0 then an alert should be issued. If the current value is < 0 and the previous value is >= 0 then an alert should be issued.
Hi Enivid,
I created this code but I think there is any problem.
You can get an indication?
I'm not interested in seeing the ICC in chart, is important that alert only.
Thanks
Quote:
#property indicator_chart_window
#property indicator_buffers 1


double CCI[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,CCI,INDICATOR_DATA);

//---
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 limit;
int i;
int counted_bars=prev_calculated;
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=rates_total-counted_bars;
//---- cci counted in the buffer
CCI[i]=iCCI(NULL,0,14,PRICE_CLOSE);
for(int i=0; i<limit; i--)
{
if ((CCI[i-1]<0)&&
(CCI[i-2]>0));
{
Alert ("TEST");
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Reply With Quote
  #4 (permalink)  
Old 13th January 2011, 11:13
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,542
Thanks: 18
Thanked 20 Times in 16 Posts
Default

You can't do this in MT5:
CCI[i]=iCCI(NULL,0,14,PRICE_CLOSE);

You have to get the indicator handle first and then copy its values into a buffer. Similar to this:

int myCCI = iCCI(NULL,0,14,PRICE_CLOSE);
if (CopyBuffer(myCCI, 0, 0, rates_total, CCI_Buffer) != rates_total) return(0);

You'll also want your OnCalculate() to run only on new bar openings - otherwise you'll get a lot of alerts after each cross.
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #5 (permalink)  
Old 13th January 2011, 16: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
You'll also want your OnCalculate() to run only on new bar openings - otherwise you'll get a lot of alerts after each cross.
Enivid :could you explain this passage?...is very different from Mt4....
Thanks
Reply With Quote
  #6 (permalink)  
Old 14th January 2011, 08:55
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,542
Thanks: 18
Thanked 20 Times in 16 Posts
Default

You need to write the rates_total (amount of bars) into some global variable and check in OnCalculate() if the new rates_total is different from the old one. If it is, then remember a new amount and proceed to the rest of the function, otherwise return from the function.
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #7 (permalink)  
Old 17th January 2011, 14:04
Default Avatar
Junior Member
 
Join Date: Jan 2010
Location: italy
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried putting this function:
MQL5 Code:
  for(int i=1;i<rates_total;i++)

is that correct?
I know very little programming .... I'm at the beginning....
Thanks
Reply With Quote
  #8 (permalink)  
Old 17th January 2011, 20:03
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,542
Thanks: 18
Thanked 20 Times in 16 Posts
Default

Quote:
Originally Posted by intraforex View Post
I tried putting this function:
MQL5 Code:
  for(int i=1;i<rates_total;i++)

is that correct?
I know very little programming .... I'm at the beginning....
Thanks
No, that's just a cycle through all the chart bars (except for the very first one, with the number 0).

Look at some of my indicators here:
http://www.earnforex.com/metatrader-indicators

Look for variable LastBars and what's done with it.
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #9 (permalink)  
Old 22nd February 2011, 13:08
Default Avatar
Junior Member
 
Join Date: Feb 2011
Location: USA
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Despite the bad press I have found them to be very good. Just stay away from numismatics and stick to bullion. When I last bought their margin above spot was very competative. The best part is that they a super professional. They are always in constant communication about your order. Highly trust worthy. Would use again.
__________________
Osbaldo
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
TRADE ALERT eja Advertisements 0 19th October 2010 11:42
TRADE ALERT eja Advertisements 0 18th October 2010 10:44
TRADE ALERT eja Advertisements 0 14th October 2010 08:34
TRADE ALERT eja Advertisements 0 13th October 2010 08:44
TRADE ALERT eja Advertisements 0 12th October 2010 07:24


All times are GMT. The time now is 01:54.


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