Initial Commit ...

This commit is contained in:
2024-01-25 04:03:36 +03:30
commit 0a19e0f4e1
217 changed files with 41677 additions and 0 deletions
+104
View File
@@ -0,0 +1,104 @@
//+------------------------------------------------------------------+
//| ATR.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Average True Range"
#property strict
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//--- input parameter
input int InpAtrPeriod=14; // ATR Period
//--- buffers
double ExtATRBuffer[];
double ExtTRBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(void)
{
string short_name;
//--- 1 additional buffer used for counting.
IndicatorBuffers(2);
IndicatorDigits(Digits);
//--- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtATRBuffer);
SetIndexBuffer(1,ExtTRBuffer);
//--- name for DataWindow and indicator subwindow label
short_name="ATR("+IntegerToString(InpAtrPeriod)+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//--- check for input parameter
if(InpAtrPeriod<=0)
{
Print("Wrong input parameter ATR Period=",InpAtrPeriod);
return(INIT_FAILED);
}
//---
SetIndexDrawBegin(0,InpAtrPeriod);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Average True Range |
//+------------------------------------------------------------------+
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 i,limit;
//--- check for bars count and input parameter
if(rates_total<=InpAtrPeriod || InpAtrPeriod<=0)
return(0);
//--- counting from 0 to rates_total
ArraySetAsSeries(ExtATRBuffer,false);
ArraySetAsSeries(ExtTRBuffer,false);
ArraySetAsSeries(open,false);
ArraySetAsSeries(high,false);
ArraySetAsSeries(low,false);
ArraySetAsSeries(close,false);
//--- preliminary calculations
if(prev_calculated==0)
{
ExtTRBuffer[0]=0.0;
ExtATRBuffer[0]=0.0;
//--- filling out the array of True Range values for each period
for(i=1; i<rates_total; i++)
ExtTRBuffer[i]=MathMax(high[i],close[i-1])-MathMin(low[i],close[i-1]);
//--- first AtrPeriod values of the indicator are not calculated
double firstValue=0.0;
for(i=1; i<=InpAtrPeriod; i++)
{
ExtATRBuffer[i]=0.0;
firstValue+=ExtTRBuffer[i];
}
//--- calculating the first value of the indicator
firstValue/=InpAtrPeriod;
ExtATRBuffer[InpAtrPeriod]=firstValue;
limit=InpAtrPeriod+1;
}
else
limit=prev_calculated-1;
//--- the main loop of calculations
for(i=limit; i<rates_total; i++)
{
ExtTRBuffer[i]=MathMax(high[i],close[i-1])-MathMin(low[i],close[i-1]);
ExtATRBuffer[i]=ExtATRBuffer[i-1]+(ExtTRBuffer[i]-ExtTRBuffer[i-InpAtrPeriod])/InpAtrPeriod;
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
+114
View File
@@ -0,0 +1,114 @@
//+------------------------------------------------------------------+
//| Accelerator.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Accelerator/Decelerator"
#property strict
#include <MovingAverages.mqh>
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Black
#property indicator_color2 Green
#property indicator_color3 Red
//--- indicator buffers
double ExtACBuffer[];
double ExtUpBuffer[];
double ExtDnBuffer[];
double ExtMacdBuffer[];
double ExtSignalBuffer[];
//---
#define PERIOD_FAST 5
#define PERIOD_SLOW 34
//--- bars minimum for calculation
#define DATA_LIMIT 38
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit(void)
{
IndicatorShortName("AC");
//--- 2 additional buffers are used for counting.
IndicatorBuffers(5);
//--- drawing settings
SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(2,DRAW_HISTOGRAM);
IndicatorDigits(Digits+2);
SetIndexDrawBegin(0,DATA_LIMIT);
SetIndexDrawBegin(1,DATA_LIMIT);
SetIndexDrawBegin(2,DATA_LIMIT);
//--- all indicator buffers mapping
SetIndexBuffer(0,ExtACBuffer);
SetIndexBuffer(1,ExtUpBuffer);
SetIndexBuffer(2,ExtDnBuffer);
SetIndexBuffer(3,ExtMacdBuffer);
SetIndexBuffer(4,ExtSignalBuffer);
//--- name for DataWindow and indicator subwindow label
SetIndexLabel(1,NULL);
SetIndexLabel(2,NULL);
}
//+------------------------------------------------------------------+
//| Accelerator/Decelerator Oscillator |
//+------------------------------------------------------------------+
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 i,limit;
double prev=0.0,current;
//--- check for rates total
if(rates_total<=DATA_LIMIT)
return(0);
//--- last counted bar will be recounted
limit=rates_total-prev_calculated;
if(prev_calculated>0)
{
limit++;
prev=ExtMacdBuffer[limit]-ExtSignalBuffer[limit];
}
//--- macd counted in the 1-st additional buffer
for(i=0; i<limit; i++)
ExtMacdBuffer[i]=iMA(NULL,0,PERIOD_FAST,0,MODE_SMA,PRICE_MEDIAN,i)-
iMA(NULL,0,PERIOD_SLOW,0,MODE_SMA,PRICE_MEDIAN,i);
//--- signal line counted in the 2-nd additional buffer
SimpleMAOnBuffer(rates_total,prev_calculated,0,5,ExtMacdBuffer,ExtSignalBuffer);
//--- dispatch values between 2 buffers
bool up=true;
for(i=limit-1; i>=0;)
{
current=ExtMacdBuffer[i]-ExtSignalBuffer[i];
if(current>prev)
up=true;
if(current<prev)
up=false;
if(!up)
{
ExtUpBuffer[i]=0.0;
ExtDnBuffer[i]=current;
}
else
{
ExtUpBuffer[i]=current;
ExtDnBuffer[i]=0.0;
}
ExtACBuffer[i]=current;
i--;
prev=ExtMacdBuffer[i+1]-ExtSignalBuffer[i+1];
}
//--- done
return(rates_total);
}
//+------------------------------------------------------------------+
+69
View File
@@ -0,0 +1,69 @@
//+------------------------------------------------------------------+
//| Accumulation.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Accumulation/Distribution"
#property strict
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 LightSeaGreen
//--- buffers
double ExtADbuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit(void)
{
IndicatorShortName("A/D");
IndicatorDigits(0);
//--- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtADbuffer);
}
//+------------------------------------------------------------------+
//| Accumulation/Distribution |
//+------------------------------------------------------------------+
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[])
{
//--- prevent total recalculation
int i=rates_total-prev_calculated-1;
//--- current value should be recalculated
if(i<0)
i=0;
//---
while(i>=0)
{
ExtADbuffer[i]=(close[i]-low[i])-(high[i]-close[i]);
if(ExtADbuffer[i]!=0.0)
{
double diff=high[i]-low[i];
if(diff<0.000000001)
ExtADbuffer[i]=0.0;
else
{
ExtADbuffer[i]/=diff;
ExtADbuffer[i]*=(double)tick_volume[i];
}
}
if(i<rates_total-1)
ExtADbuffer[i]+=ExtADbuffer[i+1];
i--;
}
//---
return(rates_total);
}
//+------------------------------------------------------------------+
+81
View File
@@ -0,0 +1,81 @@
//+------------------------------------------------------------------+
//| Alligator.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Bill Williams' Aligator"
#property strict
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Lime
//---- input parameters
input int InpJawsPeriod=13; // Jaws Period
input int InpJawsShift=8; // Jaws Shift
input int InpTeethPeriod=8; // Teeth Period
input int InpTeethShift=5; // Teeth Shift
input int InpLipsPeriod=5; // Lips Period
input int InpLipsShift=3; // Lips Shift
//---- indicator buffers
double ExtBlueBuffer[];
double ExtRedBuffer[];
double ExtLimeBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit(void)
{
IndicatorDigits(Digits);
//---- line shifts when drawing
SetIndexShift(0,InpJawsShift);
SetIndexShift(1,InpTeethShift);
SetIndexShift(2,InpLipsShift);
//---- first positions skipped when drawing
SetIndexDrawBegin(0,InpJawsShift+InpJawsPeriod);
SetIndexDrawBegin(1,InpTeethShift+InpTeethPeriod);
SetIndexDrawBegin(2,InpLipsShift+InpLipsPeriod);
//---- 3 indicator buffers mapping
SetIndexBuffer(0,ExtBlueBuffer);
SetIndexBuffer(1,ExtRedBuffer);
SetIndexBuffer(2,ExtLimeBuffer);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
//---- index labels
SetIndexLabel(0,"Gator Jaws");
SetIndexLabel(1,"Gator Teeth");
SetIndexLabel(2,"Gator Lips");
}
//+------------------------------------------------------------------+
//| Bill Williams' Alligator |
//+------------------------------------------------------------------+
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 limit=rates_total-prev_calculated;
//---- main loop
for(int i=0; i<limit; i++)
{
//---- ma_shift set to 0 because SetIndexShift called abowe
ExtBlueBuffer[i]=iMA(NULL,0,InpJawsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
ExtRedBuffer[i]=iMA(NULL,0,InpTeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
ExtLimeBuffer[i]=iMA(NULL,0,InpLipsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
}
//---- done
return(rates_total);
}
//+------------------------------------------------------------------+
+101
View File
@@ -0,0 +1,101 @@
//+------------------------------------------------------------------+
//| Awesome.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Awesome Oscillator"
#property strict
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Black
#property indicator_color2 Green
#property indicator_color3 Red
//--- buffers
double ExtAOBuffer[];
double ExtUpBuffer[];
double ExtDnBuffer[];
//---
#define PERIOD_FAST 5
#define PERIOD_SLOW 34
//--- bars minimum for calculation
#define DATA_LIMIT 34
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit(void)
{
//--- drawing settings
SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(2,DRAW_HISTOGRAM);
IndicatorDigits(Digits+1);
SetIndexDrawBegin(0,DATA_LIMIT);
SetIndexDrawBegin(1,DATA_LIMIT);
SetIndexDrawBegin(2,DATA_LIMIT);
//--- 3 indicator buffers mapping
SetIndexBuffer(0,ExtAOBuffer);
SetIndexBuffer(1,ExtUpBuffer);
SetIndexBuffer(2,ExtDnBuffer);
//--- name for DataWindow and indicator subwindow label
IndicatorShortName("AO");
SetIndexLabel(1,NULL);
SetIndexLabel(2,NULL);
}
//+------------------------------------------------------------------+
//| Awesome Oscillator |
//+------------------------------------------------------------------+
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 i,limit=rates_total-prev_calculated;
double prev=0.0,current;
//--- check for rates total
if(rates_total<=DATA_LIMIT)
return(0);
//--- last counted bar will be recounted
if(prev_calculated>0)
{
limit++;
prev=ExtAOBuffer[limit];
}
//--- macd
for(i=0; i<limit; i++)
ExtAOBuffer[i]=iMA(NULL,0,PERIOD_FAST,0,MODE_SMA,PRICE_MEDIAN,i)-
iMA(NULL,0,PERIOD_SLOW,0,MODE_SMA,PRICE_MEDIAN,i);
//--- dispatch values between 2 buffers
bool up=true;
for(i=limit-1; i>=0; i--)
{
current=ExtAOBuffer[i];
if(current>prev)
up=true;
if(current<prev)
up=false;
if(!up)
{
ExtDnBuffer[i]=current;
ExtUpBuffer[i]=0.0;
}
else
{
ExtUpBuffer[i]=current;
ExtDnBuffer[i]=0.0;
}
prev=current;
}
//--- done
return(rates_total);
}
//+------------------------------------------------------------------+
+138
View File
@@ -0,0 +1,138 @@
//+------------------------------------------------------------------+
//| Bands.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Bollinger Bands"
#property strict
#include <MovingAverages.mqh>
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 LightSeaGreen
#property indicator_color2 LightSeaGreen
#property indicator_color3 LightSeaGreen
//--- indicator parameters
input int InpBandsPeriod=20; // Bands Period
input int InpBandsShift=0; // Bands Shift
input double InpBandsDeviations=2.0; // Bands Deviations
//--- buffers
double ExtMovingBuffer[];
double ExtUpperBuffer[];
double ExtLowerBuffer[];
double ExtStdDevBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(void)
{
//--- 1 additional buffer used for counting.
IndicatorBuffers(4);
IndicatorDigits(Digits);
//--- middle line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMovingBuffer);
SetIndexShift(0,InpBandsShift);
SetIndexLabel(0,"Bands SMA");
//--- upper band
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtUpperBuffer);
SetIndexShift(1,InpBandsShift);
SetIndexLabel(1,"Bands Upper");
//--- lower band
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtLowerBuffer);
SetIndexShift(2,InpBandsShift);
SetIndexLabel(2,"Bands Lower");
//--- work buffer
SetIndexBuffer(3,ExtStdDevBuffer);
//--- check for input parameter
if(InpBandsPeriod<=0)
{
Print("Wrong input parameter Bands Period=",InpBandsPeriod);
return(INIT_FAILED);
}
//---
SetIndexDrawBegin(0,InpBandsPeriod+InpBandsShift);
SetIndexDrawBegin(1,InpBandsPeriod+InpBandsShift);
SetIndexDrawBegin(2,InpBandsPeriod+InpBandsShift);
//--- initialization done
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Bollinger Bands |
//+------------------------------------------------------------------+
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 i,pos;
//---
if(rates_total<=InpBandsPeriod || InpBandsPeriod<=0)
return(0);
//--- counting from 0 to rates_total
ArraySetAsSeries(ExtMovingBuffer,false);
ArraySetAsSeries(ExtUpperBuffer,false);
ArraySetAsSeries(ExtLowerBuffer,false);
ArraySetAsSeries(ExtStdDevBuffer,false);
ArraySetAsSeries(close,false);
//--- initial zero
if(prev_calculated<1)
{
for(i=0; i<InpBandsPeriod; i++)
{
ExtMovingBuffer[i]=EMPTY_VALUE;
ExtUpperBuffer[i]=EMPTY_VALUE;
ExtLowerBuffer[i]=EMPTY_VALUE;
}
}
//--- starting calculation
if(prev_calculated>1)
pos=prev_calculated-1;
else
pos=0;
//--- main cycle
for(i=pos; i<rates_total && !IsStopped(); i++)
{
//--- middle line
ExtMovingBuffer[i]=SimpleMA(i,InpBandsPeriod,close);
//--- calculate and write down StdDev
ExtStdDevBuffer[i]=StdDev_Func(i,close,ExtMovingBuffer,InpBandsPeriod);
//--- upper line
ExtUpperBuffer[i]=ExtMovingBuffer[i]+InpBandsDeviations*ExtStdDevBuffer[i];
//--- lower line
ExtLowerBuffer[i]=ExtMovingBuffer[i]-InpBandsDeviations*ExtStdDevBuffer[i];
//---
}
//---- OnCalculate done. Return new prev_calculated.
return(rates_total);
}
//+------------------------------------------------------------------+
//| Calculate Standard Deviation |
//+------------------------------------------------------------------+
double StdDev_Func(int position,const double &price[],const double &MAprice[],int period)
{
//--- variables
double StdDev_dTmp=0.0;
//--- check for position
if(position>=period)
{
//--- calcualte StdDev
for(int i=0; i<period; i++)
StdDev_dTmp+=MathPow(price[position-i]-MAprice[position],2);
StdDev_dTmp=MathSqrt(StdDev_dTmp/period);
}
//--- return calculated value
return(StdDev_dTmp);
}
//+------------------------------------------------------------------+
+67
View File
@@ -0,0 +1,67 @@
//+------------------------------------------------------------------+
//| Bears.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Bears Power"
#property strict
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Silver
//--- input parameter
input int InpBearsPeriod=13; // Bears Period
//--- buffers
double ExtBearsBuffer[];
double ExtTempBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit(void)
{
string short_name;
//--- 1 additional buffer used for counting.
IndicatorBuffers(2);
IndicatorDigits(Digits);
//--- indicator line
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtBearsBuffer);
SetIndexBuffer(1,ExtTempBuffer);
//--- name for DataWindow and indicator subwindow label
short_name="Bears("+IntegerToString(InpBearsPeriod)+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
}
//+------------------------------------------------------------------+
//| Bears Power |
//+------------------------------------------------------------------+
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 limit=rates_total-prev_calculated;
//---
if(rates_total<=InpBearsPeriod)
return(0);
//---
if(prev_calculated>0)
limit++;
for(int i=0; i<limit; i++)
{
ExtTempBuffer[i]=iMA(NULL,0,InpBearsPeriod,0,MODE_EMA,PRICE_CLOSE,i);
ExtBearsBuffer[i]=low[i]-ExtTempBuffer[i];
}
//---
return(rates_total);
}
//+------------------------------------------------------------------+
+67
View File
@@ -0,0 +1,67 @@
//+------------------------------------------------------------------+
//| Bulls.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Bulls Power"
#property strict
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Silver
//--- input parameter
input int InpBullsPeriod=13;
//--- buffers
double ExtBullsBuffer[];
double ExtTempBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit(void)
{
string short_name;
//--- 1 additional buffer used for counting.
IndicatorBuffers(2);
IndicatorDigits(Digits);
//--- indicator line
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtBullsBuffer);
SetIndexBuffer(1,ExtTempBuffer);
//--- name for DataWindow and indicator subwindow label
short_name="Bulls("+IntegerToString(InpBullsPeriod)+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
}
//+------------------------------------------------------------------+
//| Bulls Power |
//+------------------------------------------------------------------+
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 limit=rates_total-prev_calculated;
//---
if(rates_total<=InpBullsPeriod)
return(0);
//---
if(prev_calculated>0)
limit++;
for(int i=0; i<limit; i++)
{
ExtTempBuffer[i]=iMA(NULL,0,InpBullsPeriod,0,MODE_EMA,PRICE_CLOSE,i);
ExtBullsBuffer[i]=high[i]-ExtTempBuffer[i];
}
//---
return(rates_total);
}
//+------------------------------------------------------------------+
+125
View File
@@ -0,0 +1,125 @@
//+------------------------------------------------------------------+
//| CCI.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Commodity Channel Index"
#property strict
#include <MovingAverages.mqh>
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 LightSeaGreen
#property indicator_level1 -100.0
#property indicator_level2 100.0
#property indicator_levelcolor clrSilver
#property indicator_levelstyle STYLE_DOT
//--- input parameter
input int InpCCIPeriod=14; // CCI Period
//--- buffers
double ExtCCIBuffer[];
double ExtPriceBuffer[];
double ExtMovBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(void)
{
string short_name;
//--- 2 additional buffers are used for counting.
IndicatorBuffers(3);
SetIndexBuffer(1,ExtPriceBuffer);
SetIndexBuffer(2,ExtMovBuffer);
//--- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtCCIBuffer);
//--- check for input parameter
if(InpCCIPeriod<=1)
{
Print("Wrong input parameter CCI Period=",InpCCIPeriod);
return(INIT_FAILED);
}
//---
SetIndexDrawBegin(0,InpCCIPeriod);
//--- name for DataWindow and indicator subwindow label
short_name="CCI("+IntegerToString(InpCCIPeriod)+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//--- initialization done
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Commodity Channel Index |
//+------------------------------------------------------------------+
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 i,k,pos;
double dSum,dMul;
//---
if(rates_total<=InpCCIPeriod || InpCCIPeriod<=1)
return(0);
//--- counting from 0 to rates_total
ArraySetAsSeries(ExtCCIBuffer,false);
ArraySetAsSeries(ExtPriceBuffer,false);
ArraySetAsSeries(ExtMovBuffer,false);
ArraySetAsSeries(high,false);
ArraySetAsSeries(low,false);
ArraySetAsSeries(close,false);
//--- initial zero
if(prev_calculated<1)
{
for(i=0; i<InpCCIPeriod; i++)
{
ExtCCIBuffer[i]=0.0;
ExtPriceBuffer[i]=(high[i]+low[i]+close[i])/3;
ExtMovBuffer[i]=0.0;
}
}
//--- calculate position
pos=prev_calculated-1;
if(pos<InpCCIPeriod)
pos=InpCCIPeriod;
//--- typical price and its moving average
for(i=pos; i<rates_total; i++)
{
ExtPriceBuffer[i]=(high[i]+low[i]+close[i])/3;
ExtMovBuffer[i]=SimpleMA(i,InpCCIPeriod,ExtPriceBuffer);
}
//--- standard deviations and cci counting
dMul=0.015/InpCCIPeriod;
pos=InpCCIPeriod-1;
if(pos<prev_calculated-1)
pos=prev_calculated-2;
i=pos;
while(i<rates_total)
{
dSum=0.0;
k=i+1-InpCCIPeriod;
while(k<=i)
{
dSum+=MathAbs(ExtPriceBuffer[k]-ExtMovBuffer[i]);
k++;
}
dSum*=dMul;
if(dSum==0.0)
ExtCCIBuffer[i]=0.0;
else
ExtCCIBuffer[i]=(ExtPriceBuffer[i]-ExtMovBuffer[i])/dSum;
i++;
}
//---
return(rates_total);
}
//+------------------------------------------------------------------+
+190
View File
@@ -0,0 +1,190 @@
//+------------------------------------------------------------------+
//| Custom Moving Averages.mq4 |
//| Copyright 2005-2015, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2015, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Moving Average"
#property strict
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//--- indicator parameters
input int InpMAPeriod=13; // Period
input int InpMAShift=0; // Shift
input ENUM_MA_METHOD InpMAMethod=MODE_SMA; // Method
//--- indicator buffer
double ExtLineBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(void)
{
string short_name;
int draw_begin=InpMAPeriod-1;
//--- indicator short name
switch(InpMAMethod)
{
case MODE_SMA : short_name="SMA("; break;
case MODE_EMA : short_name="EMA("; draw_begin=0; break;
case MODE_SMMA : short_name="SMMA("; break;
case MODE_LWMA : short_name="LWMA("; break;
default : return(INIT_FAILED);
}
IndicatorShortName(short_name+string(InpMAPeriod)+")");
IndicatorDigits(Digits);
//--- check for input
if(InpMAPeriod<2)
return(INIT_FAILED);
//--- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexShift(0,InpMAShift);
SetIndexDrawBegin(0,draw_begin);
//--- indicator buffers mapping
SetIndexBuffer(0,ExtLineBuffer);
//--- initialization done
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Moving Average |
//+------------------------------------------------------------------+
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[])
{
//--- check for bars count
if(rates_total<InpMAPeriod-1 || InpMAPeriod<2)
return(0);
//--- counting from 0 to rates_total
ArraySetAsSeries(ExtLineBuffer,false);
ArraySetAsSeries(close,false);
//--- first calculation or number of bars was changed
if(prev_calculated==0)
ArrayInitialize(ExtLineBuffer,0);
//--- calculation
switch(InpMAMethod)
{
case MODE_EMA: CalculateEMA(rates_total,prev_calculated,close); break;
case MODE_LWMA: CalculateLWMA(rates_total,prev_calculated,close); break;
case MODE_SMMA: CalculateSmoothedMA(rates_total,prev_calculated,close); break;
case MODE_SMA: CalculateSimpleMA(rates_total,prev_calculated,close); break;
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//| simple moving average |
//+------------------------------------------------------------------+
void CalculateSimpleMA(int rates_total,int prev_calculated,const double &price[])
{
int i,limit;
//--- first calculation or number of bars was changed
if(prev_calculated==0)
{
limit=InpMAPeriod;
//--- calculate first visible value
double firstValue=0;
for(i=0; i<limit; i++)
firstValue+=price[i];
firstValue/=InpMAPeriod;
ExtLineBuffer[limit-1]=firstValue;
}
else
limit=prev_calculated-1;
//--- main loop
for(i=limit; i<rates_total && !IsStopped(); i++)
ExtLineBuffer[i]=ExtLineBuffer[i-1]+(price[i]-price[i-InpMAPeriod])/InpMAPeriod;
//---
}
//+------------------------------------------------------------------+
//| exponential moving average |
//+------------------------------------------------------------------+
void CalculateEMA(int rates_total,int prev_calculated,const double &price[])
{
int i,limit;
double SmoothFactor=2.0/(1.0+InpMAPeriod);
//--- first calculation or number of bars was changed
if(prev_calculated==0)
{
limit=InpMAPeriod;
ExtLineBuffer[0]=price[0];
for(i=1; i<limit; i++)
ExtLineBuffer[i]=price[i]*SmoothFactor+ExtLineBuffer[i-1]*(1.0-SmoothFactor);
}
else
limit=prev_calculated-1;
//--- main loop
for(i=limit; i<rates_total && !IsStopped(); i++)
ExtLineBuffer[i]=price[i]*SmoothFactor+ExtLineBuffer[i-1]*(1.0-SmoothFactor);
//---
}
//+------------------------------------------------------------------+
//| linear weighted moving average |
//+------------------------------------------------------------------+
void CalculateLWMA(int rates_total,int prev_calculated,const double &price[])
{
int i,limit;
static int weightsum;
double sum;
//--- first calculation or number of bars was changed
if(prev_calculated==0)
{
weightsum=0;
limit=InpMAPeriod;
//--- calculate first visible value
double firstValue=0;
for(i=0;i<limit;i++)
{
int k=i+1;
weightsum+=k;
firstValue+=k*price[i];
}
firstValue/=(double)weightsum;
ExtLineBuffer[limit-1]=firstValue;
}
else
limit=prev_calculated-1;
//--- main loop
for(i=limit; i<rates_total && !IsStopped(); i++)
{
sum=0;
for(int j=0;j<InpMAPeriod;j++)
sum+=(InpMAPeriod-j)*price[i-j];
ExtLineBuffer[i]=sum/weightsum;
}
//---
}
//+------------------------------------------------------------------+
//| smoothed moving average |
//+------------------------------------------------------------------+
void CalculateSmoothedMA(int rates_total,int prev_calculated,const double &price[])
{
int i,limit;
//--- first calculation or number of bars was changed
if(prev_calculated==0)
{
limit=InpMAPeriod;
double firstValue=0;
for(i=0; i<limit; i++)
firstValue+=price[i];
firstValue/=InpMAPeriod;
ExtLineBuffer[limit-1]=firstValue;
}
else
limit=prev_calculated-1;
//--- main loop
for(i=limit; i<rates_total && !IsStopped(); i++)
ExtLineBuffer[i]=(ExtLineBuffer[i-1]*(InpMAPeriod-1)+price[i])/InpMAPeriod;
//---
}
//+------------------------------------------------------------------+
+138
View File
@@ -0,0 +1,138 @@
//+------------------------------------------------------------------+
//| Heiken Ashi.mq4 |
//| Copyright 2006-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2006-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "We recommend next chart settings (press F8 or select menu 'Charts'->'Properties...'):"
#property description " - on 'Color' Tab select 'Black' for 'Line Graph'"
#property description " - on 'Common' Tab disable 'Chart on Foreground' checkbox and select 'Line Chart' radiobutton"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 White
#property indicator_color3 Red
#property indicator_color4 White
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 3
#property indicator_width4 3
//---
input color ExtColor1 = Red; // Shadow of bear candlestick
input color ExtColor2 = White; // Shadow of bull candlestick
input color ExtColor3 = Red; // Bear candlestick body
input color ExtColor4 = White; // Bull candlestick body
//--- buffers
double ExtLowHighBuffer[];
double ExtHighLowBuffer[];
double ExtOpenBuffer[];
double ExtCloseBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//|------------------------------------------------------------------|
void OnInit(void)
{
IndicatorShortName("Heiken Ashi");
IndicatorDigits(Digits);
//--- indicator lines
SetIndexStyle(0,DRAW_HISTOGRAM,0,1,ExtColor1);
SetIndexBuffer(0,ExtLowHighBuffer);
SetIndexStyle(1,DRAW_HISTOGRAM,0,1,ExtColor2);
SetIndexBuffer(1,ExtHighLowBuffer);
SetIndexStyle(2,DRAW_HISTOGRAM,0,3,ExtColor3);
SetIndexBuffer(2,ExtOpenBuffer);
SetIndexStyle(3,DRAW_HISTOGRAM,0,3,ExtColor4);
SetIndexBuffer(3,ExtCloseBuffer);
//---
SetIndexLabel(0,"Low/High");
SetIndexLabel(1,"High/Low");
SetIndexLabel(2,"Open");
SetIndexLabel(3,"Close");
SetIndexDrawBegin(0,10);
SetIndexDrawBegin(1,10);
SetIndexDrawBegin(2,10);
SetIndexDrawBegin(3,10);
//--- indicator buffers mapping
SetIndexBuffer(0,ExtLowHighBuffer);
SetIndexBuffer(1,ExtHighLowBuffer);
SetIndexBuffer(2,ExtOpenBuffer);
SetIndexBuffer(3,ExtCloseBuffer);
//--- initialization done
}
//+------------------------------------------------------------------+
//| Heiken Ashi |
//+------------------------------------------------------------------+
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 i,pos;
double haOpen,haHigh,haLow,haClose;
//---
if(rates_total<=10)
return(0);
//--- counting from 0 to rates_total
ArraySetAsSeries(ExtLowHighBuffer,false);
ArraySetAsSeries(ExtHighLowBuffer,false);
ArraySetAsSeries(ExtOpenBuffer,false);
ArraySetAsSeries(ExtCloseBuffer,false);
ArraySetAsSeries(open,false);
ArraySetAsSeries(high,false);
ArraySetAsSeries(low,false);
ArraySetAsSeries(close,false);
//--- preliminary calculation
if(prev_calculated>1)
pos=prev_calculated-1;
else
{
//--- set first candle
if(open[0]<close[0])
{
ExtLowHighBuffer[0]=low[0];
ExtHighLowBuffer[0]=high[0];
}
else
{
ExtLowHighBuffer[0]=high[0];
ExtHighLowBuffer[0]=low[0];
}
ExtOpenBuffer[0]=open[0];
ExtCloseBuffer[0]=close[0];
//---
pos=1;
}
//--- main loop of calculations
for(i=pos; i<rates_total; i++)
{
haOpen=(ExtOpenBuffer[i-1]+ExtCloseBuffer[i-1])/2;
haClose=(open[i]+high[i]+low[i]+close[i])/4;
haHigh=MathMax(high[i],MathMax(haOpen,haClose));
haLow=MathMin(low[i],MathMin(haOpen,haClose));
if(haOpen<haClose)
{
ExtLowHighBuffer[i]=haLow;
ExtHighLowBuffer[i]=haHigh;
}
else
{
ExtLowHighBuffer[i]=haHigh;
ExtHighLowBuffer[i]=haLow;
}
ExtOpenBuffer[i]=haOpen;
ExtCloseBuffer[i]=haClose;
}
//--- done
return(rates_total);
}
//+------------------------------------------------------------------+
+208
View File
@@ -0,0 +1,208 @@
//+------------------------------------------------------------------+
//| Ichimoku.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Ichimoku Kinko Hyo"
#property strict
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Red // Tenkan-sen
#property indicator_color2 Blue // Kijun-sen
#property indicator_color3 SandyBrown // Up Kumo
#property indicator_color4 Thistle // Down Kumo
#property indicator_color5 Lime // Chikou Span
#property indicator_color6 SandyBrown // Up Kumo bounding line
#property indicator_color7 Thistle // Down Kumo bounding line
//--- input parameters
input int InpTenkan=9; // Tenkan-sen
input int InpKijun=26; // Kijun-sen
input int InpSenkou=52; // Senkou Span B
//--- buffers
double ExtTenkanBuffer[];
double ExtKijunBuffer[];
double ExtSpanA_Buffer[];
double ExtSpanB_Buffer[];
double ExtChikouBuffer[];
double ExtSpanA2_Buffer[];
double ExtSpanB2_Buffer[];
//---
int ExtBegin;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit(void)
{
IndicatorDigits(Digits);
//---
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtTenkanBuffer);
SetIndexDrawBegin(0,InpTenkan-1);
SetIndexLabel(0,"Tenkan Sen");
//---
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtKijunBuffer);
SetIndexDrawBegin(1,InpKijun-1);
SetIndexLabel(1,"Kijun Sen");
//---
ExtBegin=InpKijun;
if(ExtBegin<InpTenkan)
ExtBegin=InpTenkan;
//---
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_DOT);
SetIndexBuffer(2,ExtSpanA_Buffer);
SetIndexDrawBegin(2,InpKijun+ExtBegin-1);
SetIndexShift(2,InpKijun);
SetIndexLabel(2,NULL);
SetIndexStyle(5,DRAW_LINE,STYLE_DOT);
SetIndexBuffer(5,ExtSpanA2_Buffer);
SetIndexDrawBegin(5,InpKijun+ExtBegin-1);
SetIndexShift(5,InpKijun);
SetIndexLabel(5,"Senkou Span A");
//---
SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_DOT);
SetIndexBuffer(3,ExtSpanB_Buffer);
SetIndexDrawBegin(3,InpKijun+InpSenkou-1);
SetIndexShift(3,InpKijun);
SetIndexLabel(3,NULL);
SetIndexStyle(6,DRAW_LINE,STYLE_DOT);
SetIndexBuffer(6,ExtSpanB2_Buffer);
SetIndexDrawBegin(6,InpKijun+InpSenkou-1);
SetIndexShift(6,InpKijun);
SetIndexLabel(6,"Senkou Span B");
//---
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,ExtChikouBuffer);
SetIndexShift(4,-InpKijun);
SetIndexLabel(4,"Chikou Span");
//--- initialization done
}
//+------------------------------------------------------------------+
//| Ichimoku Kinko Hyo |
//+------------------------------------------------------------------+
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 i,k,pos;
double high_value,low_value;
//---
if(rates_total<=InpTenkan || rates_total<=InpKijun || rates_total<=InpSenkou)
return(0);
//--- counting from 0 to rates_total
ArraySetAsSeries(ExtTenkanBuffer,false);
ArraySetAsSeries(ExtKijunBuffer,false);
ArraySetAsSeries(ExtSpanA_Buffer,false);
ArraySetAsSeries(ExtSpanB_Buffer,false);
ArraySetAsSeries(ExtChikouBuffer,false);
ArraySetAsSeries(ExtSpanA2_Buffer,false);
ArraySetAsSeries(ExtSpanB2_Buffer,false);
ArraySetAsSeries(open,false);
ArraySetAsSeries(high,false);
ArraySetAsSeries(low,false);
ArraySetAsSeries(close,false);
//--- initial zero
if(prev_calculated<1)
{
for(i=0; i<InpTenkan; i++)
ExtTenkanBuffer[i]=0.0;
for(i=0; i<InpKijun; i++)
ExtKijunBuffer[i]=0.0;
for(i=0; i<ExtBegin; i++)
{
ExtSpanA_Buffer[i]=0.0;
ExtSpanA2_Buffer[i]=0.0;
}
for(i=0; i<InpSenkou; i++)
{
ExtSpanB_Buffer[i]=0.0;
ExtSpanB2_Buffer[i]=0.0;
}
}
//--- Tenkan Sen
pos=InpTenkan-1;
if(prev_calculated>InpTenkan)
pos=prev_calculated-1;
for(i=pos; i<rates_total; i++)
{
high_value=high[i];
low_value=low[i];
k=i+1-InpTenkan;
while(k<=i)
{
if(high_value<high[k])
high_value=high[k];
if(low_value>low[k])
low_value=low[k];
k++;
}
ExtTenkanBuffer[i]=(high_value+low_value)/2;
}
//--- Kijun Sen
pos=InpKijun-1;
if(prev_calculated>InpKijun)
pos=prev_calculated-1;
for(i=pos; i<rates_total; i++)
{
high_value=high[i];
low_value=low[i];
k=i+1-InpKijun;
while(k<=i)
{
if(high_value<high[k])
high_value=high[k];
if(low_value>low[k])
low_value=low[k];
k++;
}
ExtKijunBuffer[i]=(high_value+low_value)/2;
}
//--- Senkou Span A
pos=ExtBegin-1;
if(prev_calculated>ExtBegin)
pos=prev_calculated-1;
for(i=pos; i<rates_total; i++)
{
ExtSpanA_Buffer[i]=(ExtKijunBuffer[i]+ExtTenkanBuffer[i])/2;
ExtSpanA2_Buffer[i]=ExtSpanA_Buffer[i];
}
//--- Senkou Span B
pos=InpSenkou-1;
if(prev_calculated>InpSenkou)
pos=prev_calculated-1;
for(i=pos; i<rates_total; i++)
{
high_value=high[i];
low_value=low[i];
k=i+1-InpSenkou;
while(k<=i)
{
if(high_value<high[k])
high_value=high[k];
if(low_value>low[k])
low_value=low[k];
k++;
}
ExtSpanB_Buffer[i]=(high_value+low_value)/2;
ExtSpanB2_Buffer[i]=ExtSpanB_Buffer[i];
}
//--- Chikou Span
pos=0;
if(prev_calculated>1)
pos=prev_calculated-1;
for(i=pos; i<rates_total; i++)
ExtChikouBuffer[i]=close[i];
//---
return(rates_total);
}
//+------------------------------------------------------------------+
+89
View File
@@ -0,0 +1,89 @@
//+------------------------------------------------------------------+
//| Custom MACD.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Moving Averages Convergence/Divergence"
#property strict
#include <MovingAverages.mqh>
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Silver
#property indicator_color2 Red
#property indicator_width1 2
//--- indicator parameters
input int InpFastEMA=12; // Fast EMA Period
input int InpSlowEMA=26; // Slow EMA Period
input int InpSignalSMA=9; // Signal SMA Period
//--- indicator buffers
double ExtMacdBuffer[];
double ExtSignalBuffer[];
//--- right input parameters flag
bool ExtParameters=false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(void)
{
IndicatorDigits(Digits+1);
//--- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_LINE);
SetIndexDrawBegin(1,InpSignalSMA);
//--- indicator buffers mapping
SetIndexBuffer(0,ExtMacdBuffer);
SetIndexBuffer(1,ExtSignalBuffer);
//--- name for DataWindow and indicator subwindow label
IndicatorShortName("MACD("+IntegerToString(InpFastEMA)+","+IntegerToString(InpSlowEMA)+","+IntegerToString(InpSignalSMA)+")");
SetIndexLabel(0,"MACD");
SetIndexLabel(1,"Signal");
//--- check for input parameters
if(InpFastEMA<=1 || InpSlowEMA<=1 || InpSignalSMA<=1 || InpFastEMA>=InpSlowEMA)
{
Print("Wrong input parameters");
ExtParameters=false;
return(INIT_FAILED);
}
else
ExtParameters=true;
//--- initialization done
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence |
//+------------------------------------------------------------------+
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 i,limit;
//---
if(rates_total<=InpSignalSMA || !ExtParameters)
return(0);
//--- last counted bar will be recounted
limit=rates_total-prev_calculated;
if(prev_calculated>0)
limit++;
//--- macd counted in the 1-st buffer
for(i=0; i<limit; i++)
ExtMacdBuffer[i]=iMA(NULL,0,InpFastEMA,0,MODE_EMA,PRICE_CLOSE,i)-
iMA(NULL,0,InpSlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//--- signal line counted in the 2-nd buffer
SimpleMAOnBuffer(rates_total,prev_calculated,0,InpSignalSMA,ExtMacdBuffer,ExtSignalBuffer);
//--- done
return(rates_total);
}
//+------------------------------------------------------------------+
+78
View File
@@ -0,0 +1,78 @@
//+------------------------------------------------------------------+
//| Momentum.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Momentum"
#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//--- input parameter
input int InpMomPeriod=14; // Momentum Period
//--- buffers
double ExtMomBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(void)
{
string short_name;
//--- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMomBuffer);
//--- name for DataWindow and indicator subwindow label
short_name="Mom("+IntegerToString(InpMomPeriod)+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//--- check for input parameter
if(InpMomPeriod<=0)
{
Print("Wrong input parameter Momentum Period=",InpMomPeriod);
return(INIT_FAILED);
}
//---
SetIndexDrawBegin(0,InpMomPeriod);
//--- initialization done
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Momentum |
//+------------------------------------------------------------------+
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 i,limit;
//--- check for bars count and input parameter
if(rates_total<=InpMomPeriod || InpMomPeriod<=0)
return(0);
//--- counting from 0 to rates_total
ArraySetAsSeries(ExtMomBuffer,false);
ArraySetAsSeries(close,false);
//--- initial zero
if(prev_calculated<=0)
{
for(i=0; i<InpMomPeriod; i++)
ExtMomBuffer[i]=0.0;
limit=InpMomPeriod;
}
else
limit=prev_calculated-1;
//--- the main loop of calculations
for(i=limit; i<rates_total; i++)
ExtMomBuffer[i]=close[i]*100/close[i-InpMomPeriod];
//--- done
return(rates_total);
}
//+------------------------------------------------------------------+
+91
View File
@@ -0,0 +1,91 @@
//+------------------------------------------------------------------+
//| OsMA.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Moving Averages of Oscillator"
#property strict
#include <MovingAverages.mqh>
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Silver
#property indicator_width1 2
//--- indicator parameters
input int InpFastEMA=12; // Fast EMA Period
input int InpSlowEMA=26; // Slow EMA Period
input int InpSignalSMA=9; // Signal SMA Period
//--- indicator buffers
double ExtOsmaBuffer[];
double ExtMacdBuffer[];
double ExtSignalBuffer[];
//--- right input parameters flag
bool ExtParameters=false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(void)
{
//--- 2 additional buffers are used for counting.
IndicatorBuffers(3);
//--- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexDrawBegin(0,InpSignalSMA);
IndicatorDigits(Digits+2);
//--- 3 indicator buffers mapping
SetIndexBuffer(0,ExtOsmaBuffer);
SetIndexBuffer(1,ExtMacdBuffer);
SetIndexBuffer(2,ExtSignalBuffer);
//--- name for DataWindow and indicator subwindow label
IndicatorShortName("OsMA("+IntegerToString(InpFastEMA)+","+IntegerToString(InpSlowEMA)+","+IntegerToString(InpSignalSMA)+")");
//--- check for input parameters
if(InpFastEMA<=1 || InpSlowEMA<=1 || InpSignalSMA<=1 || InpFastEMA>=InpSlowEMA)
{
Print("Wrong input parameters");
ExtParameters=false;
return(INIT_FAILED);
}
else
ExtParameters=true;
//--- initialization done
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Moving Average of Oscillator |
//+------------------------------------------------------------------+
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 i,limit;
//---
if(rates_total<=InpSignalSMA || !ExtParameters)
return(0);
//--- last counted bar will be recounted
limit=rates_total-prev_calculated;
if(prev_calculated>0)
limit++;
//--- macd counted in the 1-st buffer
for(i=0; i<limit; i++)
ExtMacdBuffer[i]=iMA(NULL,0,InpFastEMA,0,MODE_EMA,PRICE_CLOSE,i)-
iMA(NULL,0,InpSlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//--- signal line counted in the 2-nd buffer
SimpleMAOnBuffer(rates_total,prev_calculated,0,InpSignalSMA,ExtMacdBuffer,ExtSignalBuffer);
//--- main loop
for(i=0; i<limit; i++)
ExtOsmaBuffer[i]=ExtMacdBuffer[i]-ExtSignalBuffer[i];
//--- done
return(0);
}
//+------------------------------------------------------------------+
+239
View File
@@ -0,0 +1,239 @@
//+------------------------------------------------------------------+
//| Parabolic.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Parabolic Stop-And-Reversal system"
#property strict
//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Lime
//--- input parameters
input double InpSARStep=0.02; // Step
input double InpSARMaximum=0.2; // Maximum
//---- buffers
double ExtSARBuffer[];
//--- global variables
double ExtSarStep;
double ExtSarMaximum;
int ExtLastReverse;
bool ExtDirectionLong;
double ExtLastStep,ExtLastEP,ExtLastSAR;
double ExtLastHigh,ExtLastLow;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit()
{
//--- checking input data
if(InpSARStep<0.0)
{
ExtSarStep=0.02;
Print("Input parametr InpSARStep has incorrect value. Indicator will use value ",
ExtSarStep," for calculations.");
}
else
ExtSarStep=InpSARStep;
if(InpSARMaximum<0.0)
{
ExtSarMaximum=0.2;
Print("Input parametr InpSARMaximum has incorrect value. Indicator will use value ",
ExtSarMaximum," for calculations.");
}
else
ExtSarMaximum=InpSARMaximum;
//--- drawing settings
IndicatorDigits(Digits);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,159);
//---- indicator buffers
SetIndexBuffer(0,ExtSARBuffer);
//--- set short name
IndicatorShortName("SAR("+DoubleToString(ExtSarStep,2)+","+DoubleToString(ExtSarMaximum,2)+")");
//--- set global variables
ExtLastReverse=0;
ExtDirectionLong=false;
ExtLastStep=ExtLastEP=ExtLastSAR=0.0;
ExtLastHigh=ExtLastLow=0.0;
//----
}
//+------------------------------------------------------------------+
//| Parabolic SAR |
//+------------------------------------------------------------------+
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[])
{
bool dir_long;
double last_high,last_low,ep,sar,step;
int i;
//--- check for minimum rates count
if(rates_total<3)
return(0);
//--- counting from 0 to rates_total
ArraySetAsSeries(ExtSARBuffer,false);
ArraySetAsSeries(high,false);
ArraySetAsSeries(low,false);
//--- detect current position for calculations
i=prev_calculated-1;
//--- calculations from start?
if(i<1)
{
ExtLastReverse=0;
dir_long=true;
step=ExtSarStep;
last_high=-10000000.0;
last_low=10000000.0;
sar=0;
i=1;
while(i<rates_total-1)
{
ExtLastReverse=i;
if(last_low>low[i])
last_low=low[i];
if(last_high<high[i])
last_high=high[i];
if(high[i]>high[i-1] && low[i]>low[i-1])
break;
if(high[i]<high[i-1] && low[i]<low[i-1])
{
dir_long=false;
break;
}
i++;
}
//--- initialize with zero
ArrayInitialize(ExtSARBuffer,0.0);
//--- go check
if(dir_long)
{
ExtSARBuffer[i]=low[i-1];
ep=high[i];
}
else
{
ExtSARBuffer[i]=high[i-1];
ep=low[i];
}
i++;
}
else
{
//--- calculations to be continued. restore last values
i=ExtLastReverse;
step=ExtLastStep;
dir_long=ExtDirectionLong;
last_high=ExtLastHigh;
last_low=ExtLastLow;
ep=ExtLastEP;
sar=ExtLastSAR;
}
//---main cycle
while(i<rates_total)
{
//--- check for reverse
if(dir_long && low[i]<ExtSARBuffer[i-1])
{
SaveLastReverse(i,true,step,low[i],last_high,ep,sar);
step=ExtSarStep;
dir_long=false;
ep=low[i];
last_low=low[i];
ExtSARBuffer[i++]=last_high;
continue;
}
if(!dir_long && high[i]>ExtSARBuffer[i-1])
{
SaveLastReverse(i,false,step,last_low,high[i],ep,sar);
step=ExtSarStep;
dir_long=true;
ep=high[i];
last_high=high[i];
ExtSARBuffer[i++]=last_low;
continue;
}
//---
sar=ExtSARBuffer[i-1]+step*(ep-ExtSARBuffer[i-1]);
//--- LONG?
if(dir_long)
{
if(ep<high[i])
{
if((step+ExtSarStep)<=ExtSarMaximum)
step+=ExtSarStep;
}
if(high[i]<high[i-1] && i==2)
sar=ExtSARBuffer[i-1];
if(sar>low[i-1])
sar=low[i-1];
if(sar>low[i-2])
sar=low[i-2];
if(sar>low[i])
{
SaveLastReverse(i,true,step,low[i],last_high,ep,sar);
step=ExtSarStep; dir_long=false; ep=low[i];
last_low=low[i];
ExtSARBuffer[i++]=last_high;
continue;
}
if(ep<high[i])
ep=last_high=high[i];
}
else // SHORT
{
if(ep>low[i])
{
if((step+ExtSarStep)<=ExtSarMaximum)
step+=ExtSarStep;
}
if(low[i]<low[i-1] && i==2)
sar=ExtSARBuffer[i-1];
if(sar<high[i-1])
sar=high[i-1];
if(sar<high[i-2])
sar=high[i-2];
if(sar<high[i])
{
SaveLastReverse(i,false,step,last_low,high[i],ep,sar);
step=ExtSarStep;
dir_long=true;
ep=high[i];
last_high=high[i];
ExtSARBuffer[i++]=last_low;
continue;
}
if(ep>low[i])
ep=last_low=low[i];
}
ExtSARBuffer[i++]=sar;
}
//---- OnCalculate done. Return new prev_calculated.
return(rates_total);
}
//+------------------------------------------------------------------+
//| save last values to continue further calculations |
//+------------------------------------------------------------------+
void SaveLastReverse(int reverse,bool dir,double step,double last_low,double last_high,double ep,double sar)
{
ExtLastReverse=reverse;
if(ExtLastReverse<2)
ExtLastReverse=2;
ExtDirectionLong=dir;
ExtLastStep=step;
ExtLastLow=last_low;
ExtLastHigh=last_high;
ExtLastEP=ep;
ExtLastSAR=sar;
}
//+------------------------------------------------------------------+
+333
View File
@@ -0,0 +1,333 @@
//------------------------------------------------------------------
#property copyright "www.forex-station.com"
#property link "www.forex-station.com"
//------------------------------------------------------------------
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 clrLimeGreen
#property indicator_color2 clrOrange
#property indicator_color3 clrLimeGreen
#property indicator_color4 clrOrange
#property indicator_width3 3
#property indicator_width4 3
#property strict
//
//
//
//
//
extern ENUM_TIMEFRAMES TimeFrame = PERIOD_CURRENT; // Time frame to use
extern double AccStep = 0.02; // Accumulation step
extern double AccLimit = 0.2; // Accumulation limit
extern ENUM_APPLIED_PRICE PriceHigh = PRICE_CLOSE; // Psar high price
extern ENUM_APPLIED_PRICE PriceLow = PRICE_CLOSE; // Psar low price
extern int PriceSmoothing = 0; // Psar smoothing
extern ENUM_MA_METHOD PriceSmoothingMethod = MODE_SMA; // Psar ma smoothing method
extern bool alertsOn = true; // Alerts on?
extern bool alertsOnCurrent = false; // Alerts on current open bar?
extern bool alertsMessage = true; // Alerts message?
extern bool alertsSound = false; // Alerts sound?
extern bool alertsEmail = false; // Alerts email?
extern bool alertsNotify = false; // Alerts notification by phone?
extern bool DrawAsDots = true; // Draw as dots or solid line
extern int Shift = 0; // Shift
double sarUp[];
double sarDn[];
double saraUp[];
double saraDn[];
int timeFrame;
string indicatorFileName;
bool returnBars;
//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//
int init()
{
int type = DRAW_LINE; if (DrawAsDots) type = DRAW_ARROW;
SetIndexBuffer(0,sarUp); SetIndexStyle(0,type); SetIndexArrow(0,159);
SetIndexBuffer(1,sarDn); SetIndexStyle(1,type); SetIndexArrow(1,159);
SetIndexBuffer(2,saraUp); SetIndexStyle(2,DRAW_ARROW); SetIndexArrow(2,159);
SetIndexBuffer(3,saraDn); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,159);
//
//
//
//
//
indicatorFileName = WindowExpertName();
returnBars = (TimeFrame==-99);
TimeFrame = MathMax(TimeFrame,_Period);
PriceSmoothing = MathMax(PriceSmoothing,1);
for (int i=0; i<4; i++) SetIndexShift(i,Shift*timeFrame/Period());
//
//
//
//
//
return(0);
}
int deinit() { return(0); }
//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//
int start()
{
int i,counted_bars=IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars>0) counted_bars--;
int limit = MathMin(Bars-counted_bars,Bars-1);
if (returnBars) { sarUp[0] = limit+1; return(0); }
//
//
//
//
//
if (TimeFrame == Period())
{
for(i = limit; i >= 0; i--)
{
double sarClose;
double sarOpen;
double sarPosition;
double sarChange;
double pHigh = iMA(NULL,0,PriceSmoothing,0,PriceSmoothingMethod,PriceHigh,i);
double pLow = iMA(NULL,0,PriceSmoothing,0,PriceSmoothingMethod,PriceLow ,i);
iParabolic(fmax(pHigh,pLow),fmin(pHigh,pLow),AccStep,AccLimit,sarClose,sarOpen,sarPosition,sarChange,i);
sarUp[i] = EMPTY_VALUE;
sarDn[i] = EMPTY_VALUE;
saraUp[i] = EMPTY_VALUE;
saraDn[i] = EMPTY_VALUE;
if (sarPosition==1)
sarUp[i] = sarClose;
else sarDn[i] = sarClose;
if (sarChange!=0)
if (sarChange==1)
saraUp[i] = sarClose;
else saraDn[i] = sarClose;
}
manageAlerts();
return(0);
}
//
//
//
//
//
limit = (int)fmax(limit,fmin(Bars-1,iCustom(NULL,TimeFrame,indicatorFileName,-99,0,0)*TimeFrame/Period()));
for(i=limit; i>=0; i--)
{
int y = iBarShift(NULL,TimeFrame,Time[i]);
int x = iBarShift(NULL,TimeFrame,Time[i+1]);
sarUp[i] = iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,AccStep,AccLimit,PriceHigh,PriceLow,PriceSmoothing,PriceSmoothingMethod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,0,0,y);
sarDn[i] = iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,AccStep,AccLimit,PriceHigh,PriceLow,PriceSmoothing,PriceSmoothingMethod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,0,1,y);
saraUp[i] = EMPTY_VALUE;
saraDn[i] = EMPTY_VALUE;
if (x!=y)
{
saraUp[i] = iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,AccStep,AccLimit,PriceHigh,PriceLow,PriceSmoothing,PriceSmoothingMethod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,0,2,y);
saraDn[i] = iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,AccStep,AccLimit,PriceHigh,PriceLow,PriceSmoothing,PriceSmoothingMethod,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,0,3,y);
}
}
return(0);
}
//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//
double work[][7];
#define _high 0
#define _low 1
#define _ohigh 2
#define _olow 3
#define _open 4
#define _position 5
#define _af 6
void iParabolic(double high, double low, double step, double limit, double& pClose, double& pOpen, double& pPosition, double& pChange, int i)
{
if (ArrayRange(work,0)!=Bars) ArrayResize(work,Bars); i = Bars-i-1;
//
//
//
//
//
pChange = 0;
work[i][_ohigh] = high;
work[i][_olow] = low;
if (i<1)
{
work[i][_high] = high;
work[i][_low] = low;
work[i][_open] = high;
work[i][_position] = -1;
return;
}
work[i][_open] = work[i-1][_open];
work[i][_af] = work[i-1][_af];
work[i][_position] = work[i-1][_position];
work[i][_high] = fmax(work[i-1][_high],high);
work[i][_low] = fmin(work[i-1][_low] ,low );
//
//
//
//
//
if (work[i][_position] == 1)
if (low<=work[i][_open])
{
work[i][_position] = -1;
pChange = -1;
pClose = work[i][_high];
work[i][_high] = high;
work[i][_low] = low;
work[i][_af] = step;
work[i][_open] = pClose + work[i][_af]*(work[i][_low]-pClose);
if (work[i][_open]<work[i ][_ohigh]) work[i][_open] = work[i ][_ohigh];
if (work[i][_open]<work[i-1][_ohigh]) work[i][_open] = work[i-1][_ohigh];
}
else
{
pClose = work[i][_open];
if (work[i][_high]>work[i-1][_high] && work[i][_af]<limit) work[i][_af] = fmin(work[i][_af]+step,limit);
work[i][_open] = pClose + work[i][_af]*(work[i][_high]-pClose);
if (work[i][_open]>work[i ][_olow]) work[i][_open] = work[i ][_olow];
if (work[i][_open]>work[i-1][_olow]) work[i][_open] = work[i-1][_olow];
}
else
if (high>=work[i][_open])
{
work[i][_position] = 1;
pChange = 1;
pClose = work[i][_low];
work[i][_low] = low;
work[i][_high] = high;
work[i][_af] = step;
work[i][_open] = pClose + work[i][_af]*(work[i][_high]-pClose);
if (work[i][_open]>work[i ][_olow]) work[i][_open] = work[i ][_olow];
if (work[i][_open]>work[i-1][_olow]) work[i][_open] = work[i-1][_olow];
}
else
{
pClose = work[i][_open];
if (work[i][_low]<work[i-1][_low] && work[i][_af]<limit) work[i][_af] = fmin(work[i][_af]+step,limit);
work[i][_open] = pClose + work[i][_af]*(work[i][_low]-pClose);
if (work[i][_open]<work[i ][_ohigh]) work[i][_open] = work[i ][_ohigh];
if (work[i][_open]<work[i-1][_ohigh]) work[i][_open] = work[i-1][_ohigh];
}
//
//
//
//
//
pOpen = work[i][_open];
pPosition = work[i][_position];
}
//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
//
void manageAlerts()
{
if (alertsOn)
{
int whichBar = 1; if (alertsOnCurrent) whichBar = 0;
if (saraUp[whichBar] != EMPTY_VALUE || saraDn[whichBar] != EMPTY_VALUE)
{
if (saraUp[whichBar] != EMPTY_VALUE) doAlert(whichBar,"up");
if (saraDn[whichBar] != EMPTY_VALUE) doAlert(whichBar,"down");
}
}
}
//
//
//
//
//
void doAlert(int forBar, string doWhat)
{
static string previousAlert="nothing";
static datetime previousTime;
string message;
if (previousAlert != doWhat || previousTime != Time[forBar]) {
previousAlert = doWhat;
previousTime = Time[forBar];
//
//
//
//
//
message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," ",timeFrameToString(_Period)+" Parabolic sar trend changed to ",doWhat);
if (alertsMessage) Alert(message);
if (alertsEmail) SendMail(StringConcatenate(Symbol(),"parabolic sar"),message);
if (alertsNotify) SendNotification(message);
if (alertsSound) PlaySound("alert2.wav");
}
}
//+-------------------------------------------------------------------
//|
//+-------------------------------------------------------------------
//
//
//
//
//
string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};
int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};
string timeFrameToString(int tf)
{
for (int i=ArraySize(iTfTable)-1; i>=0; i--)
if (tf==iTfTable[i]) return(sTfTable[i]);
return("");
}
+133
View File
@@ -0,0 +1,133 @@
//+------------------------------------------------------------------+
//| RSI.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Relative Strength Index"
#property strict
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_level1 30.0
#property indicator_level2 70.0
#property indicator_levelcolor clrSilver
#property indicator_levelstyle STYLE_DOT
//--- input parameters
input int InpRSIPeriod=14; // RSI Period
//--- buffers
double ExtRSIBuffer[];
double ExtPosBuffer[];
double ExtNegBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(void)
{
string short_name;
//--- 2 additional buffers are used for counting.
IndicatorBuffers(3);
SetIndexBuffer(1,ExtPosBuffer);
SetIndexBuffer(2,ExtNegBuffer);
//--- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtRSIBuffer);
//--- name for DataWindow and indicator subwindow label
short_name="RSI("+string(InpRSIPeriod)+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//--- check for input
if(InpRSIPeriod<2)
{
Print("Incorrect value for input variable InpRSIPeriod = ",InpRSIPeriod);
return(INIT_FAILED);
}
//---
SetIndexDrawBegin(0,InpRSIPeriod);
//--- initialization done
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Relative Strength Index |
//+------------------------------------------------------------------+
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 i,pos;
double diff;
//---
if(Bars<=InpRSIPeriod || InpRSIPeriod<2)
return(0);
//--- counting from 0 to rates_total
ArraySetAsSeries(ExtRSIBuffer,false);
ArraySetAsSeries(ExtPosBuffer,false);
ArraySetAsSeries(ExtNegBuffer,false);
ArraySetAsSeries(close,false);
//--- preliminary calculations
pos=prev_calculated-1;
if(pos<=InpRSIPeriod)
{
//--- first RSIPeriod values of the indicator are not calculated
ExtRSIBuffer[0]=0.0;
ExtPosBuffer[0]=0.0;
ExtNegBuffer[0]=0.0;
double sump=0.0;
double sumn=0.0;
for(i=1; i<=InpRSIPeriod; i++)
{
ExtRSIBuffer[i]=0.0;
ExtPosBuffer[i]=0.0;
ExtNegBuffer[i]=0.0;
diff=close[i]-close[i-1];
if(diff>0)
sump+=diff;
else
sumn-=diff;
}
//--- calculate first visible value
ExtPosBuffer[InpRSIPeriod]=sump/InpRSIPeriod;
ExtNegBuffer[InpRSIPeriod]=sumn/InpRSIPeriod;
if(ExtNegBuffer[InpRSIPeriod]!=0.0)
ExtRSIBuffer[InpRSIPeriod]=100.0-(100.0/(1.0+ExtPosBuffer[InpRSIPeriod]/ExtNegBuffer[InpRSIPeriod]));
else
{
if(ExtPosBuffer[InpRSIPeriod]!=0.0)
ExtRSIBuffer[InpRSIPeriod]=100.0;
else
ExtRSIBuffer[InpRSIPeriod]=50.0;
}
//--- prepare the position value for main calculation
pos=InpRSIPeriod+1;
}
//--- the main loop of calculations
for(i=pos; i<rates_total && !IsStopped(); i++)
{
diff=close[i]-close[i-1];
ExtPosBuffer[i]=(ExtPosBuffer[i-1]*(InpRSIPeriod-1)+(diff>0.0?diff:0.0))/InpRSIPeriod;
ExtNegBuffer[i]=(ExtNegBuffer[i-1]*(InpRSIPeriod-1)+(diff<0.0?-diff:0.0))/InpRSIPeriod;
if(ExtNegBuffer[i]!=0.0)
ExtRSIBuffer[i]=100.0-100.0/(1+ExtPosBuffer[i]/ExtNegBuffer[i]);
else
{
if(ExtPosBuffer[i]!=0.0)
ExtRSIBuffer[i]=100.0;
else
ExtRSIBuffer[i]=50.0;
}
}
//---
return(rates_total);
}
//+------------------------------------------------------------------+
+157
View File
@@ -0,0 +1,157 @@
//+------------------------------------------------------------------+
//| Stochastic.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Stochastic Oscillator"
#property strict
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 2
#property indicator_color1 LightSeaGreen
#property indicator_color2 Red
#property indicator_level1 20.0
#property indicator_level2 80.0
#property indicator_levelcolor clrSilver
#property indicator_levelstyle STYLE_DOT
//--- input parameters
input int InpKPeriod=5; // K Period
input int InpDPeriod=3; // D Period
input int InpSlowing=3; // Slowing
//--- buffers
double ExtMainBuffer[];
double ExtSignalBuffer[];
double ExtHighesBuffer[];
double ExtLowesBuffer[];
//---
int draw_begin1=0;
int draw_begin2=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(void)
{
string short_name;
//--- 2 additional buffers are used for counting.
IndicatorBuffers(4);
SetIndexBuffer(2, ExtHighesBuffer);
SetIndexBuffer(3, ExtLowesBuffer);
//--- indicator lines
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0, ExtMainBuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1, ExtSignalBuffer);
//--- name for DataWindow and indicator subwindow label
short_name="Sto("+IntegerToString(InpKPeriod)+","+IntegerToString(InpDPeriod)+","+IntegerToString(InpSlowing)+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
SetIndexLabel(1,"Signal");
//---
draw_begin1=InpKPeriod+InpSlowing;
draw_begin2=draw_begin1+InpDPeriod;
SetIndexDrawBegin(0,draw_begin1);
SetIndexDrawBegin(1,draw_begin2);
//--- initialization done
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Stochastic oscillator |
//+------------------------------------------------------------------+
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 i,k,pos;
//--- check for bars count
if(rates_total<=InpKPeriod+InpDPeriod+InpSlowing)
return(0);
//--- counting from 0 to rates_total
ArraySetAsSeries(ExtMainBuffer,false);
ArraySetAsSeries(ExtSignalBuffer,false);
ArraySetAsSeries(ExtHighesBuffer,false);
ArraySetAsSeries(ExtLowesBuffer,false);
ArraySetAsSeries(low,false);
ArraySetAsSeries(high,false);
ArraySetAsSeries(close,false);
//---
pos=InpKPeriod-1;
if(pos+1<prev_calculated)
pos=prev_calculated-2;
else
{
for(i=0; i<pos; i++)
{
ExtLowesBuffer[i]=0.0;
ExtHighesBuffer[i]=0.0;
}
}
//--- calculate HighesBuffer[] and ExtHighesBuffer[]
for(i=pos; i<rates_total && !IsStopped(); i++)
{
double dmin=1000000.0;
double dmax=-1000000.0;
for(k=i-InpKPeriod+1; k<=i; k++)
{
if(dmin>low[k])
dmin=low[k];
if(dmax<high[k])
dmax=high[k];
}
ExtLowesBuffer[i]=dmin;
ExtHighesBuffer[i]=dmax;
}
//--- %K line
pos=InpKPeriod-1+InpSlowing-1;
if(pos+1<prev_calculated)
pos=prev_calculated-2;
else
{
for(i=0; i<pos; i++)
ExtMainBuffer[i]=0.0;
}
//--- main cycle
for(i=pos; i<rates_total && !IsStopped(); i++)
{
double sumlow=0.0;
double sumhigh=0.0;
for(k=(i-InpSlowing+1); k<=i; k++)
{
sumlow +=(close[k]-ExtLowesBuffer[k]);
sumhigh+=(ExtHighesBuffer[k]-ExtLowesBuffer[k]);
}
if(sumhigh==0.0)
ExtMainBuffer[i]=100.0;
else
ExtMainBuffer[i]=sumlow/sumhigh*100.0;
}
//--- signal
pos=InpDPeriod-1;
if(pos+1<prev_calculated)
pos=prev_calculated-2;
else
{
for(i=0; i<pos; i++)
ExtSignalBuffer[i]=0.0;
}
for(i=pos; i<rates_total && !IsStopped(); i++)
{
double sum=0.0;
for(k=0; k<InpDPeriod; k++)
sum+=ExtMainBuffer[i-k];
ExtSignalBuffer[i]=sum/InpDPeriod;
}
//--- OnCalculate done. Return new prev_calculated.
return(rates_total);
}
//+------------------------------------------------------------------+
+257
View File
@@ -0,0 +1,257 @@
//+------------------------------------------------------------------+
//| ZigZag.mq4 |
//| Copyright 2006-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2006-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property strict
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- indicator parameters
input int InpDepth=12; // Depth
input int InpDeviation=5; // Deviation
input int InpBackstep=3; // Backstep
//---- indicator buffers
double ExtZigzagBuffer[];
double ExtHighBuffer[];
double ExtLowBuffer[];
//--- globals
int ExtLevel=3; // recounting's depth of extremums
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
if(InpBackstep>=InpDepth)
{
Print("Backstep cannot be greater or equal to Depth");
return(INIT_FAILED);
}
//--- 2 additional buffers
IndicatorBuffers(3);
//---- drawing settings
SetIndexStyle(0,DRAW_SECTION);
//---- indicator buffers
SetIndexBuffer(0,ExtZigzagBuffer);
SetIndexBuffer(1,ExtHighBuffer);
SetIndexBuffer(2,ExtLowBuffer);
SetIndexEmptyValue(0,0.0);
//---- indicator short name
IndicatorShortName("ZigZag("+string(InpDepth)+","+string(InpDeviation)+","+string(InpBackstep)+")");
//---- initialization done
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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 i,limit,counterZ,whatlookfor=0;
int back,pos,lasthighpos=0,lastlowpos=0;
double extremum;
double curlow=0.0,curhigh=0.0,lasthigh=0.0,lastlow=0.0;
//--- check for history and inputs
if(rates_total<InpDepth || InpBackstep>=InpDepth)
return(0);
//--- first calculations
if(prev_calculated==0)
limit=InitializeAll();
else
{
//--- find first extremum in the depth ExtLevel or 100 last bars
i=counterZ=0;
while(counterZ<ExtLevel && i<100)
{
if(ExtZigzagBuffer[i]!=0.0)
counterZ++;
i++;
}
//--- no extremum found - recounting all from begin
if(counterZ==0)
limit=InitializeAll();
else
{
//--- set start position to found extremum position
limit=i-1;
//--- what kind of extremum?
if(ExtLowBuffer[i]!=0.0)
{
//--- low extremum
curlow=ExtLowBuffer[i];
//--- will look for the next high extremum
whatlookfor=1;
}
else
{
//--- high extremum
curhigh=ExtHighBuffer[i];
//--- will look for the next low extremum
whatlookfor=-1;
}
//--- clear the rest data
for(i=limit-1; i>=0; i--)
{
ExtZigzagBuffer[i]=0.0;
ExtLowBuffer[i]=0.0;
ExtHighBuffer[i]=0.0;
}
}
}
//--- main loop
for(i=limit; i>=0; i--)
{
//--- find lowest low in depth of bars
extremum=low[iLowest(NULL,0,MODE_LOW,InpDepth,i)];
//--- this lowest has been found previously
if(extremum==lastlow)
extremum=0.0;
else
{
//--- new last low
lastlow=extremum;
//--- discard extremum if current low is too high
if(low[i]-extremum>InpDeviation*Point)
extremum=0.0;
else
{
//--- clear previous extremums in backstep bars
for(back=1; back<=InpBackstep; back++)
{
pos=i+back;
if(ExtLowBuffer[pos]!=0 && ExtLowBuffer[pos]>extremum)
ExtLowBuffer[pos]=0.0;
}
}
}
//--- found extremum is current low
if(low[i]==extremum)
ExtLowBuffer[i]=extremum;
else
ExtLowBuffer[i]=0.0;
//--- find highest high in depth of bars
extremum=high[iHighest(NULL,0,MODE_HIGH,InpDepth,i)];
//--- this highest has been found previously
if(extremum==lasthigh)
extremum=0.0;
else
{
//--- new last high
lasthigh=extremum;
//--- discard extremum if current high is too low
if(extremum-high[i]>InpDeviation*Point)
extremum=0.0;
else
{
//--- clear previous extremums in backstep bars
for(back=1; back<=InpBackstep; back++)
{
pos=i+back;
if(ExtHighBuffer[pos]!=0 && ExtHighBuffer[pos]<extremum)
ExtHighBuffer[pos]=0.0;
}
}
}
//--- found extremum is current high
if(high[i]==extremum)
ExtHighBuffer[i]=extremum;
else
ExtHighBuffer[i]=0.0;
}
//--- final cutting
if(whatlookfor==0)
{
lastlow=0.0;
lasthigh=0.0;
}
else
{
lastlow=curlow;
lasthigh=curhigh;
}
for(i=limit; i>=0; i--)
{
switch(whatlookfor)
{
case 0: // look for peak or lawn
if(lastlow==0.0 && lasthigh==0.0)
{
if(ExtHighBuffer[i]!=0.0)
{
lasthigh=High[i];
lasthighpos=i;
whatlookfor=-1;
ExtZigzagBuffer[i]=lasthigh;
}
if(ExtLowBuffer[i]!=0.0)
{
lastlow=Low[i];
lastlowpos=i;
whatlookfor=1;
ExtZigzagBuffer[i]=lastlow;
}
}
break;
case 1: // look for peak
if(ExtLowBuffer[i]!=0.0 && ExtLowBuffer[i]<lastlow && ExtHighBuffer[i]==0.0)
{
ExtZigzagBuffer[lastlowpos]=0.0;
lastlowpos=i;
lastlow=ExtLowBuffer[i];
ExtZigzagBuffer[i]=lastlow;
}
if(ExtHighBuffer[i]!=0.0 && ExtLowBuffer[i]==0.0)
{
lasthigh=ExtHighBuffer[i];
lasthighpos=i;
ExtZigzagBuffer[i]=lasthigh;
whatlookfor=-1;
}
break;
case -1: // look for lawn
if(ExtHighBuffer[i]!=0.0 && ExtHighBuffer[i]>lasthigh && ExtLowBuffer[i]==0.0)
{
ExtZigzagBuffer[lasthighpos]=0.0;
lasthighpos=i;
lasthigh=ExtHighBuffer[i];
ExtZigzagBuffer[i]=lasthigh;
}
if(ExtLowBuffer[i]!=0.0 && ExtHighBuffer[i]==0.0)
{
lastlow=ExtLowBuffer[i];
lastlowpos=i;
ExtZigzagBuffer[i]=lastlow;
whatlookfor=1;
}
break;
}
}
//--- done
return(rates_total);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int InitializeAll()
{
ArrayInitialize(ExtZigzagBuffer,0.0);
ArrayInitialize(ExtHighBuffer,0.0);
ArrayInitialize(ExtLowBuffer,0.0);
//--- first counting position
return(Bars-InpDepth);
}
//+------------------------------------------------------------------+
+249
View File
@@ -0,0 +1,249 @@
//+------------------------------------------------------------------+
//| iExposure.mq4 |
//| Copyright 2007-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2007-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_minimum 0.0
#property indicator_maximum 0.1
#define SYMBOLS_MAX 1024
#define DEALS 0
#define BUY_LOTS 1
#define BUY_PRICE 2
#define SELL_LOTS 3
#define SELL_PRICE 4
#define NET_LOTS 5
#define PROFIT 6
input color InpColor=LightSeaGreen; // Text color
string ExtName="Exposure";
string ExtSymbols[SYMBOLS_MAX];
int ExtSymbolsTotal=0;
double ExtSymbolsSummaries[SYMBOLS_MAX][7];
int ExtLines=-1;
string ExtCols[8]={"Symbol",
"Deals",
"Buy lots",
"Buy price",
"Sell lots",
"Sell price",
"Net lots",
"Profit"};
int ExtShifts[8]={ 10, 80, 130, 180, 260, 310, 390, 460 };
int ExtVertShift=14;
double ExtMapBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit()
{
IndicatorShortName(ExtName);
SetIndexBuffer(0,ExtMapBuffer);
SetIndexStyle(0,DRAW_NONE);
IndicatorDigits(0);
SetIndexEmptyValue(0,0.0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
int windex=WindowFind(ExtName);
if(windex>0)
ObjectsDeleteAll(windex);
}
//+------------------------------------------------------------------+
//| 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[])
{
string name;
int i,col,line,windex=WindowFind(ExtName);
//----
if(windex<0)
return(rates_total);
//---- header line
if(ExtLines<0)
{
for(col=0; col<8; col++)
{
name="Head_"+string(col);
if(ObjectCreate(name,OBJ_LABEL,windex,0,0))
{
ObjectSet(name,OBJPROP_XDISTANCE,ExtShifts[col]);
ObjectSet(name,OBJPROP_YDISTANCE,ExtVertShift);
ObjectSetText(name,ExtCols[col],9,"Arial",InpColor);
}
}
ExtLines=0;
}
//----
ArrayInitialize(ExtSymbolsSummaries,0.0);
int total=Analyze();
if(total>0)
{
line=0;
for(i=0; i<ExtSymbolsTotal; i++)
{
if(ExtSymbolsSummaries[i][DEALS]<=0) continue;
line++;
//---- add line
if(line>ExtLines)
{
int y_dist=ExtVertShift*(line+1)+1;
for(col=0; col<8; col++)
{
name="Line_"+string(line)+"_"+string(col);
if(ObjectCreate(name,OBJ_LABEL,windex,0,0))
{
ObjectSet(name,OBJPROP_XDISTANCE,ExtShifts[col]);
ObjectSet(name,OBJPROP_YDISTANCE,y_dist);
}
}
ExtLines++;
}
//---- set line
int digits=(int)MarketInfo(ExtSymbols[i],MODE_DIGITS);
double buy_lots=ExtSymbolsSummaries[i][BUY_LOTS];
double sell_lots=ExtSymbolsSummaries[i][SELL_LOTS];
double buy_price=0.0;
double sell_price=0.0;
if(buy_lots!=0) buy_price=ExtSymbolsSummaries[i][BUY_PRICE]/buy_lots;
if(sell_lots!=0) sell_price=ExtSymbolsSummaries[i][SELL_PRICE]/sell_lots;
name="Line_"+string(line)+"_0";
ObjectSetText(name,ExtSymbols[i],9,"Arial",InpColor);
name="Line_"+string(line)+"_1";
ObjectSetText(name,DoubleToStr(ExtSymbolsSummaries[i][DEALS],0),9,"Arial",InpColor);
name="Line_"+string(line)+"_2";
ObjectSetText(name,DoubleToStr(buy_lots,2),9,"Arial",InpColor);
name="Line_"+string(line)+"_3";
ObjectSetText(name,DoubleToStr(buy_price,digits),9,"Arial",InpColor);
name="Line_"+string(line)+"_4";
ObjectSetText(name,DoubleToStr(sell_lots,2),9,"Arial",InpColor);
name="Line_"+string(line)+"_5";
ObjectSetText(name,DoubleToStr(sell_price,digits),9,"Arial",InpColor);
name="Line_"+string(line)+"_6";
ObjectSetText(name,DoubleToStr(buy_lots-sell_lots,2),9,"Arial",InpColor);
name="Line_"+string(line)+"_7";
ObjectSetText(name,DoubleToStr(ExtSymbolsSummaries[i][PROFIT],2),9,"Arial",InpColor);
}
}
//---- remove lines
if(total<ExtLines)
{
for(line=ExtLines; line>total; line--)
{
name="Line_"+string(line)+"_0";
ObjectSetText(name,"");
name="Line_"+string(line)+"_1";
ObjectSetText(name,"");
name="Line_"+string(line)+"_2";
ObjectSetText(name,"");
name="Line_"+string(line)+"_3";
ObjectSetText(name,"");
name="Line_"+string(line)+"_4";
ObjectSetText(name,"");
name="Line_"+string(line)+"_5";
ObjectSetText(name,"");
name="Line_"+string(line)+"_6";
ObjectSetText(name,"");
name="Line_"+string(line)+"_7";
ObjectSetText(name,"");
}
}
//---- to avoid minimum==maximum
ExtMapBuffer[Bars-1]=-1;
//----
return(rates_total);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Analyze()
{
double profit;
int i,index,type,total=OrdersTotal();
//----
for(i=0; i<total; i++)
{
if(!OrderSelect(i,SELECT_BY_POS)) continue;
type=OrderType();
if(type!=OP_BUY && type!=OP_SELL) continue;
index=SymbolsIndex(OrderSymbol());
if(index<0 || index>=SYMBOLS_MAX) continue;
//----
ExtSymbolsSummaries[index][DEALS]++;
profit=OrderProfit()+OrderCommission()+OrderSwap();
ExtSymbolsSummaries[index][PROFIT]+=profit;
if(type==OP_BUY)
{
ExtSymbolsSummaries[index][BUY_LOTS]+=OrderLots();
ExtSymbolsSummaries[index][BUY_PRICE]+=OrderOpenPrice()*OrderLots();
}
else
{
ExtSymbolsSummaries[index][SELL_LOTS]+=OrderLots();
ExtSymbolsSummaries[index][SELL_PRICE]+=OrderOpenPrice()*OrderLots();
}
}
//----
total=0;
for(i=0; i<ExtSymbolsTotal; i++)
{
if(ExtSymbolsSummaries[i][DEALS]>0) total++;
}
//----
return(total);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int SymbolsIndex(string SymbolName)
{
bool found=false;
int i;
//----
for(i=0; i<ExtSymbolsTotal; i++)
{
if(SymbolName==ExtSymbols[i])
{
found=true;
break;
}
}
//----
if(found)
return(i);
if(ExtSymbolsTotal>=SYMBOLS_MAX)
return(-1);
//----
i=ExtSymbolsTotal;
ExtSymbolsTotal++;
ExtSymbols[i]=SymbolName;
ExtSymbolsSummaries[i][DEALS]=0;
ExtSymbolsSummaries[i][BUY_LOTS]=0;
ExtSymbolsSummaries[i][BUY_PRICE]=0;
ExtSymbolsSummaries[i][SELL_LOTS]=0;
ExtSymbolsSummaries[i][SELL_PRICE]=0;
ExtSymbolsSummaries[i][NET_LOTS]=0;
ExtSymbolsSummaries[i][PROFIT]=0;
//----
return(i);
}
//+------------------------------------------------------------------+