Author: Copyright 2016, DC2008
Indicators Used
Moving average indicator
0 Views
0 Downloads
0 Favorites
example3D
ÿþ//+------------------------------------------------------------------+

//|                                                    example3D.mq5 |

//|                                           Copyright 2016, DC2008 |

//|                              http://www.mql5.com/ru/users/dc2008 |

//+------------------------------------------------------------------+

#property copyright     "Copyright 2016, DC2008"

#property link          "http://www.mql5.com/ru/users/dc2008"

#property version       "1.00"

#property description   "5<>=AB@0F8O 3D 8=48:0B>@0 Moving Average"

//--- 1JO2;5=85 :>=AB0=B

#define  StepX    10    // H03 ?> >A8 % [bar]

#define  StepY    10    // H03 ?> >A8 Y [bar]

#define  _X       50    // :>;8G5AB2> C7;>2 ?> >A8 %

#define  _Y       20    // :>;8G5AB2> C7;>2 ?> >A8 Y

#define  W1       1     // B>;I8=0 ;8=89

#define  W2       3     // B>;I8=0 :@09=8E ;8=89

//--- 0:@>AK

#define  ObjSet1  ObjectSetInteger(0,name,OBJPROP_STYLE,STYLE_SOLID)

#define  ObjSet2  ObjectSetInteger(0,name,OBJPROP_RAY_RIGHT,false)

#define  ObjSet3  ObjectSetInteger(0,name,OBJPROP_RAY_LEFT,false)

#define  ObjSet4  ObjectSetInteger(0,name,OBJPROP_BACK,true)

#define  ObjSet5  ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false)

#define  ObjSet   ObjSet1;ObjSet2;ObjSet3;ObjSet4;ObjSet5

//--- >4:;NG05< D09;K :;0AA>2

#include <3D\USC.mqh>

//---

#property indicator_chart_window

//--- >;8G5AB2> 1CD5@>2 4;O @0AG5B0 8=48:0B>@0

#property indicator_buffers 0

//--- >;8G5AB2> 3@0D8G5A:8E A5@89 2 8=48:0B>@5

#property indicator_plots   0

//--- 1JO2;O5< ?5@5<5==K5

CUSC        USC;

double fun[_X][_Y];  // 3D DC=:F8O

//--- 

double      MA[];

int         iMA_handle[_Y];

int         period[_Y]={10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200};

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

  {

   USC.Create("3D");

//---

   ArraySetAsSeries(MA,true);

   for(int i=0;i<_Y;i++)

      iMA_handle[i]=iMA(_Symbol,_Period,period[i],0,MODE_SMA,PRICE_CLOSE);

   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[])

  {

//--- $C=:F8O 3D 8=48:0B>@0 Moving Average

   for(int i=0;i<_X;i++)

      for(int j=0;j<_Y;j++)

        {

         CopyBuffer(iMA_handle[j],0,i*StepX,1,MA);

         fun[i][j]=MA[0];

        }



//--- ;8=88 X

   for(int i=1;i<_X;i++)

      for(int j=0;j<_Y;j++)

        {

         sPointCoordinates p0=USC.Z(fun[(i-1)][j], // DC=:F8O

                                    (i-1)*StepX,   // X

                                    -j*StepY);     // Y

         sPointCoordinates p1=USC.Z(fun[i][j],     // DC=:F8O

                                    i*StepX,       // X

                                    -j*StepY);     // Y

         string name="MA("+(string)period[j]+") x"+(string)i+"y"+(string)j;

         ObjectCreate(0,name,OBJ_TREND,0,p0.time,p0.price,p1.time,p1.price);

         if(fun[i][j]>USC.m_price && fun[i-1][j]>USC.m_price)

            ObjectSetInteger(0,name,OBJPROP_COLOR,clrRed);

         else

            ObjectSetInteger(0,name,OBJPROP_COLOR,clrBlue);

         ObjectSetInteger(0,name,OBJPROP_WIDTH,W1);

         if(j==0 || j==_Y-1)

            ObjectSetInteger(0,name,OBJPROP_WIDTH,W2);

         ObjSet;

        }

//--- ;8=88 Y

   for(int i=0;i<_X;i++)

      for(int j=1;j<_Y;j++)

        {

         sPointCoordinates p0=USC.Z(fun[i][j-1],   // DC=:F8O

                                    i*StepX,       // X

                                    -(j-1)*StepY); // Y

         sPointCoordinates p1=USC.Z(fun[i][j],     // DC=:F8O

                                    i*StepX,       // X

                                    -j*StepY);     // Y

         string name="line yz "+"x"+(string)i+"y"+(string)j;

         ObjectCreate(0,name,OBJ_TREND,0,p0.time,p0.price,p1.time,p1.price);

         ObjectSetInteger(0,name,OBJPROP_COLOR,clrGreen);

         ObjectSetInteger(0,name,OBJPROP_WIDTH,1);

         ObjSet;

        }

   return(rates_total);

  }

//+------------------------------------------------------------------+

//| ChartEvent function                                              |

//+------------------------------------------------------------------+

void OnChartEvent(const int id,

                  const long &lparam,

                  const double &dparam,

                  const string &sparam)

  {

   USC.OnEvent(id,lparam,dparam,sparam);

  }

//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---