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 8th April 2010, 18:36
Default Avatar
Junior Member
 
Join Date: Jan 2010
Location: italy
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Alert question

On MT4 I had the code for trigger "alert once on the bar current":

static bool TriggerOnlyThisBar;

...............

...............

if (......trigger condition......) && TriggerOnlyThisBar!=Bars
{
Alert(Symbol()," TEST ");
TriggerOnlyThisBar = Bars;
}


on mt5 I have replaced Bars (MT4) with Bars (symbol (), period_current) but does not work.

Someone explains to me where it is error?

Thanks to all.
Reply With Quote
  #2 (permalink)  
Old 8th April 2010, 20:00
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,542
Thanks: 18
Thanked 20 Times in 16 Posts
Default

What? Does it continue to trigger the alert without the new bar coming?
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #3 (permalink)  
Old 9th April 2010, 05:18
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
What? Does it continue to trigger the alert without the new bar coming?
Exact.The alarm should be triggered only the first time there is the bar that is forming.
Example:
bar 5 minutes
trigger alarm at second minute
stop alarm until 5 minutes even if the signal comes back
...on MT4 working bat not in MT5:I do not understand ....
Can you help ?
Reply With Quote
  #4 (permalink)  
Old 9th April 2010, 07:25
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,542
Thanks: 18
Thanked 20 Times in 16 Posts
Default

Can you copy the exact code of that part of your indicator? Maybe there is some syntax typo that causes this error.
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #5 (permalink)  
Old 9th April 2010, 07:48
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
Can you copy the exact code of that part of your indicator? Maybe there is some syntax typo that causes this error.
Yes.This is the code:
MQL5 Code:
#property copyright "Copyright © 2009"
#property link      ""
#property version   ""
#property description ""


#property indicator_chart_window
#property indicator_buffers 1
double CCIBUFFER[];

static bool TriggerOnlyThisBar;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
{
 
//---- indicator buffers mapping  
   SetIndexBuffer(0, CCIBUFFER);
   
}
//+------------------------------------------------------------------+
//| Custom CCI Arrows                                                |
//+------------------------------------------------------------------+
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 handle;
handle = iCCI(NULL, PERIOD_M5, 14, PRICE_CLOSE);
int buffer_num=BarsCalculated(handle);
CopyBuffer(handle,0,0,buffer_num,CCIBUFFER);
ArraySetAsSeries(CCIBUFFER,true);  

   {
     
         if((CCIBUFFER[0] > 0)&&
            (CCIBUFFER[1] < 0)&&
            TriggerOnlyThisBar != Bars(Symbol(),PERIOD_M5))
    {
      Alert(Symbol()," SIGNAL DOWN ");
       TriggerOnlyThisBar = Bars(Symbol(),PERIOD_M5);
    }    
   }
   
         if ((CCIBUFFER[0] < 0)&&
             (CCIBUFFER[1] > 0)&&
             TriggerOnlyThisBar != Bars(Symbol(),PERIOD_M5))    
    {
      Alert(Symbol(),"SIGNAL UP ");
       TriggerOnlyThisBar = Bars(Symbol(),PERIOD_M5);
        }

   return(rates_total);
}

Last edited by intraforex; 9th April 2010 at 07:50.
Reply With Quote
  #6 (permalink)  
Old 9th April 2010, 16:40
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,542
Thanks: 18
Thanked 20 Times in 16 Posts
Default

You have an extra pair of "{}" in your code for some reason. But that's not the problem. The problem is that you don't take this condition - TriggerOnlyThisBar != Bars(Symbol(),PERIOD_M5) - in the brackets "()". Correct example:

MQL5 Code:
if((CCIBUFFER[0] > 0)&&
            (CCIBUFFER[1] < 0)&&
            (TriggerOnlyThisBar != Bars(Symbol(),PERIOD_M5)))
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #7 (permalink)  
Old 9th April 2010, 18: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 have an extra pair of "{}" in your code for some reason. But that's not the problem. The problem is that you don't take this condition - TriggerOnlyThisBar != Bars(Symbol(),PERIOD_M5) - in the brackets "()". Correct example:

MQL5 Code:
if((CCIBUFFER[0] > 0)&&
            (CCIBUFFER[1] < 0)&&
            (TriggerOnlyThisBar != Bars(Symbol(),PERIOD_M5)))
Enivid : you have tested the code ?
I do not work: the alarm continues to play until the completion of the bar....
Reply With Quote
  #8 (permalink)  
Old 9th April 2010, 19:47
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
Enivid : you have tested the code ?
I do not work: the alarm continues to play until the completion of the bar....
Do you use it on M5?

EDIT: I've found the real problem . It shouldn't be bool. Make it int or long. And remove static, it's not needed if you declare it as a global variable.
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #9 (permalink)  
Old 10th April 2010, 04:22
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
Do you use it on M5?

EDIT: I've found the real problem . It shouldn't be bool. Make it int or long. And remove static, it's not needed if you declare it as a global variable.
thanks Enivid ... Monday I'll try your changes and then I tell you if it works.
Reply With Quote
  #10 (permalink)  
Old 12th April 2010, 05:07
Default Avatar
Junior Member
 
Join Date: Jan 2010
Location: italy
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have modify the code:
MQL5 Code:
#property indicator_chart_window
#property indicator_buffers 1
double CCIBUFFER[];

bool TriggerOnlyThisBar;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
{
 
//---- indicator buffers mapping  
   SetIndexBuffer(0, CCIBUFFER);
   
}
//+------------------------------------------------------------------+
//| Custom CCI Arrows                                                |
//+------------------------------------------------------------------+
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 handle;
handle = iCCI(NULL, PERIOD_M3, 14, PRICE_CLOSE);
int buffer_num=BarsCalculated(handle);
CopyBuffer(handle,0,0,buffer_num,CCIBUFFER);
ArraySetAsSeries(CCIBUFFER,true);  

  if((CCIBUFFER[0] > 0)&&
     (CCIBUFFER[1] < 0)&&
     (TriggerOnlyThisBar != Bars(Symbol(),PERIOD_M3)));
      {      
      Alert(Symbol()," UP ");
       TriggerOnlyThisBar = Bars(Symbol(),PERIOD_M3);
      }    
   
   if((CCIBUFFER[0] < 0)&&
      (CCIBUFFER[1] > 0)&&
      (TriggerOnlyThisBar != Bars(Symbol(),PERIOD_M3)))
      {
      Alert(Symbol()," DOWN ");
       TriggerOnlyThisBar = Bars(Symbol(),PERIOD_M3);
      }
   return(rates_total);
}
....but still sounds alarm continuous incessant on the all bar of trigger
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
Price Alert Enivid MetaTrader Indicators 11 8th December 2011 10:33
Question on MT5 alessio09 MetaTrader 5 2 6th January 2010 01:10
Reserve Currency Status In Question mercaforex Fundamental Analysis 0 13th October 2009 18:56
Parabolic Indicator Question JXBlack MetaTrader Indicators 2 9th October 2009 09:04
Please Help - Indicator Alarm/Alert Needed doggie01 MetaTrader Indicators 0 4th February 2009 10:31


All times are GMT. The time now is 00:19.


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