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 28th May 2011, 23:14
Default Avatar
Junior Member
 
Join Date: May 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default where i can add alert line in this code ?

i need to add alert when the signal appear

this is the code
MQL5 Code:
 //+------------------------------------------------------------------+
//| lukas1 arrows & curves.mq4 v.14 |
//| Èçìåíåíèÿ: |
//| 1. Óáðàíû íåíóæíûå (ëèøíèå) êîýôôèöèåíû, íå ó÷àñòâóþùèå |
//| â ðàñ÷åòàõ Kmin, Kmax, RISK |
//| 2. Ìàòåìàòèêà èíäèêàòîðà âñå ðàñ÷åòû âûïîëíÿåò |
//| âíóòðè îäíîãî öèêëà, ýòî óâåëè÷èëî ñêîðîñòü îáñ÷¸òà. |
//| 3. Âûêëþ÷åíî ìåðöàíèå ñòðåëîê. |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, lukas1"
#property link "http://www.alpari-idc.ru/"
//----
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Green
#property indicator_color4 Green
//---- input parameters
extern int SSP = 6; //ïåðèîä ëèíåéíîãî ðàçâîðîòà èíäèêàòîðà
extern int CountBars = 2250; //ðàñ÷åòíûé ïåðèîä
extern int SkyCh = 13; //÷óâñòâèòåëüíîñòü ê ïðîáîþ êàíàëà
//Äîëæíà áûòü â äèàïàçîíå 0-50. 0 - íåò ñòðåëîê. Áîëüøå 50 - ïåðåðåãóëèðîâàíèå
int i;
double high, low, smin, smax;
double val1[]; // áóôåð äëÿ áàé
double val2[]; // áóôåð äëÿ ñåëë
double Sky_BufferH[];
double Sky_BufferL[];
bool uptrend, old;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
 {
 SetIndexStyle(0, DRAW_ARROW);
 SetIndexArrow(0, 233); // ñòðåëêà äëÿ áàé
 SetIndexBuffer(0, val1); // èíäåêñ áóôåðà äëÿ áàé
 SetIndexDrawBegin(0, 2*SSP);
 //
 SetIndexStyle(1, DRAW_ARROW);
 SetIndexArrow(1, 234); // ñòðåëêà äëÿ ñåëë
 SetIndexBuffer(1, val2); // èíäåêñ áóôåðà äëÿ ñåëë
 SetIndexDrawBegin(1, 2*SSP);
 //
 SetIndexStyle(2, DRAW_LINE);
 SetIndexBuffer(2, Sky_BufferH);
 SetIndexLabel(2, "High");
 SetIndexDrawBegin(2, 2*SSP);
 //
 SetIndexStyle(3, DRAW_LINE);
 SetIndexBuffer(3, Sky_BufferL);
 SetIndexLabel(3, "Low");
 SetIndexDrawBegin(3, 2*SSP);
//----
 return(0);
 }
//+------------------------------------------------------------------+
//| Calculation of SilverTrend lines |
//+------------------------------------------------------------------+
int start()
 {
 int counted_bars = IndicatorCounted();
//---- ïîñëåäíèé ïîñ÷èòàííûé áàð áóäåò ïåðåñ÷èòàí
 if(counted_bars > 0) counted_bars--;
//----
 if(Bars <= SSP + 1) return(0);
//---- initial zero
 uptrend =false;
 old =false;
 GlobalVariableSet("goSELL", 0); // çàäàëè ñóùåñòâîâàíèå è îáíóëèëè goSELL=0
 GlobalVariableSet("goBUY", 0); // çàäàëè ñóùåñòâîâàíèå è îáíóëèëè goBUY =0
//----
 for(i = CountBars - SSP; i >= 0; i--) // óìåíüø çíà÷åíèå shift íà 1 çà ïðîõîä;
 {
 high = High[iHighest(Symbol(),0,MODE_HIGH,SSP,i)];
 low = Low[iLowest(Symbol(),0,MODE_LOW,SSP,i)];
 smax = high - (high - low)*SkyCh / 100; // smax íèæå high ñ ó÷åòîì êîýôô.SkyCh
 smin = low + (high - low)*SkyCh / 100; // smin âûøå low ñ ó÷åòîì êîýôô.SkyCh
 val1[i] = 0;
 val2[i] = 0;
 if(Close[i] < smin && i!=0 ) // âûêëþ÷åíî ìåðöàíèå ñòðåëîê (i!=0)
 {
 uptrend = false;
 }
 if(Close[i] > smax && i!=0 ) // âûêëþ÷åíî ìåðöàíèå ñòðåëîê (i!=0)
 {
 uptrend = true;
 }
 if(uptrend != old && uptrend == false)
 {
 val2[i] = high; // åñëè óñëîâèÿ âûïîëíåíû òî ðèñóåì val1
 if(i == 0) GlobalVariableSet("goBUY",1);
 }
 if(uptrend != old && uptrend == true )
 {
 val1[i] = low; // åñëè óñëîâèÿ âûïîëíåíû òî ðèñóåì val2
 if(i == 0) GlobalVariableSet("goSELL",1);
 }
 old=uptrend;
 Sky_BufferH[i]=high - (high - low)*SkyCh / 100;
 Sky_BufferL[i]=low + (high - low)*SkyCh / 100;
 }
 return(0);
 }
