diff --git a/Experts/JsonAPI.mq5 b/Experts/JsonAPI.mq5 index fec1d70..f6e6a67 100644 --- a/Experts/JsonAPI.mq5 +++ b/Experts/JsonAPI.mq5 @@ -101,10 +101,6 @@ struct ChartWindowIndicator ChartWindowIndicator chartWindowIndicators[]; int chartWindowIndicatorCount = 0; -// Refresh chart window interval for JsonAPIIndicator -int chartWindowTimerInterval = 1; // Cycles of the globally set EventSetMillisecondTimer interval -int chartWindowTimerCounter = 0; // Keeps track of the current cycle - // Error handling ControlErrors mControl; @@ -465,25 +461,19 @@ void OnTimer() // Ensure that all indicators have finished intitailisation for(int i=0; i= chartWindowTimerInterval) + for(int i=0; iprev_calculated) + + + if(rates_total>prev_calculated && setFormingCandleBlank) { B0[0] = EMPTY_VALUE; B1[0] = EMPTY_VALUE; @@ -198,9 +202,6 @@ int OnCalculate(const int rates_total, B28[0] = EMPTY_VALUE; B29[0] = EMPTY_VALUE; } - if(first==false) - alive[0] = 1; -// ChartRedraw(0); //--- return value of prev_calculated for next call return(rates_total); @@ -222,7 +223,7 @@ void SubscriptionHandler(ZmqMsg &chartMsg) Alert("Deserialization Error"); ExpertRemove(); } - if(message["indicatorChartId"]==IndicatorId) + if(message["chartIndicatorId"]==IndicatorId) { if(message["action"]=="PLOT" && message["actionType"]=="DATA") @@ -378,6 +379,7 @@ void SubscriptionHandler(ZmqMsg &chartMsg) WriteToBuffer(message, B29); SetIndexBuffer(29,B29,INDICATOR_DATA); } + ChartRedraw(mtChartId); } else if(message["action"]=="PLOT" && message["actionType"]=="ADDBUFFER") @@ -387,30 +389,165 @@ void SubscriptionHandler(ZmqMsg &chartMsg) string linetypeStr = message["style"]["linetype"].ToStr(); string linestyleStr = message["style"]["linestyle"].ToStr(); int linewidth = message["style"]["linewidth"].ToInt(); + setFormingCandleBlank = message["style"]["blankforming"].ToBool(); color colorstyle = StringToColor(colorstyleStr); int linetype = StringToEnumInt(linetypeStr); int linestyle = StringToEnumInt(linestyleStr); - /* - //if (aa == false) { - Print("SETBUFF ActCount ",activeBufferCount); - if (activeBufferCount == 0) {SetIndexBuffer(0,B1,INDICATOR_DATA);} // Two semicolons ar required! No idea why. Seems to be a timing problem, better to keep it in init() - - if (activeBufferCount == 1) {SetIndexBuffer(1,B2,INDICATOR_DATA);;} - if (activeBufferCount == 2) {SetIndexBuffer(2,B3,INDICATOR_DATA);;} - if (activeBufferCount == 3) {SetIndexBuffer(3,B4,INDICATOR_DATA);;} - if (activeBufferCount == 4) {SetIndexBuffer(4,B5,INDICATOR_DATA);;} - - //aa = true;} - */ - SetStyle(activeBufferCount, linelabel, colorstyle, linetype, linestyle, linewidth); activeBufferCount = activeBufferCount + 1; + + ClearBuffer(activeBufferCount-1); } } } +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +void Clear(double &buffer[]) + { + int bufferSize = ArraySize(buffer); + for(int i=0; i= EMPTY_VALUE) + val = EMPTY_VALUE; + buffer[i+offset] = val; } - //if(i == messageDataSize-1) - // buffer[i+1] = EMPTY_VALUE; } -// Set the most recent plotted value to nothing, as we do not have any data for yet unformed candles - buffer[0] = EMPTY_VALUE; }