Alert modification.

 

Hi. Please help me with change a bit a code of indicator. 


 Here I try to put a commend. So when DTOSC crossing and change for SELL/Buy

 I would like to show a text on terminal Sell/Buy. I need only this monit as a text. I'm not intersting especcialy about how Dtosc looks. Only when is sell then show me text sell;

Regards my best David 

 

#property indicator_buffers 2

#property indicator_minimum 0

#property indicator_maximum 100

#property indicator_color1 Red

#property indicator_color2 Blue

#property indicator_width1 2

#property indicator_width2 2

#property indicator_level1 20

#property indicator_level2 80




extern string TimeFrame = "Current time frame";

extern int PeriodRSI =13;

extern int PeriodStoch= 8;

extern int PeriodSK = 5;

extern int PeriodSD = 3;

// 0 = SMA

// 1 - EMA

// 2 - SMMA

// 3 - LWMA

extern int MAMode=0;

extern bool alertsOn = true;

extern bool alertsOnCurrent = true;

extern bool alertsMessage = true;

extern bool alertsSound = true;

extern bool alertsEmail = false;

extern string soundfile = "alert2.wav";




double SK[];

double SD[];

double StoRSI[];

double RSI[];

double cross[];

string IndicatorFileName;

int timeFrame;

bool returnBars=false;



//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+




int init()

{

IndicatorBuffers(5);

SetIndexBuffer(0,SK);

SetIndexBuffer(1,SD);

SetIndexBuffer(2,StoRSI);

SetIndexBuffer(3,RSI);

SetIndexBuffer(4,cross);





if (TimeFrame == "getBarsCount")

{

returnBars=true;

return(0);

}

timeFrame = stringToTimeFrame(TimeFrame);







IndicatorShortName("DTOSC ("+PeriodRSI+","+PeriodStoch+","+PeriodSK+","+PeriodSD+")");

IndicatorFileName = WindowExpertName();

return(0);

}

int deinit() { return(0); }



//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+





int start()

{

int i,limit;

int counted_bars = IndicatorCounted();



if(counted_bars < 0) return(-1);

if(counted_bars > 0) counted_bars--;

limit=Bars-counted_bars;






if (returnBars) { SK[0] = limit; return(0); }

if (timeFrame != Period())

{

limit = MathMax(limit,MathMin(Bars,iCustom(NULL,timeFrame,IndicatorFileName,"getBarsCount",0,0)*timeFrame/Period()));







for(i=0; i<limit; i++)

{

int y = iBarShift(NULL,timeFrame,Time[i]);

SK[i] = iCustom(NULL,timeFrame,IndicatorFileName,"",PeriodRSI,PeriodStoch,PeriodSK,PeriodSD,MAMode,0,y);

SD[i] = iCustom(NULL,timeFrame,IndicatorFileName,"",PeriodRSI,PeriodStoch,PeriodSK,PeriodSD,MAMode,1,y);

}

return(0);

}





for(i=limit; i>=0; i--)

{

RSI[i] = iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,i);

double LLV = RSI[ArrayMinimum(RSI,PeriodStoch,i)];

double HHV = RSI[ArrayMaximum(RSI,PeriodStoch,i)];

if ((HHV-LLV)!=0)

StoRSI[i] = 100.0*((RSI[i] - LLV)/(HHV - LLV));

else StoRSI[i] = 0;

}

for(i=limit; i>=0; i--) SK[i]=iMAOnArray(StoRSI,0,PeriodSK,0,MAMode,i);

for(i=limit; i>=0; i--)

{

SD[i]=iMAOnArray( SK,0,PeriodSD,0,MAMode,i);

cross[i] = cross[i+1];

if (SK[i]>SD[i]) cross[i] = 1;

if (SK[i]<SD[i]) cross[i] = -1;

}

if (alertsOn)

