Alert

To add comments, please log in or register
Jhonson075
2
Jhonson075  
//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2012, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property strict
#property version "2.5"
#property indicator_chart_window
#include <stdlib.mqh>
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_width1 2 
#property indicator_color2 Red
#property indicator_width2 2


//+------------------------------------------------------------------
//| Common External variables                                        
//+------------------------------------------------------------------


//+------------------------------------------------------------------
//| External variables                                               
//+------------------------------------------------------------------

extern double nPips=0.004;

//+------------------------------------------------------------------
//| Special Convertion Functions                                     
//+------------------------------------------------------------------


int LastTradeTime;
double ExtHistoBuffer[];
double ExtHistoBuffer2[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SetLoopCount(int loops)
  {
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SetIndexValue(int shift,double value)
  {
   ExtHistoBuffer[shift]=value;

  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SetIndexValue2(int shift,double value)
  {
   ExtHistoBuffer2[shift]=value;

  }
//+------------------------------------------------------------------
//| End                                                              
//+------------------------------------------------------------------


//+------------------------------------------------------------------
//| Initialization                                                   
//+------------------------------------------------------------------


int init()
  {
   SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID);
   SetIndexArrow(0,233);
   SetIndexBuffer(0,ExtHistoBuffer);
   SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID);
   SetIndexArrow(1,234);
   SetIndexBuffer(0,ExtHistoBuffer);
   SetIndexBuffer(1,ExtHistoBuffer2);
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
//+------------------------------------------------------------------
//| Local variables                                                  
//+------------------------------------------------------------------

   int shift=0;
   double cnt=0;
   double TrStopLevel=0;
   double PREV = 0;
   double pass = 0;

   SetLoopCount(0);
// loop from first bar to current bar (with shift=0)
   for(shift=Bars-2;shift>=0;shift--)
     {

      if((Close[shift]==PREV))
        {
         TrStopLevel=PREV;

        }
      else
        {
         if((Close[shift+1])<PREV && (Close[shift]<PREV))
           {
            TrStopLevel=MathMin(PREV,Close[shift]*(1+nPips));
           }

         else
           {
            if(((Close[shift+1])>PREV) && (Close[shift]>PREV))
              {
               TrStopLevel=MathMax(PREV,Close[shift]*(1-nPips));
              }

            else
              {
               if((Close[shift]>PREV))
                 {
                  TrStopLevel=Close[shift]*(1-nPips);
                 }

               else TrStopLevel=Close[shift]*
                                (1+nPips);
              }
           }
        }

      if(Close[shift]>TrStopLevel && Close[shift+1]<PREV && PREV!=
         0)
        {
         //SetOrder(OP_BUY,1,ask,2,0,ask+TakeProfit*Point,blue);
         //Alert("buy");
         SetIndexValue(shift,TrStopLevel);

        }

      if(Close[shift]<TrStopLevel && Close[shift+1]>PREV && PREV!=
         0)
        {
         //SetOrder(OP_SELL,1,bid,2,0,bid-TakeProfit*Point,Red);
         SetIndexValue2(shift,TrStopLevel);
         //Alert("Sell");
        }

      PREV=TrStopLevel;
      //Alert("Signal",TrStopLevel);
     }

   return(0);
  }

//+------------------------------------------------------------------+
Hi all, please help, need code to insert the notification (alert) on the signals to buy or sell. Can not understand, if you insert there where some comments (lines 135 and 145), the signal zadavayte and every second.
To add comments, please log in or register