diff --git a/Experts/Articles/100.zip b/Experts/Articles/100.zip new file mode 100644 index 0000000..350f6c7 Binary files /dev/null and b/Experts/Articles/100.zip differ diff --git a/Experts/Articles/100/my_first_ea.mq5 b/Experts/Articles/100/my_first_ea.mq5 new file mode 100644 index 0000000..f6ba593 --- /dev/null +++ b/Experts/Articles/100/my_first_ea.mq5 @@ -0,0 +1,278 @@ +//+------------------------------------------------------------------+ +//| My_First_EA.mq5 | +//| Copyright 2010, MetaQuotes Software Corp. | +//| http://www.mql5.com | +//+------------------------------------------------------------------+ +#property copyright "Copyright 2010, MetaQuotes Software Corp." +#property link "http://www.mql5.com" +#property version "1.00" +//--- input parameters +input int StopLoss=30; // Stop Loss +input int TakeProfit=100; // Take Profit +input int ADX_Period=8; // ADX Period +input int MA_Period=8; // Moving Average Period +input int EA_Magic=12345; // EA Magic Number +input double Adx_Min=22.0; // Minimum ADX Value +input double Lot=0.1; // Lots to Trade +//--- Other parameters +int adxHandle; // handle for our ADX indicator +int maHandle; // handle for our Moving Average indicator +double plsDI[],minDI[],adxVal[]; // Dynamic arrays to hold the values of +DI, -DI and ADX values for each bars +double maVal[]; // Dynamic array to hold the values of Moving Average for each bars +double p_close; // Variable to store the close value of a bar +int STP, TKP; // To be used for Stop Loss & Take Profit values +//+------------------------------------------------------------------+ +//| Expert initialization function | +//+------------------------------------------------------------------+ +int OnInit() + { +//--- Get handle for ADX indicator + adxHandle=iADX(NULL,0,ADX_Period); +//--- Get the handle for Moving Average indicator + maHandle=iMA(_Symbol,_Period,MA_Period,0,MODE_EMA,PRICE_CLOSE); +//--- What if handle returns Invalid Handle + if(adxHandle<0 || maHandle<0) + { + Alert("Error Creating Handles for indicators - error: ",GetLastError(),"!!"); + return(-1); + } + +//--- Let us handle currency pairs with 5 or 3 digit prices instead of 4 + STP = StopLoss; + TKP = TakeProfit; + if(_Digits==5 || _Digits==3) + { + STP = STP*10; + TKP = TKP*10; + } + return(0); + } +//+------------------------------------------------------------------+ +//| Expert deinitialization function | +//+------------------------------------------------------------------+ +void OnDeinit(const int reason) + { +//--- Release our indicator handles + IndicatorRelease(adxHandle); + IndicatorRelease(maHandle); + } +//+------------------------------------------------------------------+ +//| Expert tick function | +//+------------------------------------------------------------------+ +void OnTick() + { +//--- Do we have enough bars to work with + if(Bars(_Symbol,_Period)<60) // if total bars is less than 60 bars + { + Alert("We have less than 60 bars, EA will now exit!!"); + return; + } + +// We will use the static Old_Time variable to serve the bar time. +// At each OnTick execution we will check the current bar time with the saved one. +// If the bar time isn't equal to the saved time, it indicates that we have a new tick. + + static datetime Old_Time; + datetime New_Time[1]; + bool IsNewBar=false; + +// copying the last bar time to the element New_Time[0] + int copied=CopyTime(_Symbol,_Period,0,1,New_Time); + if(copied>0) // ok, the data has been copied successfully + { + if(Old_Time!=New_Time[0]) // if old time isn't equal to new bar time + { + IsNewBar=true; // if it isn't a first call, the new bar has appeared + if(MQL5InfoInteger(MQL5_DEBUGGING)) Print("We have new bar here ",New_Time[0]," old time was ",Old_Time); + Old_Time=New_Time[0]; // saving bar time + } + } + else + { + Alert("Error in copying historical times data, error =",GetLastError()); + ResetLastError(); + return; + } + +//--- EA should only check for new trade if we have a new bar + if(IsNewBar==false) + { + return; + } + +//--- Do we have enough bars to work with + int Mybars=Bars(_Symbol,_Period); + if(Mybars<60) // if total bars is less than 60 bars + { + Alert("We have less than 60 bars, EA will now exit!!"); + return; + } + +//--- Define some MQL5 Structures we will use for our trade + MqlTick latest_price; // To be used for getting recent/latest price quotes + MqlTradeRequest mrequest; // To be used for sending our trade requests + MqlTradeResult mresult; // To be used to get our trade results + MqlRates mrate[]; // To be used to store the prices, volumes and spread of each bar + ZeroMemory(mrequest); // Initialization of mrequest structure +/* + Let's make sure our arrays values for the Rates, ADX Values and MA values + is store serially similar to the timeseries array +*/ +// the rates arrays + ArraySetAsSeries(mrate,true); +// the ADX DI+values array + ArraySetAsSeries(plsDI,true); +// the ADX DI-values array + ArraySetAsSeries(minDI,true); +// the ADX values arrays + ArraySetAsSeries(adxVal,true); +// the MA-8 values arrays + ArraySetAsSeries(maVal,true); + + +//--- Get the last price quote using the MQL5 MqlTick Structure + if(!SymbolInfoTick(_Symbol,latest_price)) + { + Alert("Error getting the latest price quote - error:",GetLastError(),"!!"); + return; + } + +//--- Get the details of the latest 3 bars + if(CopyRates(_Symbol,_Period,0,3,mrate)<0) + { + Alert("Error copying rates/history data - error:",GetLastError(),"!!"); + ResetLastError(); + return; + } + +//--- Copy the new values of our indicators to buffers (arrays) using the handle + if(CopyBuffer(adxHandle,0,0,3,adxVal)<0 || CopyBuffer(adxHandle,1,0,3,plsDI)<0 + || CopyBuffer(adxHandle,2,0,3,minDI)<0) + { + Alert("Error copying ADX indicator Buffers - error:",GetLastError(),"!!"); + ResetLastError(); + return; + } + if(CopyBuffer(maHandle,0,0,3,maVal)<0) + { + Alert("Error copying Moving Average indicator buffer - error:",GetLastError()); + ResetLastError(); + return; + } +//--- we have no errors, so continue +//--- Do we have positions opened already? + bool Buy_opened=false; // variable to hold the result of Buy opened position + bool Sell_opened=false; // variables to hold the result of Sell opened position + + if(PositionSelect(_Symbol)==true) // we have an opened position + { + if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) + { + Buy_opened=true; //It is a Buy + } + else if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL) + { + Sell_opened=true; // It is a Sell + } + } + +// Copy the bar close price for the previous bar prior to the current bar, that is Bar 1 + p_close=mrate[1].close; // bar 1 close price + +/* + 1. Check for a long/Buy Setup : MA-8 increasing upwards, + previous price close above it, ADX > 22, +DI > -DI +*/ +//--- Declare bool type variables to hold our Buy Conditions + bool Buy_Condition_1=(maVal[0]>maVal[1]) && (maVal[1]>maVal[2]); // MA-8 Increasing upwards + bool Buy_Condition_2 = (p_close > maVal[1]); // previuos price closed above MA-8 + bool Buy_Condition_3 = (adxVal[0]>Adx_Min); // Current ADX value greater than minimum value (22) + bool Buy_Condition_4 = (plsDI[0]>minDI[0]); // +DI greater than -DI + +//--- Putting all together + if(Buy_Condition_1 && Buy_Condition_2) + { + if(Buy_Condition_3 && Buy_Condition_4) + { + // any opened Buy position? + if(Buy_opened) + { + Alert("We already have a Buy Position!!!"); + return; // Don't open a new Buy Position + } + ZeroMemory(mrequest); + mrequest.action = TRADE_ACTION_DEAL; // immediate order execution + mrequest.price = NormalizeDouble(latest_price.ask,_Digits); // latest ask price + mrequest.sl = NormalizeDouble(latest_price.ask - STP*_Point,_Digits); // Stop Loss + mrequest.tp = NormalizeDouble(latest_price.ask + TKP*_Point,_Digits); // Take Profit + mrequest.symbol = _Symbol; // currency pair + mrequest.volume = Lot; // number of lots to trade + mrequest.magic = EA_Magic; // Order Magic Number + mrequest.type = ORDER_TYPE_BUY; // Buy Order + mrequest.type_filling = ORDER_FILLING_FOK; // Order execution type + mrequest.deviation=100; // Deviation from current price + //--- send order + OrderSend(mrequest,mresult); + // get the result code + if(mresult.retcode==10009 || mresult.retcode==10008) //Request is completed or order placed + { + Alert("A Buy order has been successfully placed with Ticket#:",mresult.order,"!!"); + } + else + { + Alert("The Buy order request could not be completed -error:",GetLastError()); + ResetLastError(); + return; + } + } + } +/* + 2. Check for a Short/Sell Setup : MA-8 decreasing downwards, + previous price close below it, ADX > 22, -DI > +DI +*/ +//--- Declare bool type variables to hold our Sell Conditions + bool Sell_Condition_1 = (maVal[0]Adx_Min); // Current ADX value greater than minimum (22) + bool Sell_Condition_4 = (plsDI[0] +//--------------------------------------------------------------------- + +//===================================================================== +// External input parameters: +//===================================================================== +input string CurrencylList = "EURUSD; GBPUSD; EURGBP; AUDUSD; NZDUSD; AUDNZD; USDJPY; USDCHF; USDCAD; EURJPY; GBPJPY; AUDJPY; NZDJPY; CHFJPY; CADJPY; XAUUSD;"; +input string TimeFrameList = "H1; H4; D1; MN"; +input int UpDownBorderShift=1; +input int LeftRightBorderShift=1; +input color TitlesColor=LightCyan; +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +string Symbol_Array[ ]; // list of symbols +string TimeFrame_Array[ ]; // list of timeframes +ENUM_TIMEFRAMES TFs[]; +string Titles_Array[]={ "Bid:","Spread:","StopLev:","ToOpen:","Hi-Lo:","DailyAv:" }; +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +SymbolWatchDisplay *Watches[]; +TableDisplay TitlesDisplay; +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +int currencies_count; +int timeframes_count; +bool is_first_init=true; +//--------------------------------------------------------------------- +#define WIDTH 128 +#define HEIGHT 128 +#define FONTSIZE 10 +//--------------------------------------------------------------------- +// OnInit event handler +//--------------------------------------------------------------------- +int OnInit() + { +// List of symbols: + currencies_count=StringToArrayString(CurrencylList,Symbol_Array); + if(currencies_count>16) + { + currencies_count=16; + } +// List of timeframes: + timeframes_count=StringToArrayString(TimeFrameList,TimeFrame_Array); + ArrayResize(TFs,timeframes_count); + for(int k=0; k0) + { + np=StringFind(st,_delimiter); + if(np<0) + { + stp= st; + st = ""; + } + else + { + stp= StringSubstr(st,0,np); + st = StringSubstr(st,np+1); + } + i++; + ArrayResize(ad,i); + StringTrimLeft(stp); + ad[i-1]=stp; + } + + return(ArraySize(ad)); + } +//--------------------------------------------------------------------- +// Get color depending on symbol +//--------------------------------------------------------------------- +color get_currency_color(string _currency) + { + int i; + for(i=0; i +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +// SymbolWatchDisplay class +//--------------------------------------------------------------------- +class SymbolWatchDisplay : public TableDisplay + { +private: + string symbol; // symbol + double point; + int digits; + double point_multiplier; // conversion coefficient for 3/5 digits + +private: + MqlTick curr_tick; // current ticl + datetime times; + double prev_bid; + MqlRates D1_rates[ ]; // daily rates + MqlRates TF_rates[ ]; // bars of the current timeframe + +private: + ENUM_TIMEFRAMES time_frames[]; + +private: + double curr_HiLo; // current daily range + double curr_AvD; // average daily range + +private: + int up_down_shift; // Y coordinate + int left_right_shift; // X coordinate + +public: + void RefreshSymbolInfo(); // Refresh symbol info + void SymbolWatchDisplay(); + void ~SymbolWatchDisplay(); + bool Create(string _symbol,long _chart_id,int _window,int _cols,int _lines,int _ud_shift,int _lr_shift,color _ttl,ENUM_TIMEFRAMES &_tfs[]); + void RedrawSymbolInfo(); // Redraw information + }; +//--------------------------------------------------------------------- +// Constructor +//--------------------------------------------------------------------- +void SymbolWatchDisplay::SymbolWatchDisplay() + { + this.symbol=NULL; + this.up_down_shift=0; + this.left_right_shift=0; + this.curr_HiLo= 0.0; + this.curr_AvD = 0.0; + this.times=0; + this.prev_bid=0.0; + } +//--------------------------------------------------------------------- +// Destructor +//--------------------------------------------------------------------- +void SymbolWatchDisplay::~SymbolWatchDisplay() + { +//// this.Clear( ); + } +//--------------------------------------------------------------------- +// Refresh information +//--------------------------------------------------------------------- +void SymbolWatchDisplay::RedrawSymbolInfo() + { +// Get tick data + ResetLastError(); + if(SymbolInfoTick(this.symbol,this.curr_tick)!=true) + { + this.SetText( 0, "Err " + DoubleToString( GetLastError( ), 0 )); + this.SetColor( 0, Yellow ); + this.SetText( 1, "" ); + this.SetText( 2, "" ); + this.SetText( 3, "" ); + this.SetText( 4, "" ); + this.SetText( 5, "" ); + for(int k=0; kthis.times || this.times==0) + { + this.SetText(0,DoubleToString(this.curr_tick.bid,digits)); + if(this.curr_tick.bid>this.prev_bid && this.prev_bid>0.1) + { + this.SetColor(0,Lime); + } + else if(this.curr_tick.bid0.1) + { + this.SetColor(0,Red); + } + else + { + this.SetColor(0,Yellow); + } + + this.prev_bid=this.curr_tick.bid; + this.times=this.curr_tick.time; + } + this.SetText( 1, DoubleToString( this.point_multiplier * ( this.curr_tick.ask - this.curr_tick.bid ) / this.point, 1 )); + this.SetText( 2, DoubleToString( this.point_multiplier * SymbolInfoInteger( this.symbol, SYMBOL_TRADE_STOPS_LEVEL ), 1 )); + +// get daily bars + if(CopyRates(this.symbol,PERIOD_D1,0,21,this.D1_rates)!=21) + { + this.SetText( 3, "loading.." ); + this.SetColor( 3, Yellow ); + this.SetText( 4, "loading.." ); + this.SetColor( 4, Yellow ); + this.SetText( 5, "loading.." ); + this.SetColor( 5, Yellow ); + return; + } + +// calculate points from the open price + if(this.D1_rates[20].close>this.D1_rates[20].open) + { + this.SetColor( 3, Lime ); + this.SetText( 3, DoubleToString( this.point_multiplier * ( this.D1_rates[ 20 ].close - this.D1_rates[ 20 ].open ) / this.point, 1 )); + } + else if(D1_rates[20].close0.0005) + { + this.SetText( k + 6, "+" + DoubleToString( dev, 3 )); + this.SetColor( k + 6, PaleGreen ); + } + else if(dev<-0.0005) + { + this.SetText( k + 6, " " + DoubleToString( dev, 3 )); + this.SetColor( k + 6, Pink ); + } + else + { + this.SetText( k + 6, " " + DoubleToString( 0.0, 3 )); + this.SetColor( k + 6, Silver ); + } + } + } +//--------------------------------------------------------------------- +// Create graphic object +//--------------------------------------------------------------------- +bool SymbolWatchDisplay::Create(string _symbol,long _chart_id,int _window,int _cols,int _lines,int _ud_shift,int _lr_shift,color _ttl,ENUM_TIMEFRAMES &_tfs[]) + { + this.symbol=_symbol; + this.up_down_shift=_ud_shift; + this.left_right_shift=_lr_shift; + + this.RefreshSymbolInfo( ); + this.SetParams( _chart_id, _window, CORNER_LEFT_UPPER ); + + ArrayResize(this.time_frames,ArraySize(_tfs)); + for(int i=0; i +//--------------------------------------------------------------------- + +//===================================================================== +// External input parameters +//===================================================================== +input ENUM_BASE_CORNER Corner=CORNER_RIGHT_UPPER; +input int UpDownBorderShift=1; +input int LeftRightBorderShift=1; +input color TitlesColor=LightCyan; + +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +TableDisplay Table1; +//--------------------------------------------------------------------- + +#define NUMBER 6 +//--------------------------------------------------------------------- +string titles[]={ "Spread:","Stop Level:","Pips to Open:","Hi to Lo:","Daily Av:" }; +int c1_coord_y[ NUMBER ] = { 1, 3, 4, 6, 7, 8 }; +int c2_coord_y[ NUMBER ] = { 9, 7, 6, 4, 3, 2 }; +int c1_coord_x[ NUMBER ] = { 2, 4, 4, 4, 4, 4 }; +int c2_coord_x[ NUMBER ] = { 4, 2, 2, 2, 2, 2 }; +//--------------------------------------------------------------------- +double rates= 0.0; +datetime times = 0; +MqlTick tick; +MqlRates bars[6]; +//--------------------------------------------------------------------- +#define WIDTH 50 +#define HEIGHT 60 +#define FONTSIZE 12 +//--------------------------------------------------------------------- +// OnInit event handler +//--------------------------------------------------------------------- +int OnInit() + { +// Create table + Table1.SetParams(0,0,Corner); + +// Show prices + for(int i=0; itimes || times==0) + { + Table1.SetText(0,DoubleToString(tick.bid,(int)(SymbolInfoInteger(Symbol(),SYMBOL_DIGITS)))); + if(tick.bid>rates && rates>0.1) + { + Table1.SetColor(0,Lime); + } + else if(tick.bid0.1) + { + Table1.SetColor(0,Red); + } + else + { + Table1.SetColor(0,Yellow); + } + + rates = tick.bid; + times = tick.time; + } + Table1.SetText( 1, DoubleToString(( tick.ask - tick.bid ) / SymbolInfoDouble( Symbol( ), SYMBOL_POINT ), 0 )); + Table1.SetText( 2, DoubleToString( SymbolInfoInteger( Symbol( ), SYMBOL_TRADE_STOPS_LEVEL ), 0 )); + + CopyRates(Symbol(),PERIOD_D1,0,6,bars); + +// Points from day open price + if(bars[5].close>bars[5].open) + { + Table1.SetColor( 3, Lime ); + Table1.SetText( 3, DoubleToString(( bars[ 5 ].close - bars[ 5 ].open ) / SymbolInfoDouble( Symbol( ), SYMBOL_POINT ), 0 )); + } + else if(bars[5].close +//--------------------------------------------------------------------- + +//===================================================================== +// External input parameters +//===================================================================== +input ENUM_BASE_CORNER Corner=CORNER_LEFT_UPPER; +input int UpDownBorderShift=2; +input int LeftRightBorderShift=1; +input color TitlesColor=White; + +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +TableDisplay Table1; +//--------------------------------------------------------------------- + +#define NUMBER 8 +//--------------------------------------------------------------------- +string names[NUMBER]={ "EURUSD","GBPUSD","AUDUSD","NZDUSD","USDCHF","USDCAD","USDJPY","EURJPY" }; +int c1_coord_y[ NUMBER ] = { 0, 1, 2, 3, 4, 5, 6, 7 }; +int c2_coord_y[ NUMBER ] = { 7, 6, 5, 4, 3, 2, 1, 0 }; +//--------------------------------------------------------------------- +double rates[NUMBER]; +datetime times[NUMBER]; +MqlTick tick; +//--------------------------------------------------------------------- +// Обработчик события инициализации: +//--------------------------------------------------------------------- +int OnInit() + { + ArrayInitialize(times,0); + ArrayInitialize(rates,0); + +// Create table + Table1.SetParams(0,0,Corner); + +// Show prices + for(int i=0; itimes[i] || times[i]==0) + { + Table1.SetText(i,DoubleToString(tick.bid,(int)(SymbolInfoInteger(names[i],SYMBOL_DIGITS)))); + if(tick.bid>rates[i] && rates[i]>0.1) + { + Table1.SetColor(i,Lime); + } + else if(tick.bid0.1) + { + Table1.SetColor(i,Red); + } + else + { + Table1.SetColor(i,Yellow); + } + + rates[ i ] = tick.bid; + times[ i ] = tick.time; + } + Table1.SetText(i+NUMBER,DoubleToString(( tick.ask-tick.bid)/SymbolInfoDouble(names[i],SYMBOL_POINT),0)); + } + } +//+------------------------------------------------------------------+ diff --git a/Experts/Articles/179/textdisplay.mqh b/Experts/Articles/179/textdisplay.mqh new file mode 100644 index 0000000..793232f --- /dev/null +++ b/Experts/Articles/179/textdisplay.mqh @@ -0,0 +1,428 @@ +//===================================================================== +// A library for output of text information on the chart. +//===================================================================== + +//--------------------------------------------------------------------- +#property copyright "Dima S., 2010 г." +#property link "dimascub@mail.com" +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +#import "user32.dll" +int GetSystemMetrics(int _index); +#import +//--------------------------------------------------------------------- +#define SM_CXSCREEN 0 +#define SM_CYSCREEN 1 +#define SM_CXFULLSCREEN 16 +#define SM_CYFULLSCREEN 17 +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +// Include libraries +//--------------------------------------------------------------------- +#include +#include +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +// TTitleDisplay class +//--------------------------------------------------------------------- +class TTitleDisplay : public CChartObjectLabel + { +protected: + long chart_id; + int sub_window; + long chart_width; // chart width in pixels + long chart_height; // chart height in pixels + long chart_width_step; // chart width step + long chart_height_step; // chart height step + int columns_number; // number of columns + int lines_number; // number of rows + int curr_column; + int curr_row; + +private: + void SetParams(long _chart_id,int _window,int _cols,int _lines);// set object parameters + +public: + string GetUniqName(); // get unique name + bool Create(long _chart_id,int _window,int _cols,int _lines,int _col,int _row); + void RecalcAndRedraw(); // recalculate coordinates and redraw + +public: + void TTitleDisplay(); // constructor + void ~TTitleDisplay(); // destructor + + }; +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +// Constructor +//--------------------------------------------------------------------- +void TTitleDisplay::TTitleDisplay() + { + } +//--------------------------------------------------------------------- +// Desctructor +//--------------------------------------------------------------------- +void TTitleDisplay::~TTitleDisplay() + { + } +//--------------------------------------------------------------------- +// Create object +//--------------------------------------------------------------------- +bool TTitleDisplay::Create(long _chart_id,int _window,int _cols,int _lines,int _col,int _row) + { + this.curr_column=_col; + this.curr_row=_row; + SetParams(_chart_id,_window,_cols,_lines); + + return(this.Create(this.chart_id,this.GetUniqName(),this.sub_window,(int)(_col*this.chart_width_step),(int)(_row*this.chart_height_step))); + } +//--------------------------------------------------------------------- +// Set object parameters +//--------------------------------------------------------------------- +void TTitleDisplay::SetParams(long _chart_id,int _window,int _cols,int _lines) + { + this.chart_id=_chart_id; + this.sub_window=_window; + this.columns_number=_cols; + this.lines_number=_lines; + +// get chart width in pixels + this.chart_width=GetSystemMetrics(SM_CXFULLSCREEN); + this.chart_height=GetSystemMetrics(SM_CYFULLSCREEN); + +// calculate steps + this.chart_width_step=this.chart_width/_cols; + this.chart_height_step=this.chart_height/_lines; + } +//--------------------------------------------------------------------- +// Recalculate object parameters and redraw +//--------------------------------------------------------------------- +void TTitleDisplay::RecalcAndRedraw() + { +// Get size of the chart (in pixels) + long width=GetSystemMetrics(SM_CXFULLSCREEN); + long height=GetSystemMetrics(SM_CYFULLSCREEN); + if(width==this.chart_width && height==this.chart_height) + { + return; + } + + this.chart_width=width; + this.chart_height=height; + +// Recalculate steps + this.chart_width_step=this.chart_width/this.columns_number; + this.chart_height_step=this.chart_height/this.lines_number; + +// Move object to new coordinates + this.X_Distance(( int )( this.curr_column * this.chart_width_step )); + this.Y_Distance(( int )( this.curr_row * this.chart_height_step )); + } +//--------------------------------------------------------------------- +// Get unique name +//--------------------------------------------------------------------- +string TTitleDisplay::GetUniqName() + { + static uint prev_count=0; + + uint count=GetTickCount(); + while(1) + { + if(prev_count==UINT_MAX) + { + prev_count=0; + } + if(count<=prev_count) + { + prev_count++; + count=prev_count; + } + else + { + prev_count=count; + } + + // Check the presence of the object with the same name + string name=TimeToString(TimeGMT(),TIME_DATE|TIME_MINUTES|TIME_SECONDS)+" "+DoubleToString(count,0); + if(ObjectFind(0,name)<0) + { + return(name); + } + } + + return(NULL); + } +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +// TFieldDisplay class +//--------------------------------------------------------------------- +class TFieldDisplay : public CChartObjectEdit + { +protected: + long chart_id; + int sub_window; + long chart_width; // chart width in pixels + long chart_height; // chart height in pixels + long chart_width_step; // horizontal step size + long chart_height_step; // vertical step size + int columns_number; // number of columns + int limes_number; // number of rows + int curr_column; + int curr_row; + +private: + int type; // edit field type ( string, numerical ) + +private: + void SetParams(long _chart_id,int _window,int _cols,int _lines);// set object parameters + +public: + string GetUniqName(); // get unique name + bool Create(long _chart_id,int _window,int _cols,int _lines,int _col,int _row); + void RecalcAndRedraw(); // recalculate coordinates and redraw + +public: + void TFieldDisplay(); // constructor + void ~TFieldDisplay(); // desctructor + }; +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +// Constructor +//--------------------------------------------------------------------- +void TFieldDisplay::TFieldDisplay() + { + } +//--------------------------------------------------------------------- +// Destructor +//--------------------------------------------------------------------- +void TFieldDisplay::~TFieldDisplay() + { + } +//--------------------------------------------------------------------- +// Create object +//--------------------------------------------------------------------- +bool TFieldDisplay::Create(long _chart_id,int _window,int _cols,int _lines,int _col,int _row) + { + this.curr_column=_col; + this.curr_row=_row; + SetParams(_chart_id,_window,_cols,_lines); + + return(this.Create(this.chart_id,this.GetUniqName(),this.sub_window,(int)(_col*this.chart_width_step),(int)(_row*this.chart_height_step))); + } +//--------------------------------------------------------------------- +// Set object parameters +//--------------------------------------------------------------------- +void TFieldDisplay::SetParams(long _chart_id,int _window,int _cols,int _lines) + { + this.chart_id=_chart_id; + this.sub_window=_window; + this.columns_number=_cols; + this.limes_number=_lines; + +// get window width in pixels + this.chart_width=GetSystemMetrics(SM_CXFULLSCREEN); + this.chart_height=GetSystemMetrics(SM_CYFULLSCREEN); + +// calculate steps + this.chart_width_step=this.chart_width/_cols; + this.chart_height_step=this.chart_height/_lines; + } +//--------------------------------------------------------------------- +// Recalculate and redraw +//--------------------------------------------------------------------- +void TFieldDisplay::RecalcAndRedraw() + { +// get window size (in pixels) + long width=GetSystemMetrics(SM_CXFULLSCREEN); + long height=GetSystemMetrics(SM_CYFULLSCREEN); + if(width==this.chart_width && height==this.chart_height) + { + return; + } + + this.chart_width=width; + this.chart_height=height; + +// Calculate steps + this.chart_width_step=this.chart_width/this.columns_number; + this.chart_height_step=this.chart_height/this.limes_number; + +// Move object to new coordinates + this.X_Distance(( int )( this.curr_column * this.chart_width_step )); + this.Y_Distance(( int )( this.curr_row * this.chart_height_step )); + } +//--------------------------------------------------------------------- +// Get unique name +//--------------------------------------------------------------------- +string TFieldDisplay::GetUniqName() + { + static uint prev_count=0; + + uint count=GetTickCount(); + while(1) + { + if(prev_count==UINT_MAX) + { + prev_count=0; + } + if(count<=prev_count) + { + prev_count++; + count=prev_count; + } + else + { + prev_count=count; + } + + // Проверим, нет ли уже объекта с таким именем: + string name=TimeToString(TimeGMT(),TIME_DATE|TIME_MINUTES|TIME_SECONDS)+" "+DoubleToString(count,0); + if(ObjectFind(0,name)<0) + { + return(name); + } + } + + return(NULL); + } +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +// TableDisplay class (List of objects) +//--------------------------------------------------------------------- +class TableDisplay : public CList + { +protected: + long chart_id; + int sub_window; + ENUM_BASE_CORNER corner; + +public: + void SetParams(long _chart_id,int _window,ENUM_BASE_CORNER _corner=CORNER_LEFT_UPPER); + int AddTitleObject(int _cols,int _lines,int _col,int _row,string _title,color _color,string _fontname="Arial",int _fontsize=10); + int AddFieldObject(int _cols,int _lines,int _col,int _row,color _color,string _fontname="Arial",int _fontsize=10); + bool SetColor(int _index,color _color); + bool SetFont(int _index,string _fontname,int _fontsize); + bool SetText(int _index,string _text); + bool SetAnchor(int _index,ENUM_ANCHOR_POINT _anchor); + +public: + void TableDisplay(); + void ~TableDisplay(); + }; +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +// Constructor +//--------------------------------------------------------------------- +void TableDisplay::TableDisplay() + { + this.chart_id=0; + this.sub_window=0; + this.corner=CORNER_LEFT_UPPER; + } +//--------------------------------------------------------------------- +// Destructor +//--------------------------------------------------------------------- +void TableDisplay::~TableDisplay() + { +// Delete all objects + this.Clear(); + } +//--------------------------------------------------------------------- +// Set common parameters for all list objects +//--------------------------------------------------------------------- +void TableDisplay::SetParams(long _chart_id,int _window,ENUM_BASE_CORNER _corner) + { + this.chart_id=_chart_id; + this.sub_window=_window; + this.corner=_corner; + } +//--------------------------------------------------------------------- +// Add a header (title) object +//--------------------------------------------------------------------- +int TableDisplay::AddTitleObject(int _cols,int _lines,int _col,int _row,string _title,color _color,string _fontname,int _fontsize) + { + TTitleDisplay *title=new TTitleDisplay(); + title.Create( this.chart_id, this.sub_window, _cols, _lines, _col, _row ); + title.Description( _title ); + title.Color( _color ); + title.Font( _fontname ); + title.FontSize( _fontsize ); + title.Corner( this.corner ); + return(this.Add(title)); + } +//--------------------------------------------------------------------- +// Add Edit Field object +//--------------------------------------------------------------------- +int TableDisplay::AddFieldObject(int _cols,int _lines,int _col,int _row,color _color,string _fontname,int _fontsize) + { + TFieldDisplay *field=new TFieldDisplay(); + field.Create( this.chart_id, this.sub_window, _cols, _lines, _col, _row ); + field.Description( "" ); + field.Color( _color ); + field.Font( _fontname ); + field.FontSize( _fontsize ); + field.Corner( this.corner ); + return(this.Add(field)); + } +//--------------------------------------------------------------------- +// Set Anchor points +//--------------------------------------------------------------------- +bool TableDisplay::SetAnchor(int _index,ENUM_ANCHOR_POINT _anchor) + { + CChartObjectText *object=GetNodeAtIndex(_index); + if(object==NULL) + { + return(false); + } + return(object.Anchor(_anchor)); + } +//--------------------------------------------------------------------- +// Set color of graphic object +//--------------------------------------------------------------------- +bool TableDisplay::SetColor(int _index,color _color) + { + CChartObjectText *object=GetNodeAtIndex(_index); + if(object==NULL) + { + return(false); + } + return(object.Color(_color)); + } +//--------------------------------------------------------------------- +// Set font +//--------------------------------------------------------------------- +bool TableDisplay::SetFont(int _index,string _fontname,int _fontsize) + { + CChartObjectText *object=GetNodeAtIndex(_index); + if(object==NULL) + { + return(false); + } + + if(object.Font(_fontname)==false) + { + return(false); + } + return(object.FontSize(_fontsize)); + } +//--------------------------------------------------------------------- +// Set text +//--------------------------------------------------------------------- +bool TableDisplay::SetText(int _index,string _text) + { + CChartObjectText *object=GetNodeAtIndex(_index); + if(object==NULL) + { + return(false); + } + return(object.Description(_text)); + } +//--------------------------------------------------------------------- diff --git a/Experts/Articles/2358.zip b/Experts/Articles/2358.zip new file mode 100644 index 0000000..5edfb71 Binary files /dev/null and b/Experts/Articles/2358.zip differ diff --git a/Experts/Articles/2358/UnExpert.zip b/Experts/Articles/2358/UnExpert.zip new file mode 100644 index 0000000..16d0ba9 Binary files /dev/null and b/Experts/Articles/2358/UnExpert.zip differ diff --git a/Experts/Articles/2358/UnExpert/Impulse 2.0.mq5 b/Experts/Articles/2358/UnExpert/Impulse 2.0.mq5 new file mode 100644 index 0000000..e1f5bd0 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Impulse 2.0.mq5 differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/ComplexPosition.mqh b/Experts/Articles/2358/UnExpert/Strategy/ComplexPosition.mqh new file mode 100644 index 0000000..315b4fb Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/ComplexPosition.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Dictionary.mqh b/Experts/Articles/2358/UnExpert/Strategy/Dictionary.mqh new file mode 100644 index 0000000..f456814 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Dictionary.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/EquityListener.mqh b/Experts/Articles/2358/UnExpert/Strategy/EquityListener.mqh new file mode 100644 index 0000000..bc2b1bc Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/EquityListener.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Indicators.mqh b/Experts/Articles/2358/UnExpert/Strategy/Indicators.mqh new file mode 100644 index 0000000..b74527a Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Indicators.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Logs.mqh b/Experts/Articles/2358/UnExpert/Strategy/Logs.mqh new file mode 100644 index 0000000..6f829e7 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Logs.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/MarketBook.mqh b/Experts/Articles/2358/UnExpert/Strategy/MarketBook.mqh new file mode 100644 index 0000000..4454c14 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/MarketBook.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Message.mqh b/Experts/Articles/2358/UnExpert/Strategy/Message.mqh new file mode 100644 index 0000000..b6b3b64 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Message.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/MoneyManagment.mqh b/Experts/Articles/2358/UnExpert/Strategy/MoneyManagment.mqh new file mode 100644 index 0000000..d3a2ad6 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/MoneyManagment.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/NewBarDetector.mqh b/Experts/Articles/2358/UnExpert/Strategy/NewBarDetector.mqh new file mode 100644 index 0000000..7184348 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/NewBarDetector.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/NewTickDetector.mqh b/Experts/Articles/2358/UnExpert/Strategy/NewTickDetector.mqh new file mode 100644 index 0000000..89a7ddc Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/NewTickDetector.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Panel/AgentForm.mqh b/Experts/Articles/2358/UnExpert/Strategy/Panel/AgentForm.mqh new file mode 100644 index 0000000..4107627 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Panel/AgentForm.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Panel/ElButton.mqh b/Experts/Articles/2358/UnExpert/Strategy/Panel/ElButton.mqh new file mode 100644 index 0000000..d442eeb Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Panel/ElButton.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Panel/ElChart.mqh b/Experts/Articles/2358/UnExpert/Strategy/Panel/ElChart.mqh new file mode 100644 index 0000000..925a816 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Panel/ElChart.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Panel/ElDropDownList.mqh b/Experts/Articles/2358/UnExpert/Strategy/Panel/ElDropDownList.mqh new file mode 100644 index 0000000..8325cc9 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Panel/ElDropDownList.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/Event.mqh b/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/Event.mqh new file mode 100644 index 0000000..28a611f Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/Event.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventChart.mqh b/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventChart.mqh new file mode 100644 index 0000000..cc16326 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventChart.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventChartEndEdit.mqh b/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventChartEndEdit.mqh new file mode 100644 index 0000000..f186796 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventChartEndEdit.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventChartListChanged.mqh b/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventChartListChanged.mqh new file mode 100644 index 0000000..af0c157 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventChartListChanged.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventChartMouseMove.mqh b/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventChartMouseMove.mqh new file mode 100644 index 0000000..e12d642 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventChartMouseMove.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventChartObjClick.mqh b/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventChartObjClick.mqh new file mode 100644 index 0000000..7da4d0d Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventChartObjClick.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventRefresh.mqh b/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventRefresh.mqh new file mode 100644 index 0000000..0038da9 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Panel/Events/EventRefresh.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Panel/Node.mqh b/Experts/Articles/2358/UnExpert/Strategy/Panel/Node.mqh new file mode 100644 index 0000000..478b5ee Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Panel/Node.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Panel/ObjText.mqh b/Experts/Articles/2358/UnExpert/Strategy/Panel/ObjText.mqh new file mode 100644 index 0000000..736ab6d Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Panel/ObjText.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Panel/Panel.mqh b/Experts/Articles/2358/UnExpert/Strategy/Panel/Panel.mqh new file mode 100644 index 0000000..874658a Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Panel/Panel.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/PendingOrders.mqh b/Experts/Articles/2358/UnExpert/Strategy/PendingOrders.mqh new file mode 100644 index 0000000..9313a7e Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/PendingOrders.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Position.mqh b/Experts/Articles/2358/UnExpert/Strategy/Position.mqh new file mode 100644 index 0000000..0289b60 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Position.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/PositionMT5.mqh b/Experts/Articles/2358/UnExpert/Strategy/PositionMT5.mqh new file mode 100644 index 0000000..b048ea5 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/PositionMT5.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/RSquare.mqh b/Experts/Articles/2358/UnExpert/Strategy/RSquare.mqh new file mode 100644 index 0000000..66b45a3 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/RSquare.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Series.mqh b/Experts/Articles/2358/UnExpert/Strategy/Series.mqh new file mode 100644 index 0000000..dce27d6 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Series.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/SessionInfo.mqh b/Experts/Articles/2358/UnExpert/Strategy/SessionInfo.mqh new file mode 100644 index 0000000..068a53d Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/SessionInfo.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/SignalAdapter.mqh b/Experts/Articles/2358/UnExpert/Strategy/SignalAdapter.mqh new file mode 100644 index 0000000..2517bde Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/SignalAdapter.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/StrategiesList.mqh b/Experts/Articles/2358/UnExpert/Strategy/StrategiesList.mqh new file mode 100644 index 0000000..0abbcc2 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/StrategiesList.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Strategy.mqh b/Experts/Articles/2358/UnExpert/Strategy/Strategy.mqh new file mode 100644 index 0000000..35bde4b Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Strategy.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/StrategyParamsBase.mqh b/Experts/Articles/2358/UnExpert/Strategy/StrategyParamsBase.mqh new file mode 100644 index 0000000..f76e5d0 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/StrategyParamsBase.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Symbol.mqh b/Experts/Articles/2358/UnExpert/Strategy/Symbol.mqh new file mode 100644 index 0000000..b2f13ae Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Symbol.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Target.mqh b/Experts/Articles/2358/UnExpert/Strategy/Target.mqh new file mode 100644 index 0000000..d6956d5 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Target.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/TimeSeries.mqh b/Experts/Articles/2358/UnExpert/Strategy/TimeSeries.mqh new file mode 100644 index 0000000..84d71e4 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/TimeSeries.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/TimeValue.mqh b/Experts/Articles/2358/UnExpert/Strategy/TimeValue.mqh new file mode 100644 index 0000000..42448b5 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/TimeValue.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/TradeControl.mqh b/Experts/Articles/2358/UnExpert/Strategy/TradeControl.mqh new file mode 100644 index 0000000..4f9520f Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/TradeControl.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/TradeCustom.mqh b/Experts/Articles/2358/UnExpert/Strategy/TradeCustom.mqh new file mode 100644 index 0000000..6a15611 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/TradeCustom.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/TradeEnvironment.mqh b/Experts/Articles/2358/UnExpert/Strategy/TradeEnvironment.mqh new file mode 100644 index 0000000..57f6dff Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/TradeEnvironment.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/TradeState.mqh b/Experts/Articles/2358/UnExpert/Strategy/TradeState.mqh new file mode 100644 index 0000000..59106c4 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/TradeState.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Trailings/ClassicTrailing (OLD).mqh b/Experts/Articles/2358/UnExpert/Strategy/Trailings/ClassicTrailing (OLD).mqh new file mode 100644 index 0000000..76e1c1f Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Trailings/ClassicTrailing (OLD).mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Trailings/Trailing.mqh b/Experts/Articles/2358/UnExpert/Strategy/Trailings/Trailing.mqh new file mode 100644 index 0000000..b37747e Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Trailings/Trailing.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Trailings/TrailingClassic.mqh b/Experts/Articles/2358/UnExpert/Strategy/Trailings/TrailingClassic.mqh new file mode 100644 index 0000000..53bc45c Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Trailings/TrailingClassic.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/Trailings/TrailingMoving.mqh b/Experts/Articles/2358/UnExpert/Strategy/Trailings/TrailingMoving.mqh new file mode 100644 index 0000000..9a6dc2b Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/Trailings/TrailingMoving.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/UsingTrailing.mqh b/Experts/Articles/2358/UnExpert/Strategy/UsingTrailing.mqh new file mode 100644 index 0000000..c8d9c61 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/UsingTrailing.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/XML/XmlAttribute.mqh b/Experts/Articles/2358/UnExpert/Strategy/XML/XmlAttribute.mqh new file mode 100644 index 0000000..8c71ae8 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/XML/XmlAttribute.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/XML/XmlBase.mqh b/Experts/Articles/2358/UnExpert/Strategy/XML/XmlBase.mqh new file mode 100644 index 0000000..fa0a90f Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/XML/XmlBase.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/XML/XmlDocument.mqh b/Experts/Articles/2358/UnExpert/Strategy/XML/XmlDocument.mqh new file mode 100644 index 0000000..0aa27c8 Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/XML/XmlDocument.mqh differ diff --git a/Experts/Articles/2358/UnExpert/Strategy/XML/XmlElement.mqh b/Experts/Articles/2358/UnExpert/Strategy/XML/XmlElement.mqh new file mode 100644 index 0000000..be723fc Binary files /dev/null and b/Experts/Articles/2358/UnExpert/Strategy/XML/XmlElement.mqh differ diff --git a/Experts/Articles/357.zip b/Experts/Articles/357.zip new file mode 100644 index 0000000..2144588 Binary files /dev/null and b/Experts/Articles/357.zip differ diff --git a/Experts/Articles/357/multi_currency_panel_oop_mql5.zip b/Experts/Articles/357/multi_currency_panel_oop_mql5.zip new file mode 100644 index 0000000..80b7538 Binary files /dev/null and b/Experts/Articles/357/multi_currency_panel_oop_mql5.zip differ diff --git a/Experts/Articles/357/multi_currency_panel_oop_mql5/MQL5/Include/PriceChangeRow.mqh b/Experts/Articles/357/multi_currency_panel_oop_mql5/MQL5/Include/PriceChangeRow.mqh new file mode 100644 index 0000000..f5e69c4 --- /dev/null +++ b/Experts/Articles/357/multi_currency_panel_oop_mql5/MQL5/Include/PriceChangeRow.mqh @@ -0,0 +1,107 @@ +//+------------------------------------------------------------------+ +//| PriceChangeRow.mqh | +//| Marcin Konieczny | +//| | +//+------------------------------------------------------------------+ +#property copyright "Marcin Konieczny" + +#include +//+------------------------------------------------------------------+ +//| CPriceChangeRow class | +//+------------------------------------------------------------------+ +class CPriceChangeRow : public CRow + { +private: + bool percentChange; + bool useArrows; + +public: + //--- constructor + CPriceChangeRow(bool arrows,bool percent=false); + + //--- overrides default GetName() method from CRow + virtual string GetName(); + + //--- overrides default GetFont() method from CRow + virtual string GetFont(string symbol,ENUM_TIMEFRAMES tf); + + //--- overrides default GetValue(..) method from CRow + virtual string GetValue(string symbol,ENUM_TIMEFRAMES tf); + + //--- overrides default GetColor(..) method from CRow + virtual color GetColor(string symbol,ENUM_TIMEFRAMES tf); + + }; +//+------------------------------------------------------------------+ +//| CPriceChangeRow class constructor | +//+------------------------------------------------------------------+ +CPriceChangeRow::CPriceChangeRow(bool arrows,bool percent=false) + { + percentChange=percent; + useArrows=arrows; + } +//+------------------------------------------------------------------+ +//| Overrides default GetName() method from CRow | +//+------------------------------------------------------------------+ + string CPriceChangeRow::GetName() + { + return("PriceChg"); + } +//+------------------------------------------------------------------+ +//| Overrides default GetFont() method from CRow | +//+------------------------------------------------------------------+ +string CPriceChangeRow::GetFont(string symbol,ENUM_TIMEFRAMES tf) + { +//--- we use Wingdings font to draw arrows (up/down) + if(useArrows) + return("Wingdings"); + else + return("Arial"); + } +//+------------------------------------------------------------------+ +//| Overrides default GetValue(..) method from CRow | +//+------------------------------------------------------------------+ +string CPriceChangeRow::GetValue(string symbol,ENUM_TIMEFRAMES tf) + { + double close[1]; + double open[1]; + +//--- gets open and close of current bar + if(CopyClose(symbol,tf,0, 1, close) < 0) return(" "); + if(CopyOpen(symbol, tf, 0, 1, open) < 0) return(" "); + +//--- current bar price change + double change=close[0]-open[0]; + + if(useArrows) + { + if(change > 0) return(CharToString(233)); // returns up arrow code + if(change < 0) return(CharToString(234)); // returns down arrow code + return(" "); + }else{ + if(percentChange) + { + //--- calculates percent change + return(DoubleToString(change/open[0]*100.0,3)+"%"); + }else{ + return(DoubleToString(change,(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS))); + } + } + } +//+------------------------------------------------------------------+ +//| Overrides default GetColor(..) method from CRow | +//+------------------------------------------------------------------+ +color CPriceChangeRow::GetColor(string symbol,ENUM_TIMEFRAMES tf) + { + double close[1]; + double open[1]; + +//--- gets open and close of current bar + if(CopyClose(symbol,tf,0, 1, close) < 0) return(clrWhite); + if(CopyOpen(symbol, tf, 0, 1, open) < 0) return(clrWhite); + + if(close[0] > open[0]) return(clrLime); + if(close[0] < open[0]) return(clrRed); + return(clrWhite); + } +//+------------------------------------------------------------------+ diff --git a/Experts/Articles/357/multi_currency_panel_oop_mql5/MQL5/Include/PriceMARow.mqh b/Experts/Articles/357/multi_currency_panel_oop_mql5/MQL5/Include/PriceMARow.mqh new file mode 100644 index 0000000..5189d17 --- /dev/null +++ b/Experts/Articles/357/multi_currency_panel_oop_mql5/MQL5/Include/PriceMARow.mqh @@ -0,0 +1,118 @@ +//+------------------------------------------------------------------+ +//| PriceMARow.mqh | +//| Marcin Konieczny | +//| | +//+------------------------------------------------------------------+ +#property copyright "Marcin Konieczny" + +#include +//+------------------------------------------------------------------+ +//| CPriceMARow class | +//+------------------------------------------------------------------+ +class CPriceMARow : public CRow + { +private: + int maPeriod; // period of moving average + int maShift; // shift of moving average + ENUM_MA_METHOD maType; // SMA, EMA, SMMA or LWMA + string symbols[]; // symbols array + ENUM_TIMEFRAMES timeframes[]; // timeframes array + int handles[]; // array of MA handles + + //--- finds the indicator handle for a given symbol and timeframe + int GetHandle(string symbol,ENUM_TIMEFRAMES tf); + +public: + //--- constructor + CPriceMARow(ENUM_MA_METHOD type,int period,int shift); + + //--- overrides default GetValue(..) method of CRow + virtual string GetValue(string symbol,ENUM_TIMEFRAMES tf); + + // overrides default GetName() method CRow + virtual string GetName(); + + //--- overrides default Init(..) method from CRow + virtual void Init(string &symb[],ENUM_TIMEFRAMES &tfs[]); + }; +//+------------------------------------------------------------------+ +//| CPriceMARow class constructor | +//+------------------------------------------------------------------+ +CPriceMARow::CPriceMARow(ENUM_MA_METHOD type,int period,int shift) + { + maPeriod= period; + maShift = shift; + maType=type; + } +//+------------------------------------------------------------------+ +//| Overrides default Init(..) method from CRow | +//+------------------------------------------------------------------+ +void CPriceMARow::Init(string &symb[],ENUM_TIMEFRAMES &tfs[]) + { + int size=ArraySize(symb); + + ArrayResize(symbols,size); + ArrayResize(timeframes,size); + ArrayResize(handles,size); + +//--- copies arrays contents into own arrays + ArrayCopy(symbols,symb); + ArrayCopy(timeframes,tfs); + +//--- gets MA handles for all used symbols or timeframes + for(int i=0; i MA + if(tick.bid>value[0]) + return("Yes"); + else + return("No"); + } +//+------------------------------------------------------------------+ +//| Overrides default GetName() method of CRow | +//+------------------------------------------------------------------+ +string CPriceMARow::GetName() + { + string name; + + switch(maType) + { + case MODE_SMA: name = "SMA"; break; + case MODE_EMA: name = "EMA"; break; + case MODE_SMMA: name = "SMMA"; break; + case MODE_LWMA: name = "LWMA"; break; + } + + return("Price>"+name+"("+IntegerToString(maPeriod)+")"); + } +//+------------------------------------------------------------------+ +//| finds the indicator handle for a given symbol and timeframe | +//+------------------------------------------------------------------+ +int CPriceMARow::GetHandle(string symbol,ENUM_TIMEFRAMES tf) + { + for(int i=0; i +//+------------------------------------------------------------------+ +//| CPriceRow class | +//+------------------------------------------------------------------+ +class CPriceRow : public CRow + { +public: + //--- overrides default GetValue(..) method from CRow + virtual string GetValue(string symbol,ENUM_TIMEFRAMES tf); + + //--- overrides default GetName() method from CRow + virtual string GetName(); + + }; +//+------------------------------------------------------------------+ +//| Overrides default GetValue(..) method from CRow | +//+------------------------------------------------------------------+ +string CPriceRow::GetValue(string symbol,ENUM_TIMEFRAMES tf) + { + MqlTick tick; + +//--- gets current price + if(!SymbolInfoTick(symbol,tick)) return("-"); + + return(DoubleToString(tick.bid,(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS))); + } +//+------------------------------------------------------------------+ +//| Overrides default GetName() method from CRow | +//+------------------------------------------------------------------+ +string CPriceRow::GetName() + { + return("Price"); + } +//+------------------------------------------------------------------+ diff --git a/Experts/Articles/357/multi_currency_panel_oop_mql5/MQL5/Include/RSIRow.mqh b/Experts/Articles/357/multi_currency_panel_oop_mql5/MQL5/Include/RSIRow.mqh new file mode 100644 index 0000000..ab06133 --- /dev/null +++ b/Experts/Articles/357/multi_currency_panel_oop_mql5/MQL5/Include/RSIRow.mqh @@ -0,0 +1,97 @@ +//+------------------------------------------------------------------+ +//| RSIRow.mqh | +//| Marcin Konieczny | +//| | +//+------------------------------------------------------------------+ +#property copyright "Marcin Konieczny" + +#include +//+------------------------------------------------------------------+ +//| CRSIRow class | +//+------------------------------------------------------------------+ +class CRSIRow : public CRow + { +private: + int rsiPeriod; // RSI period + string symbols[]; // symbols array + ENUM_TIMEFRAMES timeframes[]; // timeframes array + int handles[]; // array of RSI handles + + //--- finds the indicator handle for a given symbol and timeframe + int GetHandle(string symbol,ENUM_TIMEFRAMES tf); + +public: + //--- constructor + CRSIRow(int period); + + //--- overrides default GetValue(..) method from CRow + virtual string GetValue(string symbol,ENUM_TIMEFRAMES tf); + + //--- overrides default GetName() method from CRow + virtual string GetName(); + + //--- overrides default Init(..) method from CRow + virtual void Init(string &symb[],ENUM_TIMEFRAMES &tfs[]); + }; +//+------------------------------------------------------------------+ +//| Constructor | +//+------------------------------------------------------------------+ +CRSIRow::CRSIRow(int period) + { + rsiPeriod=period; + } +//+------------------------------------------------------------------+ +//| Overrides default Init(..) method from CRow | +//+------------------------------------------------------------------+ +void CRSIRow::Init(string &symb[],ENUM_TIMEFRAMES &tfs[]) + { + int size=ArraySize(symb); + + ArrayResize(symbols,size); + ArrayResize(timeframes,size); + ArrayResize(handles,size); + +//--- copies arrays contents into own arrays + ArrayCopy(symbols,symb); + ArrayCopy(timeframes,tfs); + +//--- gets RSI handles for all used symbols or timeframes + for(int i=0; i +//+------------------------------------------------------------------+ +//| CRow class | +//+------------------------------------------------------------------+ +//| Base class for creating custom table rows | +//| one or more methods of CRow should be overriden | +//| when creating own table rows | +//+------------------------------------------------------------------+ +class CRow : public CObject + { +public: + //--- default initialization method + virtual void Init(string &symb[],ENUM_TIMEFRAMES &tfs[]) { } + + //--- default method for obtaining string value to display in the table cell + virtual string GetValue(string symbol,ENUM_TIMEFRAMES tf) { return("-"); } + + //--- default method for obtaining color for table cell + virtual color GetColor(string symbol,ENUM_TIMEFRAMES tf) { return(clrWhite); } + + //--- default method for obtaining row name + virtual string GetName() { return("-"); } + + //--- default method for obtaining font for table cell + virtual string GetFont(string symbol,ENUM_TIMEFRAMES tf) { return("Arial"); } + }; +//+------------------------------------------------------------------+ diff --git a/Experts/Articles/357/multi_currency_panel_oop_mql5/MQL5/Include/Table.mqh b/Experts/Articles/357/multi_currency_panel_oop_mql5/MQL5/Include/Table.mqh new file mode 100644 index 0000000..965135d --- /dev/null +++ b/Experts/Articles/357/multi_currency_panel_oop_mql5/MQL5/Include/Table.mqh @@ -0,0 +1,257 @@ +//+------------------------------------------------------------------+ +//| CTable.mqh | +//| Marcin Konieczny | +//| | +//+------------------------------------------------------------------+ +#property copyright "Marcin Konieczny" + +#include +#include + +const string nameBase="Table_Coord#"; // prefix for all label objects used by table +//+------------------------------------------------------------------+ +//| CTable class | +//+------------------------------------------------------------------+ +class CTable + { +private: + int xDistance; // distance from right border of the chart + int yDistance; // distance from top of the chart + int cellHeight; // table cell height + int cellWidth; // table cell width + string font; // font name + int fontSize; + color fontColor; + + CList *rowList; // list of row objects + bool tfMode; // is in multi-timeframe mode? + + ENUM_TIMEFRAMES timeframes[]; // array of timeframes for multi-timeframe mode + string symbols[]; // array of currency pairs for multi-currency mode + + //--- private methods + //--- sets default parameters of the table + void Init(); + //--- draws text label in the specified table cell + void DrawLabel(int x,int y,string text,string font,color col); + //--- returns textual representation of given timeframe + string PeriodToString(ENUM_TIMEFRAMES period); + +public: + //--- multi-timeframe mode constructor + CTable(ENUM_TIMEFRAMES &tfs[]); + //--- multi-currency mode constructor + CTable(string &symb[]); + //--- destructor + ~CTable(); + //--- redraws table + void Update(); + //--- methods for setting table parameters + void SetDistance(int xDist,int yDist); + void SetCellSize(int cellW,int cellH); + void SetFont(string fnt,int size,color clr); + //--- appends CRow object to the of the table + void AddRow(CRow *row); + }; +//+------------------------------------------------------------------+ +//| Multi-timeframe mode constructor | +//+------------------------------------------------------------------+ +CTable::CTable(ENUM_TIMEFRAMES &tfs[]) + { +//--- copy all timeframes to own array + ArrayResize(timeframes,ArraySize(tfs),0); + ArrayCopy(timeframes,tfs); + tfMode=true; + +//--- fill symbols array with current chart symbol + ArrayResize(symbols,ArraySize(tfs),0); + for(int i=0; i=0; i--) + if(StringFind(ObjectName(0,i),nameBase)!=-1) + ObjectDelete(0,ObjectName(0,i)); + +//--- delete list of rows and free memory + delete(rowList); + } +//+------------------------------------------------------------------+ +//| Appends new row to the end of the table | +//+------------------------------------------------------------------+ +CTable::AddRow(CRow *row) + { + rowList.Add(row); + row.Init(symbols,timeframes); + } +//+------------------------------------------------------------------+ +//| Redraws the table | +//+------------------------------------------------------------------+ +CTable::Update() + { + CRow *row; + string symbol; + ENUM_TIMEFRAMES tf; + + int rows=rowList.Total(); // number of rows + int columns; // number of columns + + if(tfMode) + columns=ArraySize(timeframes); + else + columns=ArraySize(symbols); + +//--- draw first column (names of rows) + for(int y=0; y +#include +#include +#include +#include + +CTable *table; // pointer to CTable object +//+------------------------------------------------------------------+ +//| Indicator initialization function | +//+------------------------------------------------------------------+ +int OnInit() + { +//--- timeframes used in table (in multi-timeframe mode) + ENUM_TIMEFRAMES timeframes[4]={PERIOD_M1,PERIOD_H1,PERIOD_D1,PERIOD_W1}; + +//--- symbols used in table (in multi-currency mode) + string symbols[4]={"EURUSD","GBPUSD","USDJPY","AUDCHF" }; +//-- CTable object creation +// table = new CTable(timeframes); // multi-timeframe mode + table=new CTable(symbols); // multi-currency mode + +//--- adding rows to the table + table.AddRow(new CPriceRow()); // shows current price + table.AddRow(new CPriceChangeRow(false)); // shows change of price in the last bar + table.AddRow(new CPriceChangeRow(false,true)); // shows percent change of price in the last bar + table.AddRow(new CPriceChangeRow(true)); // shows change of price as arrows + table.AddRow(new CRSIRow(14)); // shows RSI(14) + table.AddRow(new CRSIRow(10)); // shows RSI(10) + table.AddRow(new CPriceMARow(MODE_SMA,20,0)); // shows if SMA(20) > current price + +//--- setting table parameters + table.SetFont("Arial",10,clrYellow); // font, size, color + table.SetCellSize(60, 20); // width, height + table.SetDistance(10, 10); // distance from upper right chart corner + + table.Update(); // forces table to redraw + + return(0); + } +//+------------------------------------------------------------------+ +//| Indicator deinitialization function | +//+------------------------------------------------------------------+ +void OnDeinit(const int reason) + { +//--- calls table destructor and frees memory + delete(table); + } +//+------------------------------------------------------------------+ +//| Indicator iteration function | +//+------------------------------------------------------------------+ +int OnCalculate(const int rates_total, + const int prev_calculated, + const int begin, + const double &price[]) + { +//--- update table: recalculate/repaint + table.Update(); + return(rates_total); + } +//+------------------------------------------------------------------+ +//| OnChartEvent handler | +//| Handles CHARTEVENT_CUSTOM events sent by SpyAgent indicators | +//| Nedeed only in multi-currency mode! | +//+------------------------------------------------------------------+ +void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam) + { + table.Update(); // update table: recalculate/repaint + } +//+------------------------------------------------------------------+ diff --git a/Experts/Articles/37.zip b/Experts/Articles/37.zip new file mode 100644 index 0000000..439fcb0 Binary files /dev/null and b/Experts/Articles/37.zip differ diff --git a/Experts/Articles/37/sma.mq5 b/Experts/Articles/37/sma.mq5 new file mode 100644 index 0000000..d14c37c --- /dev/null +++ b/Experts/Articles/37/sma.mq5 @@ -0,0 +1,53 @@ +//+------------------------------------------------------------------+ +//| SMA.mq5 | +//| Copyright 2009, MetaQuotes Software Corp. | +//| http://www.mql5.com | +//+------------------------------------------------------------------+ +#property indicator_chart_window +#property indicator_buffers 1 +#property indicator_plots 1 +#property indicator_type1 DRAW_LINE +#property indicator_color1 Red + +input int MAPeriod= 13; +input int MAShift = 0; + +double ExtLineBuffer[]; +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +void OnInit() + { + SetIndexBuffer(0,ExtLineBuffer,INDICATOR_DATA); + PlotIndexSetInteger(0,PLOT_SHIFT,MAShift); + PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,MAPeriod); + } +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +int OnCalculate(const int rates_total,const int prev_calculated,const int begin,const double &price[]) + { + if(rates_total=PointTime || aTimePre=PointTime && aTimePre=StartTime || aTimeCur=StartTime && aTimeCur=StartTime || TimeCur=StartTime && TimeCur=StartTime || aTimeCur=StartTime && aTimeCur=PointTime || aTimePre=PointTime && aTimePre=StartTime || TimeCur=StartTime && TimeCur=PointTime || aTimePre=PointTime && aTimePre