
скорее всего счет центовый
extern int Shift = 3; // число дней
А можно сделать так, что бы тейки выставлялись на уровне как на скрине. т.е если взять фибо то это уровни 0,25 и 0,75
и что бы открывались 2 сделки, если первая сделка не была закрыта
Андрей почему чётко не считает
//+------------------------------------------------------------------+
//| ATR2.mq4 |
//| Copyright 2018, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
input int count=5;
input int kvart=4;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Kvart(int month)
{
int kv=0;
if(month<4) kv=1; // 1 2 3
if(month>3 && month<7) kv=2; // 4 5 6
if(month>6 && month<10) kv=3; // 7 8 9
if(month>9) kv=4; // 10 11 12
return(kv);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Sum(int num)
{
int sum=0;
for(int i=1;i<=3;i++)
{
double lo=iLow(NULL,PERIOD_MN1,i*num+Shift(Month()));//1*1+3
double hi=iHigh(NULL,PERIOD_MN1,i*num+Shift(Month()));
sum+=(int)((hi-lo)/_Point);
}
return(sum)/3;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int MonthPoint(int num)
{
int point=0;
double lo=iLow(NULL,PERIOD_MN1,num);
double hi=iHigh(NULL,PERIOD_MN1,num);
point=(int)((hi-lo)/_Point);
return(point);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Shift(int month) // 1-rv = 1 2 3
{
int shift=0;
if(Kvart(Month())==1 && Month()==1) shift=1;
if(Kvart(Month())==1 && Month()==2) shift=2;
if(Kvart(Month())==1 && Month()==3) shift=3;
if(Kvart(Month())==2 && Month()==4) shift=1;
if(Kvart(Month())==2 && Month()==5) shift=2;
if(Kvart(Month())==2 && Month()==6) shift=3;
if(Kvart(Month())==3 && Month()==7) shift=1;
if(Kvart(Month())==3 && Month()==8) shift=2;
if(Kvart(Month())==3 && Month()==8) shift=3;
if(Kvart(Month())==4 && Month()==10) shift=1;
if(Kvart(Month())==4 && Month()==11) shift=2;
if(Kvart(Month())==4 && Month()==12) shift=3;
return(shift);
}
//+------------------------------------------------------------------+
//| Put Text Function |
//+------------------------------------------------------------------+
void Text(string name,const string text,double price,datetime time,const color clr)
{
ObjectDelete(0,name);
//--- create a "Text" object
ObjectCreate(0,name,OBJ_TEXT,0,time,price);
//--- set the text
ObjectSetString(0,name,OBJPROP_TEXT,text);
//--- set the font of the text
ObjectSetString(0,name,OBJPROP_FONT,"Arial");
//--- set the font size
ObjectSetInteger(0,name,OBJPROP_FONTSIZE,11);
//--- set the method binding
ObjectSetInteger(0,name,OBJPROP_ANCHOR,ANCHOR_UPPER);
//--- set the color
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
}
//+------------------------------------------------------------------+
//| Вертикальная линия |
//+------------------------------------------------------------------+
void PutVLine(string name,datetime t,color clr)
{
ObjectDelete(0,name);
ObjectCreate(0,name,OBJ_VLINE,0,t,Bid);
//--- установим цвет линии
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- установим толщину линии
ObjectSetInteger(0,name,OBJPROP_WIDTH,1);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
/*
1. Определим текущий квартал Kvart(int month)
2. Определим сумму за текущий квартал
3.
*/
string s="";
double lo=Low[iLowest(NULL,0,MODE_LOW,11,0)];
for(int i=1;i<=count;i++)
{
s+="\n"+(string)i+" Kvart: "+(string)Sum(i);
datetime tm1=iTime(NULL,PERIOD_MN1,Shift(Month())-3+i*3);
Text(string(i),(string)Sum(i),lo,tm1,Red);
}
for(int i=0;i<count;i++)
{
datetime tm2=iTime(NULL,PERIOD_MN1,Shift(Month())+i*3-1);
PutVLine((string)i+"v",tm2,Red);
}
Comment("\n Kvartal: ",Kvart(Month()),
"\n Shift: ",(string)Shift(Month())+s);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| ATR2.mq4 |
//| Copyright 2018, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
input int count=5;
input int kvart=4;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Kvart(int month)
{
int kv=0;
if(month<4) kv=1; // 1 2 3
if(month>3 && month<7) kv=2; // 4 5 6
if(month>6 && month<10) kv=3; // 7 8 9
if(month>9) kv=4; // 10 11 12
return(kv);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Sum(int num)
{
int sum=0;
for(int i=1;i<=3;i++)
{
double lo=iLow(NULL,PERIOD_MN1,i*num+Shift(Month()));//1*1+3
double hi=iHigh(NULL,PERIOD_MN1,i*num+Shift(Month()));
sum+=((hi-lo)/_Point);
}
return(sum)/3;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int MonthPoint(int num)
{
int point=0;
double lo=iLow(NULL,PERIOD_MN1,num);
double hi=iHigh(NULL,PERIOD_MN1,num);
point=(hi-lo)/_Point;
return(point);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Shift(int month) // 1-rv = 1 2 3
{
int shift=0;
if(Kvart(Month())==1 && Month()==1) shift=1;
if(Kvart(Month())==1 && Month()==2) shift=2;
if(Kvart(Month())==1 && Month()==3) shift=3;
if(Kvart(Month())==2 && Month()==4) shift=1;
if(Kvart(Month())==2 && Month()==5) shift=2;
if(Kvart(Month())==2 && Month()==6) shift=3;
if(Kvart(Month())==3 && Month()==7) shift=1;
if(Kvart(Month())==3 && Month()==8) shift=2;
if(Kvart(Month())==3 && Month()==8) shift=3;
if(Kvart(Month())==4 && Month()==10) shift=1;
if(Kvart(Month())==4 && Month()==11) shift=2;
if(Kvart(Month())==4 && Month()==12) shift=3;
return(shift);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
/*
1. Определим текущий квартал Kvart(int month)
2. Определим сумму за текущий квартал
3.
*/
string s="";
for(int i=1;i<=count;i++)
{
s+="\n"+(string)i+" Kvart: "+(string)Sum(i);
}
Comment("\n Kvartal: ",Kvart(Month()),
"\n Shift: ",Shift(Month())+s);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| ATR2.mq4 |
//| Copyright 2018, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
input int count=2;
input int kvart=4;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Kvart(int month)
{
int kv=0;
if(month<4) kv=1; // 1 2 3
if(month>3 && month<7) kv=2; // 4 5 6
if(month>6 && month<10) kv=3; // 7 8 9
if(month>9) kv=4; // 10 11 12
return(kv);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Shift(int month) // 1-rv = 1 2 3
{
int shift=0;
if(Kvart(Month())==1 && Month()==1) shift=1;
if(Kvart(Month())==1 && Month()==2) shift=2;
if(Kvart(Month())==1 && Month()==3) shift=3;
if(Kvart(Month())==2 && Month()==4) shift=1;
if(Kvart(Month())==2 && Month()==5) shift=2;
if(Kvart(Month())==2 && Month()==6) shift=3;
if(Kvart(Month())==3 && Month()==7) shift=1;
if(Kvart(Month())==3 && Month()==8) shift=2;
if(Kvart(Month())==3 && Month()==8) shift=3;
if(Kvart(Month())==4 && Month()==10) shift=1;
if(Kvart(Month())==4 && Month()==11) shift=2;
if(Kvart(Month())==4 && Month()==12) shift=3;
return(shift);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
/*
1. Определим текущий квартал Kvart(int month)
2. Определим сумму за текущий квартал
3.
*/
string s="";
for(int i=0;i<count;i++)
{
double lo=iLow(NULL,PERIOD_MN1,i);
double hi=iHigh(NULL,PERIOD_MN1,i);
s+="\n"+(string)i+" Kvart: "+(string)NormalizeDouble((hi-lo)/_Point,2);
}
Comment("\n Kvartal: ",Kvart(Month()),
"\n Shift: ",Shift(Month())+s);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
AM2