Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
DTS-Monta§a
//+------------------------------------------------------------------+
//| rutina: Sapucay-Montaña.mq4
//| Acción: Puntos de entrada y salida
//| referencia: Basado en el indicador de Kiko Segui
//| Adaptado: Ruben Dieminger
//+------------------------------------------------------------------+
#property copyright "Sapucay-Montaña"
#property link "http://analizandoforex.blogspot.com/"
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 White
#property indicator_color4 Green
#property indicator_color5 PowderBlue
#property indicator_color6 PowderBlue
double buffer1[];
double buffer2[];
double buffer3[];
double buffer4[];
double MA1buffer[];
double MA2buffer[];
extern color ColorLineaVenta=Red;
extern color ColorLineaCompra=Green;
extern int period=22;
extern int price=0; // 0 or other = (H+L)/2
// 1 = Open
// 2 = Close
// 3 = High
// 4 = Low
// 5 = (H+L+C)/3
// 6 = (O+C+H+L)/4
// 7 = (O+C)/2
extern string expl01="0 u otro = (H+L)/2 = Precio Promedio";
extern string expl02="1 = Precio de Apertura";
extern string expl03="2 = Precio de Cierre";
extern string expl04="3 = High";
extern string expl05="4 = Low";
extern string expl06="5 = (H+L+C)/3";
extern string expl07="6 = (O+C+H+L)/4";
extern string expl08="7 = (O+C)/2";
extern bool Mode_Fast= False;
extern bool Signals= false;
extern bool AlertWindow=false;
extern int MA1period=1, MA2period=1;
extern string Ayudas_TypeMA = "0-SMA, 1-EMA , 2-SMMA, 3-LWMA";
extern int TypeMA1=0;
extern int TypeMA2=3;
double val1,val2;
int init()
{
string short_name;
short_name="Sapucay-Montaña";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,1,DarkGreen);
SetIndexBuffer(0,buffer1);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,1,Orange);
SetIndexBuffer(1,buffer2);
SetIndexStyle(2,DRAW_LINE);
SetIndexLabel(2,"line");
SetIndexBuffer(2,buffer3);
SetIndexStyle(3,DRAW_LINE);
SetIndexLabel(3,"Señal");
SetIndexBuffer(3,buffer4);
SetIndexStyle(4,DRAW_LINE);
SetIndexLabel(4,"MA1 "+MA1period);
SetIndexBuffer(4,MA1buffer);
SetIndexStyle(5,DRAW_LINE);
SetIndexLabel(5,"MA2 "+MA2period);
SetIndexBuffer(5,MA2buffer);
return(0);
}
int deinit()
{
int i;
double tmp;
for (i=0;i<Bars;i++)
{
ObjectDelete("Compra: "+DoubleToStr(i,0));
ObjectDelete("Venta: "+DoubleToStr(i,0));
ObjectDelete("SELL SIGNAL: "+DoubleToStr(i,0));
ObjectDelete("BUY SIGNAL: "+DoubleToStr(i,0));
ObjectDelete("EXIT: "+DoubleToStr(i,0));
}
return(0);
}
double Value=0,Value1=0,Value2=0,Fish=0,Fish1=0,Fish2=0;
int buy=0,sell=0;
int start()
{
int counted_bars=IndicatorCounted();
int i;
int barras;
double _price;
double tmp;
double MinL=0;
double MaxH=0;
double Threshold=0;
if(counted_bars>0) counted_bars--;
//barras = Bars;ç
barras = Bars-counted_bars;
if (Mode_Fast)
barras = 100;
i = 0;
while(i<barras)
{
MaxH = High[Highest(NULL,0,MODE_HIGH,period,i)];
MinL = Low[Lowest(NULL,0,MODE_LOW,period,i)];
switch (price)
{
case 1: _price = Open[i]; break;
case 2: _price = Close[i]; break;
case 3: _price = High[i]; break;
case 4: _price = Low[i]; break;
case 5: _price = (High[i]+Low[i]+Close[i])/3; break;
case 6: _price = (Open[i]+High[i]+Low[i]+Close[i])/4; break;
case 7: _price = (Open[i]+Close[i])/2; break;
default: _price = (High[i]+Low[i])/2; break;
}
Value = 0.33*2*((_price-MinL)/(MaxH-MinL)-0.5) + 0.67*Value1;
Value=MathMin(MathMax(Value,-0.999),0.999);
Fish = 0.5*MathLog((1+Value)/(1-Value))+0.5*Fish1;
buffer1[i]= 0;
buffer2[i]= 0;
if ( (Fish<0) && (Fish1>0))
{
if (Signals)
{
VerticalLine("Compra: "+DoubleToStr(i,0),i,STYLE_SOLID,ColorLineaCompra);
ObjectCreate("EXIT: "+DoubleToStr(i,0),OBJ_TEXT,0,Time[i],_price);
ObjectSetText("EXIT: "+DoubleToStr(i,0),"Compra "+DoubleToStr(_price,4),7,"Arial",White);
}
if (AlertWindow)
{
Alert("Compra " + Symbol());
}
buy = 0;
}
if ((Fish>0) && (Fish1<0))
{
if (Signals)
{
VerticalLine("Venta: "+DoubleToStr(i,0),i,STYLE_SOLID,ColorLineaVenta);
ObjectCreate("EXIT: "+DoubleToStr(i,0),OBJ_TEXT,0,Time[i],_price);
ObjectSetText("EXIT: "+DoubleToStr(i,0),"Venta "+DoubleToStr(_price,4),7,"Arial",White);
}
if (AlertWindow)
{
Alert("Venta " + Symbol());
}
sell = 0;
}
if (Fish > 0)
{
buffer1[i] = Fish;
buffer3[i]= Fish;
}
if (Fish < 0)
{
buffer2[i] = Fish;
buffer3[i]= Fish;
}
if (Fish == 0)
{
buffer2[i] = 0;
buffer3[i]= 0;
}
tmp = i;
if ((Fish<-Threshold) &&
(Fish>Fish1) &&
(Fish1<=Fish2))
{
if (Signals)
{
//ObjectCreate("SELL SIGNAL: "+DoubleToStr(i,0),OBJ_TEXT,0,Time[i],_price);
//ObjectSetText("SELL SIGNAL: "+DoubleToStr(i,0),"SELL AT "+DoubleToStr(_price,4),7,"Arial",Red);
}
sell = 1;
}
if ((Fish>Threshold) &&
(Fish<Fish1) &&
(Fish1>=Fish2))
{
if (Signals)
{
//ObjectCreate("BUY SIGNAL: "+DoubleToStr(i,0),OBJ_TEXT,0,Time[i],_price);
//ObjectSetText("BUY SIGNAL: "+DoubleToStr(i,0),"BUY AT "+DoubleToStr(_price,4),7,"Arial",Lime);
}
buy=1;
}
buffer4[i]= Fish1;
Value1 = Value;
Fish2 = Fish1;
Fish1 = Fish;
i++;
}
for(i=0; i<barras; i++)
MA1buffer[i]=iMAOnArray(buffer3,Bars,MA1period,0,TypeMA1,i);
for(i=0; i<barras; i++)
MA2buffer[i]=iMAOnArray(MA1buffer,Bars,MA2period,0,TypeMA2,i);
//Alert(MA1buffer[i]);
return(0);
}
//+------------------------------------------------------------------+
// Linea Vertical
//----------------------------------------------------------------------------------------------
int VerticalLine(string s,int i,int st,int Col) //s=Text Label, i = bar, st=Line Style, Col = color
{
// uso: VerticalLine("Venta",i,STYLE_SOLID,LineaVenta);
ObjectDelete(s);
val1=Low[Lowest(NULL,0,MODE_LOW,BarsPerWindow(),0)];
val2=High[Highest(NULL,0,MODE_HIGH,BarsPerWindow(),0)];
ObjectCreate(s,OBJ_TREND,0,Time[i],0,Time[i],900);
// Activar Valores
ObjectSet(s,OBJPROP_COLOR,Col);
ObjectSet(s,OBJPROP_WIDTH,1);
ObjectSet(s,OBJPROP_STYLE,st);
ObjectSet(s,OBJPROP_RAY,0);
//ObjectCreate(s,OBJ_TEXT,0,Time[i],val2-Point*16);
ObjectSetText(s,"",7,"Arial",Col);
// ObjectsRedraw();
return(0);
}
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---