Initial commit: MQL5 Indicators Collection (MetaTrader 5) - Part 1
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,22 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `18avgma.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,21 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `2XMA_Ichimoku_Oscillator.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,21 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `2XMA_Ichimoku_Oscillator_HTF.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,21 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `2XMA_Ichimoku_Signal.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 17 KiB |
@@ -0,0 +1,21 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `3_mas_market.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1,21 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `minions.3rulesmacd_signal.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,225 @@
|
||||
//+-------------------------------------------------------------------------------------+
|
||||
//| Minions.3RulesMACD_Signal.mq5 |
|
||||
//| (CC) Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License|
|
||||
//| http://www.MinionsLabs.com |
|
||||
//+-------------------------------------------------------------------------------------+
|
||||
|
||||
|
||||
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Descriptors |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "www.MinionsLabs.com"
|
||||
#property link "http://www.MinionsLabs.com"
|
||||
#property version "1.0"
|
||||
#property description "Minions in the quest for ideal MACD Crossovers using 3 rules"
|
||||
#property description " (BUY and SELL signals indicator)"
|
||||
#property description " "
|
||||
#property description "(CC) Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License"
|
||||
|
||||
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Indicator Settings |
|
||||
//+------------------------------------------------------------------+
|
||||
#property indicator_chart_window
|
||||
#property indicator_buffers 4
|
||||
#property indicator_plots 2
|
||||
|
||||
#property indicator_label1 "BUY"
|
||||
#property indicator_type1 DRAW_ARROW
|
||||
#property indicator_color1 clrDodgerBlue
|
||||
#property indicator_style1 STYLE_SOLID
|
||||
#property indicator_width1 1
|
||||
|
||||
#property indicator_label2 "SELL"
|
||||
#property indicator_type2 DRAW_ARROW
|
||||
#property indicator_color2 clrRed
|
||||
#property indicator_style2 STYLE_SOLID
|
||||
#property indicator_width2 1
|
||||
|
||||
|
||||
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Inputs from User Interface |
|
||||
//+------------------------------------------------------------------+
|
||||
input int inpMAFast=12; //Fast MA Period
|
||||
input int inpMASlow=26; //Slow MA Period
|
||||
input int inpSignal=9; //Signal Line Period
|
||||
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Global Variables |
|
||||
//+------------------------------------------------------------------+
|
||||
int bufferBuy_ID=0; // put names on buffers!
|
||||
int bufferSell_ID=1; //
|
||||
int bufferMACD_ID=2; //
|
||||
int bufferSignal_ID=3; //
|
||||
|
||||
double bufferBuy[]; // buffers for holding the data...
|
||||
double bufferSell[]; //
|
||||
double bufferMACD[]; //
|
||||
double bufferSignal[]; //
|
||||
|
||||
int hiMACD; // handle for the iMACD...
|
||||
|
||||
bool ruleBuy1=false; // holds the rule #1 cross for BUY
|
||||
bool ruleBuy2=false; // holds the rule #2 cross for BUY
|
||||
bool ruleSell1=false; // holds the rule #1 cross for SELL
|
||||
bool ruleSell2=false; // holds the rule #2 cross for SELL
|
||||
|
||||
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Custom indicator initialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit() {
|
||||
|
||||
SetIndexBuffer(bufferBuy_ID, bufferBuy, INDICATOR_DATA);
|
||||
SetIndexBuffer(bufferSell_ID, bufferSell, INDICATOR_DATA);
|
||||
SetIndexBuffer(bufferMACD_ID, bufferMACD, INDICATOR_DATA);
|
||||
SetIndexBuffer(bufferSignal_ID, bufferSignal, INDICATOR_DATA);
|
||||
|
||||
// prepare the arrows for the entry signals...
|
||||
PlotIndexSetInteger(bufferSell_ID,PLOT_ARROW,234);
|
||||
PlotIndexSetInteger(bufferBuy_ID,PLOT_ARROW,233);
|
||||
|
||||
PlotIndexSetInteger(bufferSell_ID,PLOT_ARROW_SHIFT,-10);
|
||||
PlotIndexSetInteger(bufferBuy_ID,PLOT_ARROW_SHIFT,10);
|
||||
|
||||
// create the signals... gets the handles for the indicators...
|
||||
hiMACD = iMACD( _Symbol, _Period, inpMAFast, inpMASlow, inpSignal, PRICE_CLOSE );
|
||||
|
||||
if (hiMACD==INVALID_HANDLE) {
|
||||
// tell about the failure and output the error code
|
||||
PrintFormat("Failed to create handle of the iMACD for the symbol %s/%s, error code %d", _Symbol, EnumToString(_Period), GetLastError());
|
||||
return(INIT_FAILED); //return as a failed operation...
|
||||
}
|
||||
|
||||
return(INIT_SUCCEEDED);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Custom indicator iteration function |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnCalculate(const int rates_total, // Total number of bars
|
||||
const int prev_calculated, // Previous calculated number of bars
|
||||
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;
|
||||
int startFromWhere;
|
||||
|
||||
if (prev_calculated==0) startFromWhere=1; // First Time! Start from the start! 1 is because the calculations need to address i-1, otherwise it would be 0
|
||||
else startFromWhere = prev_calculated-1; // set start equal to the last index in the arrays
|
||||
|
||||
|
||||
// fill the iMACD array with values, but only the values NOT ALREADY processed...
|
||||
// if FillArrayFromBuffer returns false, it means the information is nor ready yet, quit operation
|
||||
if (rates_total-prev_calculated > 0) {
|
||||
if (!FillArraysFromBuffers( bufferMACD, bufferSignal, hiMACD, (rates_total-prev_calculated))) { return(0); }
|
||||
}
|
||||
|
||||
|
||||
// processes the BUY and SELL signals
|
||||
for(i=startFromWhere; i<rates_total; i++) {
|
||||
|
||||
// start of the BUY signal - RULE #1...
|
||||
if ( (bufferMACD[i-1]>bufferSignal[i-1] && bufferMACD[i]<bufferSignal[i]) ) { //MACD crosses below Signal
|
||||
ruleBuy1=true; ruleBuy2=false;
|
||||
}
|
||||
// RULE BUY #2...
|
||||
if ( (bufferMACD[i-1]>0 && bufferMACD[i]<0) && ruleBuy1) { //MACD crosses below Zero Line
|
||||
ruleBuy2 = true;
|
||||
}
|
||||
|
||||
// start of the SELL signal - RULE #1...
|
||||
if ( (bufferMACD[i-1]<bufferSignal[i-1] && bufferMACD[i]>bufferSignal[i]) ) { //MACD crosses above Signal
|
||||
ruleSell1=true; ruleSell2=false;
|
||||
}
|
||||
// RULE SELL #2...
|
||||
if ( (bufferMACD[i-1]<0 && bufferMACD[i]>0) && ruleSell1) { //MACD crosses above Zero Line
|
||||
ruleSell2 = true;
|
||||
}
|
||||
|
||||
|
||||
// Sets the BUY and SELL signal...
|
||||
if (bufferMACD[i-1]<bufferSignal[i-1] && bufferMACD[i]>bufferSignal[i] && ruleBuy1 && ruleBuy2) {
|
||||
bufferBuy[i] = low[i]; //prints a BUY arrow, as if it is an "at Market order"
|
||||
bufferSell[i] = EMPTY_VALUE; //do not print an arrow
|
||||
ruleBuy1 = ruleBuy2 = false; //prepare to the next Buy signal
|
||||
|
||||
} else if (bufferMACD[i-1]>bufferSignal[i-1] && bufferMACD[i]<bufferSignal[i] && ruleSell1 && ruleSell2) {
|
||||
bufferSell[i] = high[i]; //prints a SELL arrow, as if it is an "at Market order"
|
||||
bufferBuy[i] = EMPTY_VALUE; //do not print an arrow
|
||||
ruleSell1 = ruleSell2 = false; //prepare to the next Sell signal
|
||||
|
||||
} else {
|
||||
bufferBuy[i]=bufferSell[i] = EMPTY_VALUE; //do not print any arrow at all for the candle...
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return the prev_calculated value for the next call
|
||||
return(rates_total);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Filling indicator buffers from the iMACD indicator... |
|
||||
//+------------------------------------------------------------------+
|
||||
bool FillArraysFromBuffers(double &bufMACD[], // indicator buffer of MACD values
|
||||
double &bufSignal[], // indicator buffer of the Signal line of MACD
|
||||
int ind_handle, // handle of the iMACD indicator
|
||||
int amount // number of copied values
|
||||
)
|
||||
{
|
||||
|
||||
ResetLastError();
|
||||
// fill a part of the iMACDBuffer array with values from the indicator buffer that has 0 index
|
||||
if(CopyBuffer(ind_handle,0,0,amount,bufMACD)<0)
|
||||
{
|
||||
// if the copying fails, tell the error code
|
||||
PrintFormat("Failed to copy data from the iMACD indicator, error code %d",GetLastError());
|
||||
// quit with zero result - it means that the indicator is considered as not calculated
|
||||
return(false);
|
||||
}
|
||||
|
||||
// fill a part of the Signal Buffer array with values from the indicator buffer that has index 1
|
||||
if(CopyBuffer(ind_handle,1,0,amount,bufSignal)<0)
|
||||
{
|
||||
// if the copying fails, tell the error code
|
||||
PrintFormat("Failed to copy data from the iMACD indicator, error code %d",GetLastError());
|
||||
// quit with zero result - it means that the indicator is considered as not calculated
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| indicator exit... freeing memory... |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnDeinit(const int reason) {
|
||||
IndicatorRelease(hiMACD);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
|
After Width: | Height: | Size: 18 MiB |
@@ -0,0 +1,23 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `3d_moving_avarage.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||

|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
@@ -0,0 +1,21 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `example3d.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 408 KiB |
|
After Width: | Height: | Size: 32 MiB |
|
After Width: | Height: | Size: 18 MiB |
@@ -0,0 +1,139 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| 3DSpiral.mq5 |
|
||||
//| Copyright 2020, MetaQuotes Software Corp. |
|
||||
//| https://www.mql5.com/en/users/nikolay7ko |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2018, Nikolay Semko"
|
||||
#property link "https://www.mql5.com/ru/users/nikolay7ko"
|
||||
#property link "SemkoNV@bk.ru"
|
||||
#property version "3.00"
|
||||
#property indicator_chart_window
|
||||
#property indicator_buffers 1
|
||||
#property indicator_plots 0
|
||||
#include <Canvas\iCanvas_CB.mqh> //https://www.mql5.com/ru/code/22164
|
||||
|
||||
input int N = 200; // Maximum circles
|
||||
|
||||
double cl[];
|
||||
int Size;
|
||||
double max=-DBL_MAX, min=DBL_MAX;
|
||||
double _r;
|
||||
int _per=0,per=0;
|
||||
double K;
|
||||
bool rotate = true;
|
||||
int startPos = 0;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit() {
|
||||
ChartSetInteger(0,CHART_SHOW,false);
|
||||
SetIndexBuffer(0,cl);
|
||||
PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_NONE);
|
||||
_r=_Height/2-7;
|
||||
_per=int(2*M_PI*_r);
|
||||
per = _per;
|
||||
K=100*_Height;
|
||||
return(INIT_SUCCEEDED);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
void OnDeinit(const int reason) {
|
||||
ChartSetInteger(0,CHART_SHOW,true);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| 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[]) {
|
||||
int d=rates_total-prev_calculated;
|
||||
Size = rates_total;
|
||||
if (prev_calculated == 0 && rates_total>per*N) startPos = rates_total-per*N;
|
||||
if (d>0) {
|
||||
int from = prev_calculated>0?prev_calculated-1:0;
|
||||
for(int i=from;i<Size;i++){
|
||||
|
||||
//cl[i]=(close[i]-close[i-1])/close[i];
|
||||
cl[i]=close[i];
|
||||
if (i >= startPos+1) {
|
||||
if(cl[i]>max) max=cl[i];
|
||||
if(cl[i]<min) min=cl[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//cl[Size-1]=(close[Size-1]-close[Size-2])/close[Size-2];
|
||||
cl[Size-1]=close[Size-1];
|
||||
}
|
||||
Draw();
|
||||
return(rates_total);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| ChartEvent function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnChartEvent(const int id,
|
||||
const long &lparam,
|
||||
const double &dparam,
|
||||
const string &sparam) {
|
||||
if (id==CHARTEVENT_CLICK) rotate = !rotate;
|
||||
if (id==CHARTEVENT_MOUSE_MOVE) {
|
||||
if (!rotate) per = int((1+5.0*_MouseX/_Width)*_per);
|
||||
Draw();
|
||||
}
|
||||
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
void Draw() {
|
||||
static uint last = 0;
|
||||
static int mx = 0,my =0;
|
||||
uint cur = GetTickCount();
|
||||
if (cur-last<30) return;
|
||||
last = cur;
|
||||
ulong t=GetMicrosecondCount();
|
||||
int X=_Width/2;
|
||||
int Y=_Height/2-5;
|
||||
Canvas.Erase(0x00FFFFFF);
|
||||
if (max-min<=0) return;
|
||||
int nn=0;
|
||||
double c=0;
|
||||
if (rotate) {
|
||||
mx = _MouseX;
|
||||
my = _MouseY;
|
||||
}
|
||||
int _a=(X - mx + 5*per);
|
||||
int _b=(Y+5 - my + 5*per);
|
||||
|
||||
for (int i=startPos,j=0; i<Size; i++,j++) {
|
||||
double r = _r*(0.3+0.7*(cl[i]-min)/(max-min));
|
||||
double cc=cos(j*2*M_PI/per);
|
||||
if (c<0 && cc>=0) nn++;
|
||||
c=cc;
|
||||
double z =r -r*2*double(j)/(Size-startPos);
|
||||
double x = c*r;
|
||||
double y = sin(j*2*M_PI/per)*r;
|
||||
//double R=sqrt(x*x+y*y+z*z);
|
||||
double x1=x*cos(_a*2*M_PI/per)+z*sin(_a*2*M_PI/per);
|
||||
double z1=-x*sin(_a*2*M_PI/per)+z*cos(_a*2*M_PI/per);
|
||||
double y1=y*cos(_b*2*M_PI/per)+z1*sin(_b*2*M_PI/per);
|
||||
double z2=-y*sin(_b*2*M_PI/per)+z1*cos(_b*2*M_PI/per);
|
||||
z2=z2+_r;
|
||||
x=X+K*x1/(z2+K);
|
||||
y=Y+K*y1/(z2+K);
|
||||
_PixelSet((int)x,(int)y,Canvas.Grad(double(i-startPos)/(Size-startPos)));
|
||||
}
|
||||
t=GetMicrosecondCount()-t;
|
||||
_CommXY(20,30,_Symbol);
|
||||
_Comment("Total "+string(nn)+" Circles");
|
||||
_Comment("Circle period = " + string(per)+" bars");
|
||||
_Comment("Runtime = "+string (t) +" mks");
|
||||
_Comment("Max : "+string(max));
|
||||
_Comment("Min : "+string(min));
|
||||
Canvas.Update();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `3dspiral.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 13 MiB |
@@ -0,0 +1,21 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `3dma.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,214 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| 3D_OscilatorSign.mq5 |
|
||||
//| Copyright © 2005, Luis Damiani |
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
//---- àâòîðñòâî èíäèêàòîðà
|
||||
#property copyright "Copyright © 2005, Luis Damiani"
|
||||
//---- ññûëêà íà ñàéò àâòîðà
|
||||
#property link ""
|
||||
//---- íîìåð âåðñèè èíäèêàòîðà
|
||||
#property version "1.00"
|
||||
//--- îòðèñîâêà èíäèêàòîðà â ãëàâíîì îêíå
|
||||
#property indicator_chart_window
|
||||
//--- äëÿ ðàñ÷åòà è îòðèñîâêè èíäèêàòîðà èñïîëüçîâàíî äâà áóôåðà
|
||||
#property indicator_buffers 2
|
||||
//--- èñïîëüçîâàíî âñåãî äâà ãðàôè÷åñêèõ ïîñòðîåíèÿ
|
||||
#property indicator_plots 2
|
||||
//+----------------------------------------------+
|
||||
//| Ïàðàìåòðû îòðèñîâêè ìåäâåæüåãî èíäèêàòîðà |
|
||||
//+----------------------------------------------+
|
||||
//--- îòðèñîâêà èíäèêàòîðà 1 â âèäå ñèìâîëà
|
||||
#property indicator_type1 DRAW_ARROW
|
||||
//--- â êà÷åñòâå öâåòà ìåäâåæüåé ëèíèè èíäèêàòîðà èñïîëüçîâàí ðîçîâûé öâåò
|
||||
#property indicator_color1 clrMagenta
|
||||
//--- òîëùèíà ëèíèè èíäèêàòîðà 1 ðàâíà 4
|
||||
#property indicator_width1 4
|
||||
//--- îòîáðàæåíèå ìåäâåæüåé ìåòêè èíäèêàòîðà
|
||||
#property indicator_label1 "3D_Oscilator Sell"
|
||||
//+----------------------------------------------+
|
||||
//| Ïàðàìåòðû îòðèñîâêè áû÷üåãî èíäèêàòîðà |
|
||||
//+----------------------------------------------+
|
||||
//--- îòðèñîâêà èíäèêàòîðà 2 â âèäå ñèìâîëà
|
||||
#property indicator_type2 DRAW_ARROW
|
||||
//--- â êà÷åñòâå öâåòà áû÷üåé ëèíèè èíäèêàòîðà èñïîëüçîâàí çåëåíûé öâåò
|
||||
#property indicator_color2 clrLime
|
||||
//--- òîëùèíà ëèíèè èíäèêàòîðà 2 ðàâíà 4
|
||||
#property indicator_width2 4
|
||||
//--- îòîáðàæåíèå áû÷üåé ìåòêè èíäèêàòîðà
|
||||
#property indicator_label2 "3D_Oscilator Buy"
|
||||
//+----------------------------------------------+
|
||||
//| îáúÿâëåíèå êîíñòàíò |
|
||||
//+----------------------------------------------+
|
||||
#define RESET 0 // Êîíñòàíòà äëÿ âîçâðàòà òåðìèíàëó êîìàíäû íà ïåðåñ÷¸ò èíäèêàòîðà
|
||||
//+----------------------------------------------+
|
||||
//| Âõîäíûå ïàðàìåòðû èíäèêàòîðà |
|
||||
//+----------------------------------------------+
|
||||
input int D1RSIPer=13;
|
||||
input int D2StochPer=8;
|
||||
input int D3tunnelPer=8;
|
||||
input double hot=0.4;
|
||||
input int sigsmooth=4;
|
||||
//+----------------------------------------------+
|
||||
//--- îáúÿâëåíèå äèíàìè÷åñêèõ ìàññèâîâ, êîòîðûå â äàëüíåéøåì
|
||||
//--- áóäóò èñïîëüçîâàíû â êà÷åñòâå èíäèêàòîðíûõ áóôåðîâ
|
||||
double SellBuffer[];
|
||||
double BuyBuffer[];
|
||||
//---
|
||||
double sk,sk2;
|
||||
int ss,min_rates_total,ATR_Handle,RSI_Handle,CCI_Handle;
|
||||
//+------------------------------------------------------------------+
|
||||
//| Custom indicator initialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit()
|
||||
{
|
||||
//---- èíèöèàëèçàöèÿ ãëîáàëüíûõ ïåðåìåííûõ
|
||||
ss=sigsmooth;
|
||||
if(ss<2) ss=2;
|
||||
sk = 2.0 / (ss + 1.0);
|
||||
sk2=2.0/(ss*0.8+1.0);
|
||||
int ATR_Period=15;
|
||||
min_rates_total=int(D1RSIPer+D2StochPer+D2StochPer+hot+sigsmooth);
|
||||
min_rates_total=MathMax(min_rates_total,ATR_Period)+1;
|
||||
|
||||
//---- ïîëó÷åíèå õåíäëà èíäèêàòîðà
|
||||
RSI_Handle=iRSI(NULL,0,D1RSIPer,PRICE_CLOSE);
|
||||
if(RSI_Handle==INVALID_HANDLE)
|
||||
{
|
||||
Print(" Íå óäàëîñü ïîëó÷èòü õåíäë èíäèêàòîðà iRSI");
|
||||
return(INIT_FAILED);
|
||||
}
|
||||
//---- ïîëó÷åíèå õåíäëà èíäèêàòîðà
|
||||
CCI_Handle=iCCI(NULL,0,D3tunnelPer,PRICE_TYPICAL);
|
||||
if(CCI_Handle==INVALID_HANDLE)
|
||||
{
|
||||
Print(" Íå óäàëîñü ïîëó÷èòü õåíäë èíäèêàòîðà iCCI");
|
||||
return(INIT_FAILED);
|
||||
}
|
||||
//--- ïîëó÷åíèå õåíäëà èíäèêàòîðà ATR
|
||||
ATR_Handle=iATR(NULL,0,ATR_Period);
|
||||
if(ATR_Handle==INVALID_HANDLE)
|
||||
{
|
||||
Print(" Íå óäàëîñü ïîëó÷èòü õåíäë èíäèêàòîðà ATR");
|
||||
return(INIT_FAILED);
|
||||
}
|
||||
|
||||
//---- ïðåâðàùåíèå äèíàìè÷åñêîãî ìàññèâà â èíäèêàòîðíûé áóôåð
|
||||
SetIndexBuffer(0,SellBuffer,INDICATOR_DATA);
|
||||
//---- îñóùåñòâëåíèå ñäâèãà íà÷àëà îòñ÷¸òà îòðèñîâêè èíäèêàòîðà
|
||||
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total);
|
||||
//---- ñèìâîë äëÿ èíäèêàòîðà
|
||||
PlotIndexSetInteger(0,PLOT_ARROW,159);
|
||||
//---- èíäåêñàöèÿ ýëåìåíòîâ â áóôåðå êàê â òàéìñåðèè
|
||||
ArraySetAsSeries(SellBuffer,true);
|
||||
//---- çàïðåò íà îòðèñîâêó èíäèêàòîðîì ïóñòûõ çíà÷åíèé
|
||||
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0);
|
||||
|
||||
//---- ïðåâðàùåíèå äèíàìè÷åñêîãî ìàññèâà â èíäèêàòîðíûé áóôåð
|
||||
SetIndexBuffer(1,BuyBuffer,INDICATOR_DATA);
|
||||
//---- îñóùåñòâëåíèå ñäâèãà íà÷àëà îòñ÷¸òà îòðèñîâêè èíäèêàòîðà
|
||||
PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total);
|
||||
//---- ñèìâîë äëÿ èíäèêàòîðà
|
||||
PlotIndexSetInteger(1,PLOT_ARROW,159);
|
||||
//---- èíäåêñàöèÿ ýëåìåíòîâ â áóôåðå êàê â òàéìñåðèè
|
||||
ArraySetAsSeries(BuyBuffer,true);
|
||||
//---- çàïðåò íà îòðèñîâêó èíäèêàòîðîì ïóñòûõ çíà÷åíèé
|
||||
PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0);
|
||||
|
||||
//---- Óñòàíîâêà ôîðìàòà òî÷íîñòè îòîáðàæåíèÿ èíäèêàòîðà
|
||||
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
|
||||
//---- èìÿ äëÿ îêîí äàííûõ è ëýéáà äëÿ ñóáúîêîí
|
||||
string short_name="3D OscillatorSign";
|
||||
IndicatorSetString(INDICATOR_SHORTNAME,short_name);
|
||||
//---
|
||||
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[])
|
||||
{
|
||||
//---- ïðîâåðêà êîëè÷åñòâà áàðîâ íà äîñòàòî÷íîñòü äëÿ ðàñ÷¸òà
|
||||
if(BarsCalculated(RSI_Handle)<rates_total
|
||||
|| BarsCalculated(CCI_Handle)<rates_total
|
||||
|| BarsCalculated(ATR_Handle)<rates_total
|
||||
||rates_total<min_rates_total) return(RESET);
|
||||
|
||||
//---- îáúÿâëåíèÿ ëîêàëüíûõ ïåðåìåííûõ
|
||||
int to_copy,limit,bar;
|
||||
double rsi,maxrsi,minrsi,storsi,E3D,RSI[],CCI[],ATR[],rangrsi,ind,sig;
|
||||
static double prev_ind,prev_sig;
|
||||
|
||||
//---- ðàñ÷¸òû íåîáõîäèìîãî êîëè÷åñòâà êîïèðóåìûõ äàííûõ è
|
||||
//ñòàðòîâîãî íîìåðà limit äëÿ öèêëà ïåðåñ÷¸òà áàðîâ
|
||||
if(prev_calculated>rates_total || prev_calculated<=0)// ïðîâåðêà íà ïåðâûé ñòàðò ðàñ÷¸òà èíäèêàòîðà
|
||||
{
|
||||
to_copy=rates_total; // ðàñ÷¸òíîå êîëè÷åñòâî âñåõ áàðîâ
|
||||
limit=rates_total-min_rates_total-1; // ñòàðòîâûé íîìåð äëÿ ðàñ÷¸òà âñåõ áàðîâ
|
||||
}
|
||||
else
|
||||
{
|
||||
limit=rates_total-prev_calculated; // ñòàðòîâûé íîìåð äëÿ ðàñ÷¸òà íîâûõ áàðîâ
|
||||
to_copy=limit+D2StochPer+3; // ðàñ÷¸òíîå êîëè÷åñòâî âñåõ áàðîâ
|
||||
}
|
||||
|
||||
//---- èíäåêñàöèÿ ýëåìåíòîâ â ìàññèâàõ êàê â òàéìñåðèÿõ
|
||||
ArraySetAsSeries(RSI,true);
|
||||
ArraySetAsSeries(CCI,true);
|
||||
ArraySetAsSeries(ATR,true);
|
||||
ArraySetAsSeries(high,true);
|
||||
ArraySetAsSeries(low,true);
|
||||
|
||||
//---- êîïèðóåì âíîâü ïîÿâèâøèåñÿ äàííûå â ìàññèâû
|
||||
if(CopyBuffer(RSI_Handle,0,0,to_copy,RSI)<=0) return(RESET);
|
||||
to_copy=limit+1;
|
||||
if(CopyBuffer(CCI_Handle,0,0,to_copy,CCI)<=0) return(RESET);
|
||||
if(CopyBuffer(ATR_Handle,0,0,to_copy,ATR)<=0) return(RESET);
|
||||
|
||||
//---- îñíîâíîé öèêë ðàñ÷¸òà èíäèêàòîðà
|
||||
for(bar=limit; bar>=0 && !IsStopped(); bar--)
|
||||
{
|
||||
rsi=RSI[bar];
|
||||
maxrsi=rsi;
|
||||
minrsi=rsi;
|
||||
|
||||
for(int iii=bar+D2StochPer; iii>=bar; iii--)
|
||||
{
|
||||
rsi=RSI[iii];
|
||||
if(rsi>maxrsi) maxrsi=rsi;
|
||||
if(rsi<minrsi) minrsi=rsi;
|
||||
}
|
||||
|
||||
rangrsi=maxrsi-minrsi;
|
||||
if(rangrsi==0) storsi=0.0;
|
||||
else storsi=(rsi-minrsi)/((maxrsi-minrsi)*200)-100;
|
||||
E3D=hot*CCI[bar]+(1.0-hot)*storsi;
|
||||
|
||||
ind=sk*E3D+(1.0-sk)*prev_ind;
|
||||
sig=sk2*prev_ind+(1.0-sk2)*prev_sig;
|
||||
|
||||
BuyBuffer[bar]=0.0;
|
||||
SellBuffer[bar]=0.0;
|
||||
|
||||
if(ind>sig && prev_ind<prev_sig) BuyBuffer[bar]=low[bar]-ATR[bar]*3/8;
|
||||
if(ind<sig && prev_ind>prev_sig) SellBuffer[bar]=high[bar]+ATR[bar]*3/8;
|
||||
|
||||
if(bar)
|
||||
{
|
||||
prev_ind=ind;
|
||||
prev_sig=sig;
|
||||
}
|
||||
}
|
||||
//----
|
||||
return(rates_total);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,21 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `3d_oscilatorsign.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 17 KiB |
@@ -0,0 +1,22 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `3tf_mfi_average.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 19 KiB |
@@ -0,0 +1,22 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `3tf_rsi_average.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,22 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `3tf_stochastic_average.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,22 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `3_in_1_stochastic.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
@@ -0,0 +1,21 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||
|
||||
## Files included:
|
||||
### Source Files:
|
||||
- `3rdgenma.mq5`
|
||||
|
||||
### Screenshots:
|
||||

|
||||
|
||||
> Made with ❤️ for the trading community.
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
@@ -0,0 +1,215 @@
|
||||
//------------------------------------------------------------------
|
||||
#property copyright "mladen"
|
||||
#property link "www.forex-tsd.com"
|
||||
#property version "1.00"
|
||||
//------------------------------------------------------------------
|
||||
#property indicator_chart_window
|
||||
#property indicator_buffers 5
|
||||
#property indicator_plots 1
|
||||
|
||||
#property indicator_label1 "4 ma candles"
|
||||
#property indicator_type1 DRAW_COLOR_CANDLES
|
||||
#property indicator_color1 clrGray,clrLimeGreen,clrSandyBrown
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
enum enMaTypes
|
||||
{
|
||||
avgSma, // Simple moving average
|
||||
avgEma, // Exponential moving average
|
||||
avgSmma, // Smoothed MA
|
||||
avgLwma // Linear weighted MA
|
||||
};
|
||||
|
||||
input int AvgPeriod = 25; // Averages period
|
||||
input enMaTypes AvgType = avgEma; // Averages method
|
||||
|
||||
double canc[],cano[],canh[],canl[],colors[];
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
int OnInit()
|
||||
{
|
||||
SetIndexBuffer(0,cano ,INDICATOR_DATA);
|
||||
SetIndexBuffer(1,canh ,INDICATOR_DATA);
|
||||
SetIndexBuffer(2,canl ,INDICATOR_DATA);
|
||||
SetIndexBuffer(3,canc ,INDICATOR_DATA);
|
||||
SetIndexBuffer(4,colors,INDICATOR_COLOR_INDEX);
|
||||
return(0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
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 bars = Bars(_Symbol,_Period); if (bars<rates_total) return(-1);
|
||||
for (int i=(int)MathMax(prev_calculated-1,0); i<rates_total && !IsStopped(); i++)
|
||||
{
|
||||
double mao = iCustomMa(AvgType,open[i] ,AvgPeriod,i,rates_total,0);
|
||||
double mac = iCustomMa(AvgType,close[i],AvgPeriod,i,rates_total,1);
|
||||
double mah = iCustomMa(AvgType,high[i] ,AvgPeriod,i,rates_total,2);
|
||||
double mal = iCustomMa(AvgType,low[i] ,AvgPeriod,i,rates_total,3);
|
||||
canh[i] = MathMax(MathMax(MathMax(mao,mac),mal),mah);
|
||||
canl[i] = MathMin(MathMin(MathMin(mao,mac),mal),mah);
|
||||
cano[i] = mao;
|
||||
canc[i] = mac;
|
||||
colors[i] = mao>mac ? 2 : mao<mac ? 1 : 0;
|
||||
}
|
||||
return(rates_total);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
#define _maInstances 4
|
||||
#define _maWorkBufferx1 1*_maInstances
|
||||
#define _maWorkBufferx2 2*_maInstances
|
||||
|
||||
double iCustomMa(int mode, double price, double length, int r, int bars, int instanceNo=0)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case avgSma : return(iSma(price,(int)length,r,bars,instanceNo));
|
||||
case avgEma : return(iEma(price,length,r,bars,instanceNo));
|
||||
case avgSmma : return(iSmma(price,(int)length,r,bars,instanceNo));
|
||||
case avgLwma : return(iLwma(price,(int)length,r,bars,instanceNo));
|
||||
default : return(price);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
double workSma[][_maWorkBufferx2];
|
||||
double iSma(double price, int period, int r, int _bars, int instanceNo=0)
|
||||
{
|
||||
if (period<=1) return(price);
|
||||
if (ArrayRange(workSma,0)!= _bars) ArrayResize(workSma,_bars); instanceNo *= 2; int k;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
workSma[r][instanceNo+0] = price;
|
||||
workSma[r][instanceNo+1] = price; for(k=1; k<period && (r-k)>=0; k++) workSma[r][instanceNo+1] += workSma[r-k][instanceNo+0];
|
||||
workSma[r][instanceNo+1] /= 1.0*k;
|
||||
return(workSma[r][instanceNo+1]);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
double workEma[][_maWorkBufferx1];
|
||||
double iEma(double price, double period, int r, int _bars, int instanceNo=0)
|
||||
{
|
||||
if (period<=1) return(price);
|
||||
if (ArrayRange(workEma,0)!= _bars) ArrayResize(workEma,_bars);
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
workEma[r][instanceNo] = price;
|
||||
double alpha = 2.0 / (1.0+period);
|
||||
if (r>0)
|
||||
workEma[r][instanceNo] = workEma[r-1][instanceNo]+alpha*(price-workEma[r-1][instanceNo]);
|
||||
return(workEma[r][instanceNo]);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
double workSmma[][_maWorkBufferx1];
|
||||
double iSmma(double price, double period, int r, int _bars, int instanceNo=0)
|
||||
{
|
||||
if (period<=1) return(price);
|
||||
if (ArrayRange(workSmma,0)!= _bars) ArrayResize(workSmma,_bars);
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
if (r<period)
|
||||
workSmma[r][instanceNo] = price;
|
||||
else workSmma[r][instanceNo] = workSmma[r-1][instanceNo]+(price-workSmma[r-1][instanceNo])/period;
|
||||
return(workSmma[r][instanceNo]);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
double workLwma[][_maWorkBufferx1];
|
||||
double iLwma(double price, double period, int r, int _bars, int instanceNo=0)
|
||||
{
|
||||
if (period<=1) return(price);
|
||||
if (ArrayRange(workLwma,0)!= _bars) ArrayResize(workLwma,_bars);
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
workLwma[r][instanceNo] = price;
|
||||
double sumw = period;
|
||||
double sum = period*price;
|
||||
|
||||
for(int k=1; k<period && (r-k)>=0; k++)
|
||||
{
|
||||
double weight = period-k;
|
||||
sumw += weight;
|
||||
sum += weight*workLwma[r-k][instanceNo];
|
||||
}
|
||||
return(sum/sumw);
|
||||
}
|
||||