Indicators with alerts/signal - page 1363

 
//+------------------------------------------------------------------+
//|                       Indicator: Signal_Stochastics_Strategy.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright " "
#property link      " "
#property version   "1.00"
#property description "Trade extreme levels of overbought and oversold"

#include <stdlib.mqh>
#include <stderror.mqh>

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 2

#property indicator_type1 DRAW_ARROW
#property indicator_width1 2
#property indicator_color1 0xFFAA00
#property indicator_label1 "CALL opportunity"

#property indicator_type2 DRAW_ARROW
#property indicator_width2 2
#property indicator_color2 0x006AFF
#property indicator_label2 "PUT opportunity"

//--- indicator buffers
double Buffer1[];
double Buffer2[];

double myPoint; //initialized in OnInit

void myAlert(string type, string message)
  {
   if(type == "print")
      Print(message);
   else if(type == "error")
     {
      Print(type+" | Signal_Stochastics_Strategy @ "+Symbol()+","+Period()+" | "+message);
     }
   else if(type == "order")
     {
     }
   else if(type == "modify")
     {
     }
  }

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {   
   IndicatorBuffers(2);
   SetIndexBuffer(0, Buffer1);
   SetIndexEmptyValue(0, 0);
   SetIndexArrow(0, 241);
   SetIndexBuffer(1, Buffer2);
   SetIndexEmptyValue(1, 0);
   SetIndexArrow(1, 242);
   //initialize myPoint
   myPoint = Point();
   if(Digits() == 5 || Digits() == 3)
     {
      myPoint *= 10;
     }
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| 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 = rates_total - prev_calculated;
   //--- counting from 0 to rates_total
   ArraySetAsSeries(Buffer1, true);
   ArraySetAsSeries(Buffer2, true);
   //--- initial zero
   if(prev_calculated < 1)
     {
      ArrayInitialize(Buffer1, 0);
      ArrayInitialize(Buffer2, 0);
     }
   else
      limit++;
   
   //--- main loop
   for(int i = limit-1; i >= 0; i--)
     {
      if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation   
      //Indicator Buffer 1
      if(iStochastic(NULL, PERIOD_CURRENT, 21, 9, 9, MODE_SMA, 0, MODE_MAIN, i) > iStochastic(NULL, PERIOD_CURRENT, 21, 9, 9, MODE_SMA, 0, MODE_SIGNAL, i)
      && iStochastic(NULL, PERIOD_CURRENT, 21, 9, 9, MODE_SMA, 0, MODE_MAIN, i+1) < iStochastic(NULL, PERIOD_CURRENT, 21, 9, 9, MODE_SMA, 0, MODE_SIGNAL, i+1) //Stochastic Oscillator crosses above Stochastic Oscillator
      && iStochastic(NULL, PERIOD_CURRENT, 14, 3, 3, MODE_SMA, 0, MODE_MAIN, i) < 20 //Stochastic Oscillator < fixed value
      && iStochastic(NULL, PERIOD_CURRENT, 14, 3, 3, MODE_SMA, 0, MODE_SIGNAL, i) < 20 //Stochastic Oscillator < fixed value
      && iStochastic(NULL, PERIOD_CURRENT, 21, 9, 9, MODE_SMA, 0, MODE_MAIN, i) < 20 //Stochastic Oscillator < fixed value
      && iStochastic(NULL, PERIOD_CURRENT, 21, 9, 9, MODE_SMA, 0, MODE_SIGNAL, i) < 20 //Stochastic Oscillator < fixed value
      )
        {
         Buffer1[i] = Low[i]; //Set indicator value at Candlestick Low
        }
      //Indicator Buffer 2
      if(iStochastic(NULL, PERIOD_CURRENT, 21, 9, 9, MODE_SMA, 0, MODE_MAIN, i) < iStochastic(NULL, PERIOD_CURRENT, 21, 9, 9, MODE_SMA, 0, MODE_SIGNAL, i)
      && iStochastic(NULL, PERIOD_CURRENT, 21, 9, 9, MODE_SMA, 0, MODE_MAIN, i+1) > iStochastic(NULL, PERIOD_CURRENT, 21, 9, 9, MODE_SMA, 0, MODE_SIGNAL, i+1) //Stochastic Oscillator crosses below Stochastic Oscillator
      && iStochastic(NULL, PERIOD_CURRENT, 14, 3, 3, MODE_SMA, 0, MODE_MAIN, i) > 80 //Stochastic Oscillator > fixed value
      && iStochastic(NULL, PERIOD_CURRENT, 14, 3, 3, MODE_SMA, 0, MODE_SIGNAL, i) > 80 //Stochastic Oscillator > fixed value
      && iStochastic(NULL, PERIOD_CURRENT, 21, 9, 9, MODE_SMA, 0, MODE_MAIN, i) > 80 //Stochastic Oscillator > fixed value
      && iStochastic(NULL, PERIOD_CURRENT, 21, 9, 9, MODE_SMA, 0, MODE_SIGNAL, i) > 80 //Stochastic Oscillator > fixed value
      )
        {
         Buffer2[i] = High[i]; //Set indicator value at Candlestick High
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
Julio
:

Dear mladen can you please take a look at my post?. Thank you in advance for your help.

https://www.mql5.com/en/forum/180648/page906 


 
Julio:

Julio


When a new arrow appears?

 
Julio:

???

Any clarification?

 
Julio:

Add :


if (Buffer1[0]!=EMPTY_VALUE) ... alert for buy

if (Buffer2[0]!=EMPTY_VALUE) ... alert for sell

 
Julio:

Why are you using SetAsSeries on buffers that are already used as buffers (series)?

That is not MT5

 
kewu:
hi Mladen , please am waiting anxiously for ur response on the filter image that i requested above .

kewu


As I told : from a picture I can not tell anything

 
arbtrader:
As seen from chart H4, the pair is traded at 1.27082. ADX is 28.51 along with the green SAR arrow, showing a relatively strong uptrend. The stock is expected to go down slightly then go up again. I'm going long with SL at 1.26505 and TP at 1.27806
Which pair?
 
kapoo:

k sir.

Mr Mladen, Please look at the below codes , the arrow doesnt show up in live until i switched time frame.

It repaints. How do you use it?
 

Hello everybody.

Got an idea about a new kind of OSMA indicator and would like to know if it can be done.

 

OSMA, MTF, Message Alert ONLY if Hidden divergence happens (real short terms too)

Colored not necessary. 

Possibility to see divergence lines on price chart or not, but always in indicator window. Calculations from close to close, not from Hi to Hi and Lo to Lo. 

 

IGNORING classic divergences. (no alerts)

 

Reason is to follow the momentum of the market and add trades in trend direction, or get in after a pullback.

 

Time to stop chasing tops and bottoms only to get in to early and get stopped out, thats why ignoring classic divergence at all.

Osma hidden div because not to have a oscillator-based indicator. Osma is the relation to macd-signal-line distance to histogram bars. 

Please let me know if a osma can be coded like that, that would be nice.

Thank you. 

 
Hello Mladen and Mr.Tools,

I kindly ask you, if you can add an alarm to this indicator when the yellow line breaks red stripes. I also attached a photo for greater understanding.

Thanks in advance!

Barons1


Files:
BBflat_sw.mq4  3 kb
Reason: