I'm making it some customizations to calculate the lower Unrealized Account Balance value that if reached then it means the trading strategy you are using has failed. Lower Unrealized Account Balance value = lower Net Liquidation value.
Now what I need is that if this described event happens, then that the indicator put a mark of this event:
- Displaying in red color the date and exact time (hh:mm:ss) it has happened.
- If possible and for better visual illustration, in addition to the previous, that the indicator also draws a vertical time line in red color showing the moment/bar the event took place.
I need a guide about how to add these 2 features to the indicator.
I need this works either in Live, in Demo, in Simulated or in Playback (Market Replay), so for Live, Demo and Simulated accounts the date and time I need to be displayed is the real-time calendar date and time, as the normal, but about the Playback the thing is different, because what it is needed is the event's date and time of the Market Replay moment, i.e. not the date and time in the computer for these cases.
For example, if today Feb 23, 2021 you are running the Market Replay of Nov 30, 2020 and the failure event happens at 11:05:42 am (on Nov 30, 2020) then I need the indicator displays something similar like:
"The strategy failed to meet the minimum necessary requirements at 11:05:42 am, on Nov 30, 2020"
Note: I have not programming backgraound but some years ago I learned the basis for programming. I started with these modifications some days ago, so as you can imagine I'm in a knowledge refreshing process and I'm noticing that to do any simple action in C# needs almost the double of code than others more simplified programming languages.
The indicator I mention "Position Display Indicator" draws a textbox in any chart you want showing the information pre-defined, and for this you just need to import and load the indicator as any other indicator. I need to display the failed event notification in this textbox.
to display information any extra iformation I've been using the defeult way the indicator use, for example
The situation I'm asking for is not mainly about how to draw the time/date, this will help but is secundary, becuase the main I need to know is how I get the time-and-date when the event happened, to then take that information and display it in screen (a chart).
For example, let's suppose a starting account balance = $1,000.00, and you have the rule that if the account balance < or = $500, either with the account unrealized balance or with the account realized balance, then it means your strategy failed to meet the minimum necessary requirements. So what I need to know is how I can get the time-and-date when the example event happens, i.e. when the account have a net liquidation < or = $500, to then draw this information in the screen, also drawing a reference vertical time line of the event.
I have a basic idea about the needed code for the example described, but seeing how C# works, I'm almost sure it won't be so simplified:
Finally, as far as I know the Playback runs the Market Replay at 1 second update that for my case is ok because I can obtain the time of the event with 1 second of maximum inaccuracy time distortion, either the Market Replay speed be at 1x or at 100x or at Max speed.
So I may have a general idea of what you're trying to do here...
But as you want to capture TIME... there are issues with storing and capturing these values.
So... NT does not actually have an object that can be easily referenced that permantly stores the time of LIVE trades taken in real or SIM accounts(as odd as this is). So while you'll always have access to balances, you won't have access to times/dates. Actually, when you go across a session, or when you restart your PC, you will lose access to times of trades taken in live or SIM.
Now... if you run a strategy for example, and are placing trades... you can always STORE those times... but those will only be available for the life cycle of the script, so unless you write that info to a text file, it will be destroyed on a restart of the indicator.
So to recap....
For LIVE/SIM trades taken by a strategy, your access to events are limited. You would have to store those events(date/time), and you would have access to it for the life-cycle of the indicator.
If you want to store that time of strategy taking the trades, and NOT the PC time, that is standard, so no worries there. I.e., when a balance dips below your desire value, you would simply flag that event, and store that date with "Time[0]", and you would have the time that event occurred.
I actually built and indicator for someone else in THIS thread, where he wanted to have his TIME in trade, where I found out about all these pitfalls of attempting to capture times of trades placed.
The posts about that indie are interspersed throughout the thread, but you can start reading from that link, and maybe you can get a sense of what I'm trying to explain here.
This probably isn't the most thorough answer, but maybe it will get the discussion started.