From 99ea77ebfe64552a878887f35537a702baf29a63 Mon Sep 17 00:00:00 2001 From: Gunther Schulz Date: Thu, 30 Apr 2020 10:34:45 +0200 Subject: [PATCH] cleanup --- Experts/JsonAPI.mq5 | 340 ++------------------------------ Indicators/JsonAPIIndicator.mq5 | 46 ----- clean.sh | 1 - 3 files changed, 14 insertions(+), 373 deletions(-) diff --git a/Experts/JsonAPI.mq5 b/Experts/JsonAPI.mq5 index 72ea6a9..aca5741 100644 --- a/Experts/JsonAPI.mq5 +++ b/Experts/JsonAPI.mq5 @@ -102,11 +102,6 @@ int chartWindowTimerCounter = 0; // Keeps track of the current cycle // Error handling ControlErrors mControl; -//string chartWindowObjects[]; - -//double chartCurvePositions[][3]; - - //+------------------------------------------------------------------+ //| Bind ZMQ sockets to ports | //+------------------------------------------------------------------+ @@ -152,12 +147,10 @@ bool BindSockets(){ //+------------------------------------------------------------------+ int OnInit(){ - // Settimg up error reporting + // Setting up error reporting mControl.SetAlert(true); - //mControl.SetPrint(true); mControl.SetSound(false); mControl.SetWriteFlag(false); - //mControl.SetPlaySoundFile("news.wav"); /* Bindinig ZMQ ports on init */ // Skip reloading of the EA script when the reason to reload is a chart timeframe change @@ -226,12 +219,6 @@ void OnDeinit(const int reason){ } } -/* -void OnTick(){ - -} -*/ - //+------------------------------------------------------------------+ //| Check if subscribed to symbol and timeframe combination | //+------------------------------------------------------------------+ @@ -296,9 +283,6 @@ void StreamPriceData(){ MqlRates rates[1]; int spread[1]; - //if(CopyBuffer(indicators[idx].indicatorHandle, i, fromDate, 1, values) < 0) { - // CheckError(__FUNCTION__, indicatorDataSocket); - //} if( chartTF == "TICK"){ if(SymbolInfoTick(symbol,tick) !=true) { /*mControl.Check();*/ } thisBar=(datetime) tick.time_msc; @@ -351,7 +335,6 @@ void StreamPriceData(){ } } } - // return true; } //+------------------------------------------------------------------+ @@ -378,8 +361,7 @@ void OnTimer(){ chartDataSocket.recv(chartMsg, true); if(chartMsg.size()>0){ if(debug) Print(chartMsg.getData()); - chartIndicatorSocket.send(chartMsg,true); - //ResetLastError(); + chartIndicatorSocket.send(chartMsg,true); } // Trigger the indicator JsonAPIIndicator to check for new Messages @@ -408,19 +390,9 @@ void RequestHandler(ZmqMsg &request){ if(debug) Print("Processing:"+msg); - // Deserialize msg to CJAVal array - /* - if(!message.Deserialize(msg)){ - ActionDoneOrError(65537, __FUNCTION__); - Alert("Deserialization Error"); - ExpertRemove(); - } - */ - if(!incomingMessage.Deserialize(msg)){ mControl.mSetUserError(65537, GetErrorID(65537)); CheckError(__FUNCTION__); - //ExpertRemove(); } // Send response to System socket that request was received @@ -440,8 +412,6 @@ void RequestHandler(ZmqMsg &request){ else if(action=="RESET") ResetSubscriptionsAndIndicators(); else if(action=="INDICATOR") IndicatorControl(incomingMessage); else if(action=="CHART") ChartControl(incomingMessage); - // Action command error processing - //else ActionDoneOrError(65538, __FUNCTION__); else { mControl.mSetUserError(65538, GetErrorID(65538)); CheckError(__FUNCTION__); @@ -463,16 +433,10 @@ void ScriptConfiguration(CJAVal &dataObject){ // to initialze with value 0 skips the first price symbolSubscriptions[symbolSubscriptionCount].lastBar = 0; symbolSubscriptionCount++; - /* - if(SymbolInfoInteger(symbol, SYMBOL_EXIST)){ - ActionDoneOrError(ERR_SUCCESS, __FUNCTION__); - } - else ActionDoneOrError(ERR_MARKET_UNKNOWN_SYMBOL, __FUNCTION__); - */ + mControl.mResetLastError(); SymbolInfoString(symbol, SYMBOL_DESCRIPTION); if(!CheckError(__FUNCTION__)) ActionDoneOrError(ERR_SUCCESS, __FUNCTION__, "ERR_SUCCESS"); - //if(!CheckError(__FUNCTION__, dataSocket)) ActionDoneOrError(ERR_SUCCESS, __FUNCTION__, dataSocket); } //+------------------------------------------------------------------+ @@ -670,9 +634,6 @@ void ChartControl(CJAVal &dataObject){ if(actionType=="ADDINDICATOR") { AddChartIndicator(dataObject); } - else if(actionType=="ADDOBJECT") { - AddObjectToChart(dataObject); - } else if(actionType=="OPEN") { OpenChart(dataObject); } @@ -740,238 +701,6 @@ void AddChartIndicator(CJAVal &dataObject){ } } -//+------------------------------------------------------------------+ -//| Draw on chart | -//+------------------------------------------------------------------+ -void ChartDrawY(CJAVal &dataObject){ -/* - Print("drawchart"); - - string id=dataObject["id"].ToStr(); - //int windowIdx = GetChartWindowIdxByChartWindowId(id); - - int datesSize = dataObject["data"][0].Size(); - int x[]; - int y[]; - double x_dbl[]; - double y_dbl[]; - ArrayResize(chartCurvePositions, datesSize); - ArrayResize(x,datesSize); - ArrayResize(y,datesSize); - ArrayResize(x_dbl,datesSize); - ArrayResize(y_dbl,datesSize); - for(int i=0;iprev_calculated){ Buffer[0] = EMPTY_VALUE; } - -/* -https://www.mql5.com/en/docs/constants/structures/mqlparam - -*/ - //--- return value of prev_calculated for next call return(rates_total); @@ -116,8 +96,6 @@ https://www.mql5.com/en/docs/constants/structures/mqlparam void SubscriptionHandler(ZmqMsg &chartMsg){ CJAVal message; - - //ResetLastError(); // Get data from reguest string msg=chartMsg.getData(); @@ -125,7 +103,6 @@ void SubscriptionHandler(ZmqMsg &chartMsg){ // Deserialize msg to CJAVal array if(!message.Deserialize(msg)){ - //ActionDoneOrError(65537, __FUNCTION__); Alert("Deserialization Error"); ExpertRemove(); } @@ -139,7 +116,6 @@ void WriteToBuffer(CJAVal &message) { int bufferSize = ArraySize(Buffer); int messageDataSize = message["data"].Size(); if(first==false) { - //ArrayFill(Buffer, 0, ArraySize(Buffer), EMPTY_VALUE); PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,bufferSize-messageDataSize); first = true; } @@ -153,29 +129,8 @@ void WriteToBuffer(CJAVal &message) { } } Buffer[0] = EMPTY_VALUE; - - - - //ArrayResize(Values, bufferSize); - //for(int i=0;i ./Experts/JsonAPI.clean.mq5 sed -i '1s/^/\xef\xbb\xbf/' ./Experts/JsonAPI.clean.mq5 mv ./Experts/JsonAPI.clean.mq5 ./Experts/JsonAPI.mq5 - # Remove non-printable ASCII characters tr -cd '[:print:]\n\r' < ./Indicators/JsonAPIIndicator.mq5 > ./Indicators/JsonAPIIndicator.clean.mq5 # Add UTF-8 BOM