68 lines
3 KiB
MQL5
68 lines
3 KiB
MQL5
//****** project (module signals): tf-test-g1_module_signals_ind.mq5
|
|
//+------------------------------------------------------------------+
|
|
//| The program code is generated Modular project generator |
|
|
//| Copyright 2010-2017, Sergey Pavlov (DC2008) |
|
|
//| http://www.mql5.com/ru/users/dc2008 |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "Copyright 2010-2017, Sergey Pavlov (DC2008)"
|
|
#property link "http://www.mql5.com/ru/users/dc2008"
|
|
#property link "1.00"
|
|
#property link "Example of a multimodule expert: project tf-test-g1 module Trading signals"
|
|
//--- Display indicator in the chart window
|
|
#property indicator_chart_window
|
|
//--- Number of buffers to calculate the indicator
|
|
#property indicator_buffers 1
|
|
//--- Number of graphic series in the indicator
|
|
#property indicator_plots 1
|
|
//---
|
|
input int i_band_period=20; // band_period=20
|
|
input int i_band_shift=0; // band_shift=0
|
|
input double i_deviation=3.5; // i_deviation=3.5
|
|
ENUM_APPLIED_PRICE i_EAP=PRICE_CLOSE; // i_EAP=PRICE_CLOSE
|
|
double Buffer1[];
|
|
//--- Variable for storing the indicator iBands handle
|
|
int handle_Bands;
|
|
//+------------------------------------------------------------------+
|
|
//| Custom indicator initialization function |
|
|
//+------------------------------------------------------------------+
|
|
int OnInit()
|
|
{
|
|
handle_Bands=iBands(_Symbol,_Period,i_band_period,i_band_shift,i_deviation,i_EAP);
|
|
//---
|
|
ArraySetAsSeries(Buffer1,true);
|
|
SetIndexBuffer(0,Buffer1,INDICATOR_DATA);
|
|
PlotIndexSetString(0,PLOT_LABEL,"Signal");
|
|
ChartIndicatorAdd(0,0,handle_Bands);
|
|
return(INIT_SUCCEEDED);
|
|
};
|
|
//+------------------------------------------------------------------+
|
|
//| 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[])
|
|
{
|
|
double signal=0.0;
|
|
ArraySetAsSeries(high,true);
|
|
ArraySetAsSeries(low,true);
|
|
//--- Indicator buffers
|
|
double UpperBuffer[];
|
|
double LowerBuffer[];
|
|
ArraySetAsSeries(UpperBuffer,true);
|
|
CopyBuffer(handle_Bands,1,0,1,UpperBuffer);
|
|
ArraySetAsSeries(LowerBuffer,true);
|
|
CopyBuffer(handle_Bands,2,0,1,LowerBuffer);
|
|
//--- calculation of the Trading signals
|
|
if(high[0]>UpperBuffer[0]) signal=-2.0;
|
|
if(low[0]<LowerBuffer[0]) signal=2.0;
|
|
Buffer1[0]=signal;
|
|
return(rates_total);
|
|
};
|
|
//+------------------------------------------------------------------+
|