Para iniciar sesión y usar el sitio web MQL5.com es necesario permitir el uso de Сookies.
Por favor, active este ajuste en su navegador, de lo contrario, no podrá iniciar sesión.
Ha iniciado sesión. La autenticación de dos factores se ha desactivado. Vuelva a configurarla y escanee un nuevo código QR, o continúe con la autenticación de dos factores desactivada.
Por favor, alguien podría ayudarme a juntar en un sólo código , estos dos códigos de estos dos indicadores?
INDICADOR 1
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 2
#property indicator_color1 clrBlue
#property indicator_color2 clrPurple
//---- input parameters
extern int RSIOMA = 14;
extern int RSIOMA_MODE = MODE_EMA;
extern int RSIOMA_PRICE = PRICE_CLOSE;
extern int Ma_RSIOMA = 21,
Ma_RSIOMA_MODE = MODE_EMA;
//---- buffers
double RSIBuffer[];
double PosBuffer[];
double NegBuffer[];
double marsioma[];
string short_name;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
short_name = StringConcatenate("RSIOMA(",RSIOMA,")");
IndicatorBuffers(4);
SetIndexBuffer(0,RSIBuffer);
SetIndexBuffer(1,marsioma);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID);
SetIndexBuffer(2,PosBuffer);
SetIndexBuffer(3,NegBuffer);
IndicatorShortName("");
SetIndexLabel(0,NULL);
SetIndexLabel(1,NULL);
SetIndexLabel(2,NULL);
SetIndexLabel(3,NULL);
SetIndexDrawBegin(0,RSIOMA);
SetIndexDrawBegin(1,RSIOMA);
SetIndexDrawBegin(2,RSIOMA);
SetIndexDrawBegin(3,RSIOMA);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Relative Strength Index |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
double rel,negative,positive;
//----
if(Bars<=RSIOMA) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=RSIOMA;i++) RSIBuffer[Bars-i]=0.0;
//----
i=Bars-RSIOMA-1;
int ma = i;
if(counted_bars>=RSIOMA) i=Bars-counted_bars-1;
while(i>=0)
{
double sumn=0.0,sump=0.0;
if(i==Bars-RSIOMA-1)
{
int k=Bars-2;
//---- initial accumulation
while(k>=i)
{
double cma = iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE,k);
double pma = iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE,k+1);
rel=cma-pma;
if(rel>0) sump+=rel;
else sumn-=rel;
k--;
}
positive=sump/RSIOMA;
negative=sumn/RSIOMA;
}
else
{
//---- smoothed moving average
double ccma = iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE,i);
double ppma = iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE,i+1);
rel=ccma-ppma;
if(rel>0) sump=rel;
else sumn=-rel;
positive=(PosBuffer[i+1]*(RSIOMA-1)+sump)/RSIOMA;
negative=(NegBuffer[i+1]*(RSIOMA-1)+sumn)/RSIOMA;
}
PosBuffer[i]=positive;
NegBuffer[i]=negative;
if(negative==0.0) RSIBuffer[i]=0.0;
else
{
RSIBuffer[i]=100.0-100.0/(1+positive/negative);
}
i--;
}
while(ma>=0)
{
marsioma[ma] = iMAOnArray(RSIBuffer,0,Ma_RSIOMA,0,Ma_RSIOMA_MODE,ma);
ma--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
INDICADOR 2:
#property indicator_separate_window
#property indicator_minimum 0.00
#property indicator_maximum 100.00
#property indicator_buffers 4
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 clrBlue
#property indicator_color4 clrPurple
#property indicator_level1 20
#property indicator_level2 80
//+------------------------------------------------------------------+
//| Common External variables |
//+------------------------------------------------------------------+
extern int RSIOMA = 14;
extern int RSIOMA_MODE = MODE_EMA;
extern int RSIOMA_PRICE = PRICE_CLOSE;
extern int Ma_RSIOMA = 21,
Ma_RSIOMA_MODE = MODE_EMA;
//+------------------------------------------------------------------+
//| External variables |
//+------------------------------------------------------------------+
extern double Slw = 8;
extern double Pds = 13;
extern double Slwsignal = 9;
extern int Barcount = 2000;
//+------------------------------------------------------------------+
//| Special Convertion Functions |
//+------------------------------------------------------------------+
int LastTradeTime;
double ExtHistoBuffer[];
double ExtHistoBuffer2[];
bool BuyAlert=false, SellAlert=false;
double RSIBuffer[];
double PosBuffer[];
double NegBuffer[];
double marsioma[];
string short_name;
void SetLoopCount(int loops)
{
}
void SetIndexValue(int shift, double value)
{
ExtHistoBuffer[shift] = value;
// Print ("ExtHistoBuffer :" ,value); // green
}
void SetIndexValue2(int shift, double value)
{
ExtHistoBuffer2[shift] = value;
// Print ("ExtHistoBuffer2 :" ,value); // green
}
double GetIndexValue(int shift)
{
return(ExtHistoBuffer[shift]);
}
double GetIndexValue2(int shift)
{
return(ExtHistoBuffer2[shift]);
}
//+------------------------------------------------------------------+
//| End |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Initialization |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID);
SetIndexBuffer(0, ExtHistoBuffer);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID);
SetIndexBuffer(1, ExtHistoBuffer2);
short_name = StringConcatenate("RSIOMA(",RSIOMA,")");
IndicatorBuffers(4);
SetIndexBuffer(0,RSIBuffer);
SetIndexBuffer(1,marsioma);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID);
SetIndexBuffer(2,PosBuffer);
SetIndexBuffer(3,NegBuffer);
IndicatorShortName("");
SetIndexLabel(0,NULL);
SetIndexLabel(1,NULL);
SetIndexLabel(2,NULL);
SetIndexLabel(3,NULL);
SetIndexDrawBegin(0,RSIOMA);
SetIndexDrawBegin(1,RSIOMA);
SetIndexDrawBegin(2,RSIOMA);
SetIndexDrawBegin(3,RSIOMA);
return(0);
}
int start()
{
//+------------------------------------------------------------------+
//| Local variables |
//+------------------------------------------------------------------+
double AA = 0;
double bb = 0;
double aa1 = 0;
double cnt1 = 0;
int shift = 0;
double cnt = 0;
double loopbegin = 0;
double loopbegin2 = 0;
double loopbegin3 = 0;
bool first = True;
double prevbars = 0;
double sum = 0;
double smconst = 0;
double smconst1 = 0;
double prev = 0;
double prev1 = 0;
double prev2 = 0;
double prev3 = 0;
double weight = 0;
double linear = 0;
double MAValue = 0;
double MAValue2 = 0;
double mavalue3 = 0;
string MAstring = "";
double MyHigh = 0;
double MyLow = 0;
int counter = 0;
double Price = 0;
double Price1 = 0;
double tmpDevAA = 0;
SetLoopCount(0);
smconst = 2 / (1+Slw);
smconst1 = 2 / (1+Slwsignal);
loopbegin = loopbegin+1;
for(shift =Barcount;shift >=0 ;shift --)
{
prev = GetIndexValue2(shift+1);
// Yousky 15/05/2006 - Change to avoid Zero divide exception.
AA = 0;
tmpDevAA = (High[Highest(NULL, 0, MODE_HIGH,shift+Pds,Pds)] - Low[Lowest(NULL, 0, MODE_LOW,shift+Pds,Pds)]);
if (tmpDevAA != 0)
AA = 100* ((Close[shift] - Low[Lowest(NULL, 0, MODE_LOW,shift+Pds,Pds)]) / tmpDevAA);
// ---
MAValue2 = smconst * (AA-prev) + prev;
SetIndexValue2(shift,MAValue2);
loopbegin = loopbegin-1;
}
loopbegin2 = loopbegin2+1;
for(shift =Barcount-Pds;shift >=0 ;shift --){
MyHigh = -999999;
MyLow = 99999999;
for(counter =shift;counter <=Pds + shift ;counter ++){
Price= GetIndexValue2(counter);
if( Price > MyHigh )
MyHigh = Price;
if( Pds <= 0 )
MyHigh = Price;
if( Price < MyLow )
MyLow = Price;
if( Pds <= 0 )
MyLow = Price;
}
prev1 = GetIndexValue(shift+1);
aa1=GetIndexValue2(shift);
// Yousky 15/05/2006 - Change to avoid Zero divide exception.
bb= 0;
if ((MyHigh-MyLow) != 0)
bb=100*(aa1-MyLow)/(MyHigh-MyLow);
// ---
MAValue = smconst * (bb-prev1) + prev1;
SetIndexValue(shift,MAValue);
loopbegin2 = loopbegin2-1;
}
//Print (MAValue); // green
loopbegin3 = loopbegin3+1;
for(shift =Barcount;shift >=0 ;shift --){
prev2=GetIndexValue2(shift+1);
prev3=GetIndexValue(shift);
mavalue3= smconst1 * (prev3-prev2) +prev2;
SetIndexValue2(shift,mavalue3);
loopbegin3 = loopbegin3-1;
int i,counted_bars=IndicatorCounted();
double rel,negative,positive;
//----
if(Bars<=RSIOMA) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=RSIOMA;i++) RSIBuffer[Bars-i]=0.0;
//----
i=Bars-RSIOMA-1;
int ma = i;
if(counted_bars>=RSIOMA) i=Bars-counted_bars-1;
while(i>=0)
{
double sumn=0.0,sump=0.0;
if(i==Bars-RSIOMA-1)
{
int k=Bars-2;
//---- initial accumulation
while(k>=i)
{
double cma = iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE,k);
double pma = iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE,k+1);
rel=cma-pma;
if(rel>0) sump+=rel;
else sumn-=rel;
k--;
}
positive=sump/RSIOMA;
negative=sumn/RSIOMA;
}
else
{
//---- smoothed moving average
double ccma = iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE,i);
double ppma = iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE,i+1);
rel=ccma-ppma;
if(rel>0) sump=rel;
else sumn=-rel;
positive=(PosBuffer[i+1]*(RSIOMA-1)+sump)/RSIOMA;
negative=(NegBuffer[i+1]*(RSIOMA-1)+sumn)/RSIOMA;
}
PosBuffer[i]=positive;
NegBuffer[i]=negative;
if(negative==0.0) RSIBuffer[i]=0.0;
else
{
RSIBuffer[i]=100.0-100.0/(1+positive/negative);
}
i--;
}
while(ma>=0)
{
marsioma[ma] = iMAOnArray(RSIBuffer,0,Ma_RSIOMA,0,Ma_RSIOMA_MODE,ma);
ma--;
}
return(0);
}
if(ExtHistoBuffer[0] > ExtHistoBuffer2[0] && ExtHistoBuffer[0]<20.1 && ExtHistoBuffer2[0] < 20.1 && BuyAlert==False)
{
Alert ("Doda-Stochastic says Buy ",Symbol()," at ",Close[0]);
BuyAlert = True;
SellAlert = False;
}
if(ExtHistoBuffer2[0] > ExtHistoBuffer[0] && ExtHistoBuffer[0]>80.1 && ExtHistoBuffer2[0] > 80.1 && SellAlert==False)
{
// sell signal
Alert ("Doda-Stochastic says Sell ",Symbol()," at ",Close[0]);
BuyAlert = false;
SellAlert = True;
}
}