{

if (alertsOnCurrent)

int whichBar = 0;

else whichBar = 1;

if (cross[whichBar] != cross[whichBar+1])

if (cross[whichBar] == 1)

doAlert("BUY");
ObjectCreate("ObjName", OBJ_LABEL, 0, 0, 0);

ObjectSetText("ObjName","BUY",53, "Verdana", Green);

ObjectSet("ObjName", OBJPROP_CORNER, 0);

ObjectSet("ObjName", OBJPROP_XDISTANCE, 10);

ObjectSet("ObjName", OBJPROP_YDISTANCE, 33);



// Here I try to put a commend. So when DTOSC crossing and change for SELL/Buy

// I would like to show a text on terminal Sell/Buy.

// I need only this monit as a text. I'm not intersting especcialy about how Dtosc looks. Only when is sell then show me text sell;







doAlert("SELL");

} ObjectCreate("ObjName", OBJ_LABEL, 0, 0, 0);

ObjectSetText("ObjName","Sell",53, "Verdana", Red);

ObjectSet("ObjName", OBJPROP_CORNER, 0);

ObjectSet("ObjName", OBJPROP_XDISTANCE, 10);

ObjectSet("ObjName", OBJPROP_YDISTANCE, 33);





return(0);

}
//------------------------------------------------------------------

//

//------------------------------------------------------------------

void doAlert(string doWhat)

{

static string previousAlert="nothing";

static datetime previousTime;

string message;



if (previousAlert != doWhat || previousTime != Time[0]) {

previousAlert = doWhat;

previousTime = Time[0];







message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," Kierunek ",doWhat);

if (alertsMessage) Alert(message);

if (alertsEmail) SendMail(StringConcatenate(Symbol()," Dtosc "),message);

if (alertsSound) PlaySound(soundfile);

}

}



//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+





int stringToTimeFrame(string tfs)

