PDA

View Full Version : Calculating Max and Min Value of RTD without capturing them.



Tuhin Paul
08-21-2019, 08:05 AM
Hi, I trade in stocks using RTD function in my excel sheet.
Can anyone tell me if there is any way to store the maximum and minmum value of RTD (which are always updating continuously) of a particular time-period without storing them.
To be specific, In my excel sheet, from 10:00 am to 10:05 am I get RTD values. Now I want to know the highest (lowest or average) value within this time, without storing them continuously in excel sheet.

Actually by continuously storing value in excel sheet, the sheet gets pretty big in size.

Leith Ross
08-21-2019, 09:08 AM
Hello Tuhin Paul,

Welcome!

I noticed you post this same question in another forum earlier today. Most forums have rules about posting the same question in multiple forums, known as cross-posting. Please take the time to read the forum's rules once you have become a member. It will help get your questions answered quickly and correctly.

Question cross-posted Excel Forum (https://www.excelforum.com/excel-programming-vba-macros/1287212-calculating-max-and-min-value-of-rtd-without-capturing-them.html)

SamT
08-21-2019, 10:56 AM
With Range("A1")
If .Value = 0 Then
.Value = RTD
Else
.Value = Min(.Value, RTD)
End If
End With

Range("B1") = Max(Range("B1"), RTD)
Range("C1") = Range("C1") + RTD
Range("D1") = RTD_Count
Range("E1") = Range("C1") \ Range("D1") 'Average RTD

Tuhin Paul
08-21-2019, 07:50 PM
Hello Tuhin Paul,

Welcome!

I noticed you post this same question in another forum earlier today. Most forums have rules about posting the same question in multiple forums, known as cross-posting. Please take the time to read the forum's rules once you have become a member. It will help get your questions answered quickly and correctly.

Question cross-posted Excel Forum (https://www.excelforum.com/excel-programming-vba-macros/1287212-calculating-max-and-min-value-of-rtd-without-capturing-them.html)

Sorry Leith, I didn't know that I thought I would get quicker and better reply if I post this question at multiple blogs...

Tuhin Paul
08-21-2019, 07:53 PM
Thanks SamT, for your contribution. What is .Value function is actually doing here. If the RTD value is in negative (in case of RTD of Spreads) will it work?

SamT
08-22-2019, 07:07 PM
Dim Foo As Range

With Foo
'All below relates to Foo: Because "With."
.Value = Bar 'Value is a Property of a Range
End With '(Not using Foo now)

The leading Dot ( .) inside the With... End With relates Properties and Methods to the Object (Foo,) that the With is concerned about.

For example:

Dim Foo As Collection

With Foo
.Add Bar 'Add is a Method of Collections
End With