
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
A A Adhioermawan #:
What does time[0] have to do with the bar with index i that you analyze at each individual iteration?
I asked you for the following:
describe in ordinary human words when you need an alert
But you dodged this and sent the code. So I give up. Perhaps one of the other users will be able to guess when you want alerts.
Your (like many others) problem is that you start writing code first and think later.
Do you need notification about signals on bar 0 and 1? Then leave the “main loop” alone and write separate logic for alerts. You have ready-made signals in buffers, analyze them. Once you try to do this, you will be faced with the question "when exactly do I want to receive alerts?"
Your (like many others) problem is that you start writing code first and think later.
Do you need notification about signals on bar 0 and 1? Then leave the “main loop” alone and write separate logic for alerts. You have ready-made signals in buffers, analyze them. Once you try to do this, you will be faced with the question "when exactly do I want to receive alerts?"
Do you need notification about signals on bar 0 and 1? Then leave the “main loop” alone and write separate logic for alerts. You have ready-made signals in buffers, analyze them.
This is the path to object-oriented thinking.
The code for generating signals should not know anything about alerts.
The code for sending alerts should not know anything about generating signals. The code for alerts should simply take the single current signal and analyze whether an alert should be sent. This may involve storing information about which signal the previous alert was sent for. A little later, you will want to combine all the alert functions and data into a single object. Because the alert functions and data are independent and self-contained, you don't want them getting in the way while you work on other code. As a bonus, you will find that your code is more portable, less cumbersome, and identifiers are shorter and more obvious.
I am really sorry if this action inappropriate and offense you
This is not inappropriate or offensive. You have nothing to apologize for.
It's just that I asked you for a "task" and you gave me a broken implementation with no explanation of how it's supposed to work. I see that it works strangely, but I don't know how it's supposed to work.
No, Mr Vladislav I didn't mean to dodge your advice. The condition for alert at my code are fine and clear to me just like I said, I learn write this code from several platform include asking chatGPT then backtested it. The problem is about alert always triggered when I attach the indicator to the chart/changing timeframe. That is why I asked if anyone has similar problem with me. I shared my full code to you in case you may want to try the indicator and see my problem, I am really sorry if this action inappropriate and offense you
did you see my advice?
During the OnInit() you should not depend on any function that requests data from the trade server, because it may not be connected yet.
Instead, you should wait for the first tick or valid data in the OnCalculate() and only then initialise any required variables that is dependant on that data.