{

for(int l = StringLen(tfs)-1; l >= 0; l--)

{

int tchar = StringGetChar(tfs,l);

if((tchar > 96 && tchar < 123) || (tchar > 223 && tchar < 256))

tfs = StringSetChar(tfs, l, tchar - 32);

else

if(tchar > -33 && tchar < 0)

tfs = StringSetChar(tfs, l, tchar + 224);

}


int tf=0;

if (tfs=="M1" || tfs=="1") tf=PERIOD_M1;

if (tfs=="M5" || tfs=="5") tf=PERIOD_M5;

if (tfs=="M15"|| tfs=="15") tf=PERIOD_M15;

if (tfs=="M30"|| tfs=="30") tf=PERIOD_M30;

if (tfs=="H1" || tfs=="60") tf=PERIOD_H1;

if (tfs=="H4" || tfs=="240") tf=PERIOD_H4;

if (tfs=="D1" || tfs=="1440") tf=PERIOD_D1;

if (tfs=="W1" || tfs=="10080") tf=PERIOD_W1;

if (tfs=="MN" || tfs=="43200") tf=PERIOD_MN1;

if (tf<Period()) tf=Period();

return(tf);
 
Dejwidziu:

if (cross[whichBar] != cross[whichBar+1])

if (cross[whichBar] == 1)

doAlert("BUY");
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. You have no braces "{}" around your cross code
  3. or around your buy alert code.
  4. or an else{ sell alert code}
  5. Nor do you delete your buy object when you sell alert and visa versa.
 

Hello friends
I have an oscillator that I want when the indicators qqe and ts1 I interrupted each other to receive an alert with a voice and a message, can anyone help me?
Thanks


//+------------------------------------------------------------------+
//|                               Copyright © 2016, Gehtsoft USA LLC |
//|                                            http://fxcodebase.com |
//|                         Donate / Support:  https://goo.gl/9Rj74e |
//+------------------------------------------------------------------+
//|                                      Developed by : Mario Jemic  |
//|                                          mario.jemic@gmail.com   |
//|                     BitCoin: 15VCJTLaz12Amr7adHSBtL9v8XomURo9RF  |
//+------------------------------------------------------------------+



#property indicator_buffers 3
#property indicator_separate_window
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Blue

extern int   RSI_Period = 14;
extern int   RSI_Smoothing_Period = 5;
extern int   ATR_Period = 14;
extern double Fast_ATR_Multipliers = 2.618;
extern double Slow_ATR_Multipliers = 4.236;


double TR[];
double QQE[];
double TS1[];
double TS2[];
double RSI[];
double ATR[];
double DELTA[];
double WildersPeriod;
int init()
  {

   IndicatorShortName("QualitativeQuantitativeEstimation");
   IndicatorBuffers(7);

   WildersPeriod=RSI_Period * 2 - 1;


   SetIndexBuffer(0,QQE);
   SetIndexLabel(0,"QQE");

   SetIndexBuffer(1,TS1);
   SetIndexLabel(1,"TS1");

   SetIndexBuffer(2,TS2);
   SetIndexLabel(2,"TS2");

   SetIndexBuffer(3,TR);
   SetIndexBuffer(4,RSI);
   SetIndexBuffer(5,ATR);
   SetIndexBuffer(6,DELTA);

   SetLevelValue(1,50);
   SetLevelValue(2,30);
   SetLevelValue(3,70);
   SetLevelStyle(STYLE_SOLID,1);


   return(0);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {

   int i;
   int counted_bars=IndicatorCounted();
   int limit = Bars-counted_bars-1;

   for(i=limit; i>=0; i--)
     {


      RSI[i]= iRSI(NULL,0,RSI_Period,PRICE_CLOSE,i);


     }


   for(i=limit; i>=0; i--)
     {

      QQE[i]= iMAOnArray(RSI,0,RSI_Smoothing_Period,0,MODE_EMA,i);

      TR[i] = MathAbs(QQE[i] - QQE[i+1]);

     }


   for(i=limit; i>=0; i--)
     {

      ATR[i]= iMAOnArray(TR,0,ATR_Period,0,MODE_EMA,i);


     }

   for(i=limit; i>=0; i--)
     {
      DELTA[i]= iMAOnArray(ATR,0,WildersPeriod,0,MODE_EMA,i);
     }

   double Stop1=QQE[limit];
   double Stop2=QQE[limit];

   for(i=limit; i>=0; i--)
     {





      if(QQE[i] < TS1[i+1])
        {
         Stop1=QQE[i] + DELTA[i]*Fast_ATR_Multipliers;

         if(Stop1 > TS1[i+1])
           {
            if(QQE[i+1] <  TS1[i+1])
              {
               Stop1 = TS1[i+1];
              }

           }
        }

      else
         if(QQE[i] > TS1[i+1])
           {
            Stop1=QQE[i] - DELTA[i]*Fast_ATR_Multipliers;

            if(Stop1 < TS1[i+1])
              {
               if(QQE[i+1] >  TS1[i+1])
                 {
                  Stop1 = TS1[i+1];
                 }

              }

           }

      TS1[i]=Stop1;



     }

   for(i=limit; i>=0; i--)
     {

      if(QQE[i] < TS2[i+1])
        {
         Stop2=QQE[i] + DELTA[i]*Slow_ATR_Multipliers;

         if(Stop2 > TS2[1+1])
           {
            if(QQE[i+1] <  TS2[i+1])
              {
               Stop2 = TS2[i+1];
              }
           }
        }
      else
         if(QQE[i] > TS2[i+1])
           {
            Stop2=QQE[i] - DELTA[i]*Slow_ATR_Multipliers;

            if(Stop2 < TS2[i+1])
              {
               if(QQE[i+1] >  TS2[i+1])
                 {
                  Stop2 = TS2[i+1];
                 }
              }

           }

      TS2[i]=Stop2;

     }

 
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code correctly in a new post.
Reason: