Using "alerts" and "event log" information
Hi PTMC team,
Is it possible to use the information in 'Alerts' or the 'event log' to create a histogram indicator?
To be more specific -
specific alerts or event log entries will act as a trigger to input data into a histogram loaded on a chart.
Example - alert on chart 1 and chart 2 causes - histogram indicator on chart 3 to perform a calculation and output the result on the histogram on chart 3.
I do know how to create alerts and print into the event log.
What i do not know is - how to let the alert or event log data to act as an input to an indicator loaded on another chart.
Another way to put it would be how to access a 'past alert event' and 'event log information' so that this data could be used for the calculation in an indicator that is already loaded onto a chart within the ptmc platform.
Hope i made sense.
As of now I was thinking about learning windows forms, create a time based histogram and some how link it with custom panels etc. Or get it to pass data from protrader 3 onto the windows form...... A long and tedious task.
So if there is some easier way or any suggestions please do let me know.
Any help and suggestions would be highly appreciated.
Cheers
Dear ssk1284u
If you familiar with C#, please use any available Collections there (as List,Dictionary, ArrayList etc) to store alerts’ value in buffer. To draw histogram indicator, please create class inherited from NETIndicator (API Class) and in constructor use method SetIndicatorLine(), this is how you will set line name, color, width, line style (LineStyle.HistogrammChart). For the reference check this indicator’s source code. So just focus on your print/alert logic and pass value to SetValue() method with correct line index and barshift. For this task there is no need to build WinForm plugin. Use API reference and CodeBase.Hi Burhay Vlad,
Thanks for the reply - I am familiar with C# ( not a professional though), I have coded histogram indicators in the past so that aspect is fine.
However, could you provide an example or any guideline/tip with respect to -
'' please use any available Collections there (as List,Dictionary, ArrayList etc) to store alerts’ value in buffer. ''
I can work with/figure out collections. What I would like help is with respect to " store alerts’ value in buffer." i.e. how can i access the 'alert' data in terms of coding.
In the platform it shows up in a separate alert window.
For example If I look at the level 2 class I can access bid and ask side prices and volumes/sizes etc. In a similar manner what can i do to access the 'alert' events?
Just to provide some more insight on what I am trying to do here -
I have 20+ charts with a custom indicator on each of them. Let us call this indicator 'custom indicator'. If the values on one of the 'custom indicator' on a chart i.e. 1 amongst 20+ custom indicators crosses a threshold I have coded it show an alert in the platform.
I am interested in using this alert 'event' to act as an input for another indicator. Let us call this indicator - 'summary indicator'.
So if an instance or multiple instances of 'custom indicator' sends out an 'alert' or alerts - it triggers the logic on the 'summary indicator'.
In essence - just by looking at the 'summary indicator' I am able to understand what the 10 instances of 'custom indicator's are doing on 10 charts.
So the 'summary indicator' gets input from one or more of the 'custom indicators' in the form of 'alerts'.
Previously I had tried to get the 'summary indicator' to pull data from the 'custom indicator' s by looking at the historical data/latest indicator output (index offset 1) for each of the 'custom indicators'. However that proved very problematic and caused high CPU usage/platform freezing etc due to the fact that each currency pair forms a new bar at different times; care of the NextBar() method.
Trying to use alerts would solve this problem as the 'summary indicator' logic would only get triggered when and if the 'alert' event occurs on one or more 'custom indicator' s. Whereas previously I had to write some lenghty/confusing loops to address the problem of each currency pair new bars opening at different times,needless to say this approach was never stable
CPU matters - I am using a VPS with 16 cores. Things are fine with 28 'custom indicator' s running on each curreny pair ( 28 different currency pairs).On average- Over a week the CPU only goes above 50% usage about 5% of the time, more than 70% of the time it uses between 0-20% of CPU. I have been using a CPU logger program.
However the moment I use the 'summary indicator' with the complex loops ( to address the new bar forming time differences) - it results in platform instability. Quite sure my coding is bad too.
Nonetheless - Trying to use alerts would solve this problem as the 'summary indicator' logic would only get triggered when and if the 'alert' event occurs on one or more 'custom indicator' s. Hence the need to access the 'alert' event.
Hope that made some sense.
Cheers
all logs are written to Documents\Protrader(your version)\logs folder
just in case you need to retrieve data for your own needs
But as I said before you also can store a required info to collection and global variable and only after send an alert/print log:
if you build indicator you probably should revise logic of storing or retrieving data. Just look on this source code and see how it is done, you can pass any conditions based on price movement, do some calculations, draw a histogram and after all call alerts from indicator body and not from terminal which makes more sense in terms of indicator’s nature. Hope any option above is what you were looking forHi Burhay Vlad,
I have been trying to go down the 'global variable' route.
Based on - https://protrader.org/ptmc-api/netscript/globalvar...
i.e. with respect to the syntax mentioned - I am not able toenter the name parameter as a string - it will only accept 'int' type. The 'double' type also cannot be used ( since I do use decimal point values). Hence I am quite confused i.e. does global variable in ptmc protrader only accept ints ?
Can you point me to an actual indicator example that uses global variables?
According to API you pass string,which is any name you choose to indicate later your global variable's string name, second parameter is object value, pass to it your double, int, string, float, List<double> etc, as long as it is serializable. You should not have any problem with it, as you retrieve it later with (double)GlobalVariablesManager.GetValue("global_variable");
Do not forget to cast it.
Regards
Hi Burhay Vlad,
Thanks a lot for all the help.That was a very clear explanation and I managed to solve my multi chart indicator issues with the use of 'global variables' :)
I have a suggestion - I guess it is a good idea to post an example/tutorial on the code base section with respect to 'how to make indicators communicate with each other' and in this use 'global variables'.
Cheers