#property copyright "Copyright © 2021 KIKOS."
#property version "2.00"
#property description ""
#include <stdlib.mqh>
#include <stderror.mqh>
//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_type1 DRAW_ARROW
#property indicator_width1 3
#property indicator_color1 Green
#property indicator_type2 DRAW_ARROW
#property indicator_width2 2
#property indicator_color2 Snow
#property indicator_type3 DRAW_ARROW
#property indicator_width3 3
#property indicator_color3 Red
#property indicator_type4 DRAW_ARROW
#property indicator_width4 2
#property indicator_color4 Snow
string Text_to_Write = "Kikos 99/1!";
color Text_Color = Yellow;
int Font_Size = 20;
string Font_Name = "Arial Black";
int WindowCorner = 1;
int YPos = 5;
int XPos = 5;
string UniqueID = "text1";
int liveAccountNumber = 1;
extern bool UseAlert = true;
//--- indicator buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
double myPoint; //initialized in OnInit
void myAlert(string type, string message)
{
if(type == "print")
Print(message);
else if(type == "error")
{
Print(type+" | Portafolio @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
}
else if(type == "order")
{
}
else if(type == "modify")
{
}
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
if(TimeCurrent()>D'08.02.2030'){
Alert("contacte a portafolio");
Comment("vencio");
Print("vencio");
ExpertRemove();
return(INIT_SUCCEEDED);
}
IndicatorBuffers(4);
SetIndexBuffer(0, Buffer1);
SetIndexEmptyValue(0, EMPTY_VALUE);
SetIndexArrow(0, 221);
SetIndexBuffer(1, Buffer2);
SetIndexEmptyValue(1, EMPTY_VALUE);
SetIndexArrow(1, 108);
SetIndexBuffer(2, Buffer3);
SetIndexEmptyValue(2, EMPTY_VALUE);
SetIndexArrow(2, 222);
SetIndexBuffer(3, Buffer4);
SetIndexEmptyValue(3, EMPTY_VALUE);
SetIndexArrow(3, 108);
//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);
ArraySetAsSeries(Buffer3, true);
ArraySetAsSeries(Buffer4, true);
//--- initial zero
if(prev_calculated < 1)
{
ArrayInitialize(Buffer1, EMPTY_VALUE);
ArrayInitialize(Buffer2, EMPTY_VALUE);
ArrayInitialize(Buffer3, EMPTY_VALUE);
ArrayInitialize(Buffer4, EMPTY_VALUE);
}
else
limit++;
static datetime timeLastAlert = NULL;
{
ObjectCreate(UniqueID, OBJ_LABEL, 0, 0, 0);
ObjectSet(UniqueID, OBJPROP_CORNER, WindowCorner);
ObjectSet(UniqueID, OBJPROP_XDISTANCE, XPos);
ObjectSet(UniqueID, OBJPROP_YDISTANCE, YPos);
ObjectSet(UniqueID, OBJPROP_BACK, FALSE);
ObjectSetText(UniqueID, Text_to_Write, Font_Size, Font_Name, Text_Color);
}
//--- 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(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 3+i) > 1 //Relative Strength Index > fixed value
&& iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 2+i) > 1 //Relative Strength Index > fixed value
&& iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) < 1 //Relative Strength Index < fixed value
)
{
Buffer1 = Low; //Set indicator value at Candlestick Low
}
else
{
Buffer1 = EMPTY_VALUE;
}
//Indicator Buffer 2
if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 2+i) > 1 //Relative Strength Index > fixed value
&& iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) > 1 //Relative Strength Index > fixed value
&& iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, i) < 1 //Relative Strength Index < fixed value
)
{
Buffer2 = Low; //Set indicator value at Candlestick Low
if( UseAlert && i == 0 && Time[0] != timeLastAlert )
{
Alert(Symbol()," M",Period()," Se ligue ABESTADO");
timeLastAlert = Time[0];
}
}
else
{
Buffer2 = EMPTY_VALUE;
}
//Indicator Buffer 3
if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 3+i) < 99 //Relative Strength Index < fixed value
&& iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 2+i) < 99 //Relative Strength Index < fixed value
&& iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) > 99 //Relative Strength Index > fixed value
)
{
Buffer3 = High; //Set indicator value at Candlestick Low
}
else
{
Buffer3 = EMPTY_VALUE;
}
//Indicator Buffer 4
if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 2+i) < 99 //Relative Strength Index < fixed value
&& iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) < 99 //Relative Strength Index < fixed value
&& iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, i) > 99 //Relative Strength Index > fixed value
)
{
Buffer4 = High; //Set indicator value at Candlestick Low
if( UseAlert && i == 0 && Time[0] != timeLastAlert )
{
Alert(Symbol()," M",Period(),"Se ligue ABESTADO");
timeLastAlert = Time[0];
}
}
else
{
Buffer4 = EMPTY_VALUE;
}
}
return(rates_total);
}
//+------------------------------------------------------------------+