In experimenting with a custom price index indicator, I can get it to plot in real time, but only in real time. As soon as the window is closed or chart time frame is changed, the indicator resets to zero and starts over. I can only get it to show history by keeping the chart window with indicator continuously opened and unedited.
How do I need to modify the code so that I can use it offline and have it plot history as well as update in real time.
Here is the complete code as is. I'd like to modify it so that it calculates history upon adding it to the chart and so that it also updates in real time. I understand that with a lot of history it would take much longer to calculate and load, so the best solution would be to add a variable number of historical bars to calculate and plot from.
How do I need to modify the code so that I can use it offline and have it plot history as well as update in real time.
Here is the complete code as is. I'd like to modify it so that it calculates history upon adding it to the chart and so that it also updates in real time. I understand that with a lot of history it would take much longer to calculate and load, so the best solution would be to add a variable number of historical bars to calculate and plot from.
Inserted Code
#property copyright "" #property link "" #define vers "Beta" //---- #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Gold #property indicator_width1 1 extern string SymbolMain = ""; extern string Symbol1 = "EURUSD"; extern string Symbol2 = "EURUSD"; extern string Symbol3 = "EURUSD"; extern string Symbol4 = "EURJPY"; extern string Symbol5 = "EURJPY"; extern string Symbol6 = "EURJPY"; extern string Symbol7 = "CHFJPY"; extern string Symbol8 = "CHFJPY"; extern string Symbol9 = "CHFJPY"; extern string Symbol10 = "USDCHF"; extern string Symbol11 = "USDCHF"; extern string Symbol12 = "USDCHF"; extern string Symbol13 = "EURGBP"; extern string Symbol14 = "GBPCHF"; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ double Buff1[]; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void init() { SetIndexStyle(0, DRAW_LINE); SetIndexBuffer(0, Buff1); SetIndexEmptyValue(0, 0.0); } void deinit() { } void start() { int counted_bars = IndicatorCounted(); if (counted_bars < 0) return; if (counted_bars > 0) counted_bars--; int limit = Bars-counted_bars; for (int i=limit; i >= 0; i--) { Buff1[i] = (iClose(Symbol1,0,0) + iClose(Symbol2,0,0) + iClose(Symbol3,0,0) + iClose(Symbol4,0,0)/100 + iClose(Symbol5,0,0)/100 + iClose(Symbol6,0,0)/100 + iClose(Symbol7,0,0)/100 + iClose(Symbol8,0,0)/100 + iClose(Symbol9,0,0)/100 + (1/iClose(Symbol10,0,0)) + (1/iClose(Symbol11,0,0)) + (1/iClose(Symbol12,0,0)) + iClose(Symbol13,0,0) + (1/iClose(Symbol14,0,0)))/14; } }