//+------------------------------------------------------------------+
//| TDC.mq5 |
//| Copyright 2020, Alexandr Valutsa |
//| https://www.valutsa.vip |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, Alexandr Valutsa"
#property link "https://www.valutsa.vip"
#property version "1.00"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 1
input double Ind0Param0 = 0;//Calculation method
input double Ind0Param1 = 0;
input double Ind0Param2 = 0;
input double Ind0Param3 = 0;
input double Ind0Param4 = 0;
input double Ind0Param5 = 0;
input double Ind0Param6 = 0;
input double Ind0Param7 = 0;
input double Ind0Param8 = 0;
input double Ind0Param9 = 0;
input double Ind0Param10 = 0;
input double Ind0Param11 = 0;
input double Ind0Param12 = 0;
input double Ind0Param13 = 0;
input double Ind0Param14 = 0;
input double Ind0Param15 = 0;
double ExtPosBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,ExtPosBuffer,INDICATOR_DATA);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Open:
//| 1 = BUY
//| -1 = SELL
//| Close:
//| 1 = SELL
//| -1 = BUY
//+------------------------------------------------------------------+
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 rates=rates_total-1;
if(Ind0Param0==0)//Calculation method ( 1 )
{
if(iClose(_Symbol,_Period,1)>iClose(_Symbol,_Period,2))// - BUY
ExtPosBuffer[rates]=1;
else
if(iClose(_Symbol,_Period,1)<iClose(_Symbol,_Period,2))// - SELL
ExtPosBuffer[rates]=-1;
else
ExtPosBuffer[rates]=0;
}
else
if(Ind0Param0==1)//Calculation method ( 2 )
{
if(iClose(_Symbol,_Period,1)<iClose(_Symbol,_Period,2))// - BUY
ExtPosBuffer[rates]=1;
else
if(iClose(_Symbol,_Period,1)>iClose(_Symbol,_Period,2))// - SELL
ExtPosBuffer[rates]=-1;
else
ExtPosBuffer[rates]=0;
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+