//+------------------------------------------------------------------+
Attached Files
File Type: mq4 lukas1 Arrows & Curves.mq4 (4.2 KB, 12 views)
Reply With Quote
  #2 (permalink)  
Old 29th May 2011, 10:21
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,542
Thanks: 18
Thanked 20 Times in 16 Posts
Default

Insert this line:

MQL5 Code:
datetime WasAlert;

After this one:

MQL5 Code:
bool   uptrend, old;

This one:

MQL5 Code:
if ((i == 0) && (WasAlert != Time[0])) { Alert("Up!"); PlaySound("alert.wav"); WasAlert = Time[0];}

After this one:

MQL5 Code:
val2[i] = high; // если условия выполнены то рисуем val1

And this one:

MQL5 Code:
if ((i == 0) && (WasAlert != Time[0])) { Alert("Down!"); PlaySound("alert.wav"); WasAlert = Time[0];}

After this one:

MQL5 Code:
val1[i] = low; // если условия выполнены то рисуем val2
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #3 (permalink)  
Old 29th May 2011, 10:49
Default Avatar
Junior Member
 
Join Date: May 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thaks alot bro

Q: is the signal is fixed when it appear and when it appear at the begging
of the candle or after closing ???
Q : is that true ( the new line in red color) ?
MQL5 Code:
//+------------------------------------------------------------------+
//|                      lukas1 arrows & curves.mq4       v.14       |
//|       Èçìåíåíèÿ:                                                 |
//|       1. Óáðàíû íåíóæíûå (ëèøíèå) êîýôôèöèåíû, íå ó÷àñòâóþùèå    |
//|          â ðàñ÷åòàõ Kmin, Kmax, RISK                             |
//|       2. Ìàòåìàòèêà èíäèêàòîðà âñå ðàñ÷åòû âûïîëíÿåò             |
//|          âíóòðè îäíîãî öèêëà, ýòî óâåëè÷èëî ñêîðîñòü îáñ÷¸òà.    |
//|       3. Âûêëþ÷åíî ìåðöàíèå ñòðåëîê.                             |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, lukas1"
#property link      "http://www.alpari-idc.ru/"
//----
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Green
#property indicator_color4 Green
//---- input parameters
extern int SSP       = 6;     //ïåðèîä ëèíåéíîãî ðàçâîðîòà èíäèêàòîðà
extern int CountBars = 2250;  //ðàñ÷åòíûé ïåðèîä
extern int SkyCh     = 13;    //÷óâñòâèòåëüíîñòü ê ïðîáîþ êàíàëà
//Äîëæíà áûòü â äèàïàçîíå 0-50. 0 - íåò ñòðåëîê. Áîëüøå 50 - ïåðåðåãóëèðîâàíèå
int    i;
double high, low, smin, smax;
double val1[];      // áóôåð äëÿ áàé
double val2[];      // áóôåð äëÿ ñåëë
double Sky_BufferH[];
double Sky_BufferL[];
bool   uptrend, old;
[COLOR="red"][B]datetime WasAlert;[/B][/COLOR]
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 233);        // ñòðåëêà äëÿ áàé
   SetIndexBuffer(0, val1);      // èíäåêñ áóôåðà äëÿ áàé
   SetIndexDrawBegin(0, 2*SSP);
   //
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1, 234);        // ñòðåëêà äëÿ ñåëë
   SetIndexBuffer(1, val2);      // èíäåêñ áóôåðà äëÿ ñåëë
   SetIndexDrawBegin(1, 2*SSP);
   //
   SetIndexStyle(2, DRAW_LINE);
   SetIndexBuffer(2, Sky_BufferH);
   SetIndexLabel(2, "High");
   SetIndexDrawBegin(2, 2*SSP);
   //
   SetIndexStyle(3, DRAW_LINE);
   SetIndexBuffer(3, Sky_BufferL);
   SetIndexLabel(3, "Low");
   SetIndexDrawBegin(3, 2*SSP);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Calculation of SilverTrend lines                                 |
