//+------------------------------------------------------------------+
//| Camarilla Exchange 1.mq4 |
//| Copyright © 2010, Êóùåíêî Íèêèòà |
//| www.tradestrateg.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Êóùåíêî Íèêèòà"
#property link "www.tradestrateg.ru"
//----
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Aqua
#property indicator_color2 LawnGreen
#property indicator_color3 Red
#property indicator_color4 BlueViolet
#property indicator_color5 BlueViolet
//---- input parameters
//---- buffers
double PBuffer[];
double OP_SELL3Buffer[];
double OP_SELL2Buffer[];
double OP_BUY2Buffer[];
double OP_BUY3Buffer[];
string Pivot="Pivot",sOP_BUY2="OP_BUY2",sOP_SELL2="OP_SELL2";
string sOP_BUY3="OP_BUY3",sOP_SELL3="OP_SELL3";
int fontsize=10;
double P,OP_BUY2,OP_BUY3,OP_SELL2,OP_SELL3;
double LastHigh,LastLow,x;
double D1=0.091667;
double D2=0.183333;
double D3=0.2750;
double D4=0.55;
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
ObjectDelete("Pivot");
ObjectDelete("OP_BUY2");
ObjectDelete("OP_SELL2");
ObjectDelete("OP_BUY3");
ObjectDelete("OP_SELL3");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0,DRAW_LINE,0,2);
SetIndexStyle(1,DRAW_LINE,0,4);
SetIndexStyle(2,DRAW_LINE,0,4);
SetIndexStyle(3,DRAW_LINE,0,4);
SetIndexStyle(4,DRAW_LINE,0,4);
SetIndexBuffer(0,PBuffer);
SetIndexBuffer(1,OP_BUY2Buffer);
SetIndexBuffer(2,OP_SELL2Buffer);
SetIndexBuffer(3,OP_BUY3Buffer);
SetIndexBuffer(4,OP_SELL3Buffer);
//---- name for DataWindow and indicator subwindow label
short_name="Camarilla Exchange";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
SetIndexDrawBegin(0,1);
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit,i;
//---- indicator calculation
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
if(counted_bars==0) limit-=1+1;
if(counted_bars==0)
{
x=Period();
if(x>240) return(-1);
ObjectCreate("OP_BUY2",OBJ_TEXT,0,0,0);
ObjectSetText("OP_BUY2"," OP_BUY-2",fontsize,"Arial",White);
ObjectCreate("OP_SELL2",OBJ_TEXT,0,0,0);
ObjectSetText("OP_SELL2"," OP_SELL-2",fontsize,"Arial",White);
ObjectCreate("OP_BUY3",OBJ_TEXT,0,0,0);
ObjectSetText("OP_BUY3"," OP_BUY-3",fontsize,"Arial",White);
ObjectCreate("OP_SELL3",OBJ_TEXT,0,0,0);
ObjectSetText("OP_SELL3"," OP_SELL-3",fontsize,"Arial",White);
}
//----
for(i=limit; i>=0;i--)
{
if(High[i+1]>LastHigh) LastHigh=High[i+1];
if(Low[i+1]<LastLow) LastLow=Low[i+1];
if(TimeDay(Time[i])!=TimeDay(Time[i+1]))
{
P=(LastHigh+LastLow+Close[i+1])/3;
OP_SELL2=(LastHigh-LastLow)*D2+Close[i+1];
OP_BUY2=Close[i+1]-(LastHigh-LastLow)*D2;
OP_SELL3=(LastHigh-LastLow)*D4+Close[i+1];
OP_BUY3=Close[i+1]-(LastHigh-LastLow)*D4;
//----
LastLow=Open[i];
LastHigh=Open[i];
//----
ObjectMove("Pivot",0,Time[i],P);
ObjectMove("OP_BUY2",0,Time[i],OP_BUY2);
ObjectMove("OP_SELL2",0,Time[i],OP_SELL2);
ObjectMove("OP_BUY3",0,Time[i],OP_BUY3);
ObjectMove("OP_SELL3",0,Time[i],OP_SELL3);
}
PBuffer[i]=P;
OP_BUY2Buffer[i]=OP_BUY2;
OP_BUY3Buffer[i]=OP_BUY3;
OP_SELL2Buffer[i]=OP_SELL2;
OP_SELL3Buffer[i]=OP_SELL3;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments