Obtaining Open Interest values not for the current bar - page 10

 
Why are you doing this in the first place?
 
prostotrader:
Why are you doing this at all?

I compare two indicators on exchange instruments:

  1. the difference between the volume of buy orders at the moment and the volume of sell orders at the moment, with
  2. total volume of open positions
i.e. I attach both of these indicators to the chart of the exchange instrument.

 
Karputov Vladimir:

I compare two indicators on exchange instruments:

  1. the difference between the volume of buy orders at the moment and the volume of sell orders at the moment, with
  2. total volume of open positions
I.e. I attach both of these indicators to the chart of the exchange instrument.

It is clear, but what are these two charts for?

What are you going to do with them?

 
prostotrader:

This is understandable, but what are these two charts for?

What are YOU going to do with them?

There are two answers here (you can consider them in the concept of AND, OR, OR OR- generally to your liking):

  1. purely academic interest
  2. Earn money from the stock exchange :)

 
Karputov Vladimir:

There are two answers here (you can consider them in the concept of AND, OR, OR OR- generally to your liking):

  1. purely academic interest
  2. To make a lot of money from the exchange :)

By the time you get your data in theOnCalculate function, you'll be out of your trousers!
 
prostotrader:
By the time you get your data in the OnCalculate function, you will be out of your trousers!
You don't understand: I have indicators and the purpose of the indicator is visualisation. In this case there is no need in an excessively "twitchy" glass. I say more - the glass is even undesirable here.
 

I could not capture more as the indicator readings are reset if the connection is interrupted:

Screenshots of MetaTrader trading platform

RTS-9.16, M1, 2016.09.12

JSC ''Brokerage House ''OTKRYTIE'', MetaTrader 5, Real

Correlation of RTS-9.16 trend direction, total volume of open positions and difference between the volume of buy orders at the moment and the volume of sell orders at the moment

RTS-9.16, M1, 2016.09.12, OTKRYTIE Brokerage House, MetaTrader 5, Real


 

For the Open Interest indicator I introduced a small modification: now, after the first launch, if prev_calculate==0, the indicator will not reinitialize its indicator buffers. What do I get: for example, you attach indicator to a chart, the indicator works for some time and suddenly prev_calculate==0 (maybe there was a connection failure, or something happened with the history) - in this case, the indicator will not reinitialize its indicator buffers and it will continue working as nothing happened.

Implementation:

in the area of declaration of global variables of the program there is a variable"StartDate":

double         BufferMinDown[];
//---
datetime       StartDate=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()

then at the first start (at prev_calculated==0) value of "StartDate" variable is checked: if its value is less than D'2015.01.01 00:00' - this is the first indicator start, and "StartDate" variable is assigned with the last known server time

   if(prev_calculated==0)
     {
      Print("prev_calculated==0, StartDate=",StartDate);
      if(StartDate<D'2015.01.01 00:00')
        {
         StartDate=TimeCurrent();
        }
      else
        {
         return(rates_total);
        }
     }

otherwise it simply returns "rates_total".

Files:
 

Hello again! I have another question about using SYMBOL_SESSION_SELL_ORDERS_VOLUME and SYMBOL_SESSION_INTEREST constants. When using the indicator posted in this thread, the data on these constants are plunged, obviously to test their use on the history you should create an Expert Advisor. When receiving these constants via SymbolInfoDouble(Symbol(),SYMBOL_SESSION_BUY_ORDERS_VOLUME) not in OnCalculate() the output is zero.

Personally I want to take a simple way without complicating the code too much. Can it be obtained only for the indicator and respectively only in OnCalculate(), and it cannot be obtained on the history, since the data can be obtained only for the current bar?

Please answer in this topic and do not move the message, as it is impossible to find the answer later, especially since the question is on topic.
 
I think I understand the answer to my question and the title of the topic, I ran the EA in real time, everything works on the history no. So the question how to get values of OI and volume of buy/sell orders on the history is answered - no way...