It looks like you're new here. If you want to get involved, click one of these buttons!
Public Function GetPreviousValue (
TrdSym As String,
Value As Double,
Field As String,
Optional StgyCode As String = "ZZ"
) As Double
Parameters
TrdSym
Type: System.String
TrdSym
Value
Type: System.Double
Value
Field
Type: System.String
Field
StgyCode (Optional)
Type: System.String
StgyCode
Return Value
Type: Double
Previous Value
Am I right?
Also please consider other few questions of mine?
As my trading Excel file is in final stages I won't post questions after few days!
Sure, we will answer all of your questions.
We are working on some other issues.
We will update you Tomorrow.
GetPreviousValue, GetPriceChange and GetPriceSide are utility functions purely meant to use with Excel and has no connection with Kite API.
Let explain with example:
GetPriceSide:
As you know when a cell value is updated through formula or RTD or manually typing, we don't have any reference to the old or last value. Excel cell will always display latest/last value.
Example usage...
Assume in cell A1 LTP is updating and you want to conditional format the A1 Green if the latest value is greater than the previous value and vice versa for red.
B1 = GetPriceSide("AXISBANK",A1,"LTP","ZZ")
B1 will display 1 if the latest price > previous price and will display -1 if the latest price < previous price and 0 if no change.
So, you can simply format the A based on B1 value i.e.
If B1 = 1 then Green
B1 = -1 , then Red
else Yellow
This is similar to GetPriceSide, except that it will return the difference between the latest value and previous value.
Example:
If the LTP is changed from 485.55 to 485.85, then this function will return 0.3 i.e. Latest value - Previous value..
Example usage...
You can use this to track difference between two ticks.
We are using this function to track big price change between two ticks.
This is very similar to GetPriceSide and GetPriceChange, except that it will return the previous value.
As you know excel cell will always display latest value, we don't have reference to what value it is changed from, in that case you can use this function.
Example usage:
Assume you want to buy when price greater than 500 and LTP is updating in A1
B1 = If(A1 > 500, PlaceOrder(...), "NO BUY")
The problem with the above formula is
If the Ltp is already above 500 say, Ltp is 535.65 (due to Gapup or something), your IF conditions is true in B1 and order is placed. But in real time we want the price to be cross from below.
Here you can use GetPreviousValue to check the price.
A1 = LTP
B1 = GetPreviousValue(...)
C1 = If(AND(A1 > 500,B1 <=500), PlaceOrder(...), "NO BUY")
C1 will be triggered only if the prices crosses 500 from below i.e. ....480..499..500..501