//+------------------------------------------------------------------+
int start()
  {  
   int counted_bars = IndicatorCounted();
//---- ïîñëåäíèé ïîñ÷èòàííûé áàð áóäåò ïåðåñ÷èòàí
   if(counted_bars > 0) counted_bars--;
//----
   if(Bars <= SSP + 1)        return(0);
//---- initial zero
   uptrend       =false;
   old           =false;
   GlobalVariableSet("goSELL", 0); // çàäàëè ñóùåñòâîâàíèå è îáíóëèëè goSELL=0
   GlobalVariableSet("goBUY", 0);  // çàäàëè ñóùåñòâîâàíèå è îáíóëèëè goBUY =0
//----
   for(i = CountBars - SSP; i >= 0; i--) // óìåíüø çíà÷åíèå shift íà 1 çà ïðîõîä;
     {
       high = High[iHighest(Symbol(),0,MODE_HIGH,SSP,i)];
       low = Low[iLowest(Symbol(),0,MODE_LOW,SSP,i)];
       smax = high - (high - low)*SkyCh / 100; // smax íèæå high ñ ó÷åòîì êîýôô.SkyCh
       smin = low + (high - low)*SkyCh / 100;  // smin âûøå low ñ ó÷åòîì êîýôô.SkyCh
        val1[i] = 0;  
       val2[i] = 0;
       if(Close[i] < smin && i!=0 ) // âûêëþ÷åíî ìåðöàíèå ñòðåëîê (i!=0)
       {
       uptrend = false;
       }
        if(Close[i] > smax && i!=0 )    // âûêëþ÷åíî ìåðöàíèå ñòðåëîê (i!=0)   
        {
        uptrend = true;      
       }      
       if(uptrend != old && uptrend == false)
         {
           val2[i] = high; // åñëè óñëîâèÿ âûïîëíåíû òî ðèñóåì val1
[COLOR="red"]          [B] if ((i == 0) && (WasAlert != Time[0])) { Alert("Up!"); PlaySound("alert.wav"); WasAlert = Time[0];}[/B][/COLOR]
          if(i == 0)                GlobalVariableSet("goBUY",1);
         }
       if(uptrend != old && uptrend == true )
         {
           val1[i] = low; // åñëè óñëîâèÿ âûïîëíåíû òî ðèñóåì val2
[COLOR="red"]    [B] if ((i == 0) && (WasAlert != Time[0])) { Alert("Down!"); PlaySound("alert.wav"); WasAlert = Time[0];}[/B][/COLOR]
           if(i == 0)                GlobalVariableSet("goSELL",1);
         }
       old=uptrend;
       Sky_BufferH[i]=high - (high - low)*SkyCh / 100;
       Sky_BufferL[i]=low +  (high - low)*SkyCh / 100;
     }
   return(0);
  }
//+------------------------------------------------------------------+
Reply With Quote
  #4 (permalink)  
Old 29th May 2011, 11:07
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,542
Thanks: 18
Thanked 20 Times in 16 Posts
Default

As far as I understand it, the signal may disappear on the current bar as it changes.

Yes, it's correct.
__________________
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
code EA for 15-25$ crn Advertisements 5 24th March 2012 07:49
I'll code indicators, experts. cde.max Advertisements 4 22nd March 2012 06:15
Murrey Math Line X Enivid MetaTrader Indicators 12 28th February 2012 09:38
Strategy American Day Line mandarin Trading Systems and Strategies 4 5th November 2010 04:10
Fap Turbo's ForexBulletProof Code leaked?? anil595 Advertisements 0 29th August 2010 18:02


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


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