//+------------------------------------------------------------------+ //| Equilibrium.mq5 | //| Copyright 2019, Thomas Schwabhaeuser | //| schwabhaeuser@icloud.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2019, Thomas Schwabhaeuser" #property link "schwabhaeuser@icloud.com" #property description "Product of rates of added symbols:" #property description "1. uses ask/bid prices for Equilibrium's ask/bid rates," #property description "2. uses ask/bid according to symbol's direction for Equilibrium's enter/leave rate, resp." #property description "(intended for adding symbols whose product should equal one.)" #property version "1.00" //+------------------------------------------------------------------+ //| BACKLOG | //| | //| 1. Extract the functions | //| bool parsePortfolioString(portfolio,directions,symbols[]) | //| bool parseDirection(portfolio,string_index,array[]) | //| bool parseSymbol(portfolio,string_index,array[]) | //| int getNextIndex(portfolio,string_index) | //| void PrintNextIndex(fn,pf,i,p,m,r) | //| bool IsValidSymbolName(string symbol) | //| string ToString(string &array[]) | //| string ToString(ENUM_DIRECTION &array[]) | //| to a new class CPortfolio encapsulating the 2 arrays | //| string ExtSymbols[]; | //| ENUM_DIRECTION ExtDirections[]; | //| and providing the methods | //| parse(string portfolio); | //| int Total(void); | //| string GetSymbol(int i); | //| ENUM_DIRECTION GetDiretion(int i); | //| string ToString(); | //| | //| 2. An expert should use the buffer MARGIN for risk management | //| as ususal: | //| LotSize = AccountInfoDouble(ACCOUNT_MARGIN_FREE)/MARGIN | //| where MARGIN is computed by the indicator as follows: | //| for(int i=0;i<#Symbols;i++): | //| OrderCalcMargin(ExtDirections[i],ExtSymbols[i],1.0, | //| EnterPrice,value) | //| MARGIN += value; | //| | //| 3. Then the OnTick() handler of an expert is straightforward | //| if(CheckClose()): | //| for(int i=0;i<#Symbols;i++): | //| Trade.Close(ExtSymbols[i]); | //| else: | //| if(CheckOpen()): | //| for(int i=0;i<#Symbols;i++): | //| Trade.Open(LotSize,ExtSymbols[i]); | //| | //+------------------------------------------------------------------+ //#property indicator_chart_window // Выводить индикатор в окно графика #property indicator_separate_window #property indicator_buffers 5 // Количество буферов для расчёта индикатора #property indicator_plots 4 // Количество графических серий //--- Цвета цветовых буферов //#property indicator_color1 clrDodgerBlue,C'0,50,100' //#property indicator_color2 clrMagenta,C'130,0,130' //#property indicator_color3 clrGold,C'160,140,0' //#property indicator_color4 clrAqua,C'0,140,140' //#property indicator_color5 clrLimeGreen,C'20,80,20' //--- #property indicator_label1 "Enter" #property indicator_type1 DRAW_LINE #property indicator_color1 clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 1 #property indicator_label2 "Leave" #property indicator_type2 DRAW_LINE #property indicator_color2 clrGreen #property indicator_style2 STYLE_SOLID #property indicator_width2 1 #property indicator_label3 "Bid" #property indicator_type3 DRAW_LINE #property indicator_color3 clrBlue #property indicator_style3 STYLE_SOLID #property indicator_width4 1 #property indicator_label4 "Ask" #property indicator_type4 DRAW_LINE #property indicator_color4 clrMagenta #property indicator_style4 STYLE_SOLID #property indicator_width4 1 #property indicator_label4 "Margin" #property indicator_type4 DRAW_LINE #property indicator_color4 clrFireBrick #property indicator_style4 STYLE_SOLID #property indicator_width4 1 //--- #include "../Include/MultiSymbolIndicator.mqh" //--- input parameters input string InpPortfolio="EURUSD-EURGBP-GBPUSD"; // Buy/Sell (+/-) Symbols //---- buffers //--- TODO: // enum ENUM_BUFFERS_EQL // { // BUFFER_ENTER = 0, // BUFFER_LEAVE = 1, // BUFFER_BID = 2, // BUFFER_ASK = 3, // BUFFER_MARGIN = 4, // BUFFERS_TOTAL = 5 // }; // struct BufferType { double data[]; }; // BufferType ExtBuffersEql[BUFFERS_TOTAL]; //--- SetPropertiesIndicator(): // for(int b=0; b