Topics
Replies
sjolandersimon
31 Jul 2023, 20:05
RE: Evaluate indicator at close of bar
PanagiotisChar said:
Hi,
It's wrong to evaluate at the opening of the previous bar. This is what you were doing before and was not working. The indicator should be calculated on every tick until the bar closes. Regarding signals (I guess you are reading this from a cBot?) you should only consider closed bars.
Need help? Join us on Telegram
Thanks for the reply, I appreciate your effort!
When the indicator is evaluated at every tick, a signal is produced every time the condition is met during the length of that bar.
I am using an email notification, and my actual problem is that I am receiving an email for every tick the condition is met during the length of the bar. I would like to only receive one email at the close of the bar if the condition is met at the close of that bar. Do you have any suggestion how to proceed based on this information?
Actually I am working with chatGPT to produce code. The AI can produce a lot of interesting code, but you have to be very specific and you often have to modify the code in some degree.
@sjolandersimon
sjolandersimon
26 Jul 2023, 14:20
RE: Evaluate indicator at close of bar
PanagiotisChar said:
Hi again,
Try removing this condition
if (index > lastIndex)
It causes the problem and I don't see the point of it
Thanks for the reply.
When I remove the line of codes related to the "private int lastIndex", the indicator produces signals meeting the criteria for real-time price data. Although it evaluates at ever tick, resulting in all to many signals.
What would you recommend using as code to make the indicator only to be evaluated at the start of a new bar?
@sjolandersimon
sjolandersimon
26 Jul 2023, 13:18
( Updated at: 21 Dec 2023, 09:23 )
RE: Evaluate indicator at close of bar
Thank you for the fast reply.
With the given code setup, the indicator produces signals for historical data, see the picture below for the example Gold.
But when the indicator is live and evaluating the most recent real-time data, no signal is produced, even though the criteria is meet. I have come to this conclusion by watching new price bars forming.
PanagiotisChar said:
Hi there,
The current issue is that the indicator produces signals for historical data, but not for live real-time data.
How did you come this conclusion?
Need help? Join us on Telegram
@sjolandersimon
sjolandersimon
02 Aug 2023, 19:47
RE: Evaluate indicator at close of bar
PanagiotisChar said:
Hi Panagiotis,
Thanks for the reply and suggestion in how to improve the code.
I have made somewhat progress with the script. Below are two different scripts for the same criteria and is calculated at every tick respectively once at the close of the bar.
The 1st script below have the following prerequisites:
The 2nd script below have the following prerequisites:
So to the question. I am trying to get the 2nd script to work with regards to email notification being sent. My suspicion is that it has something to do with email notification system not working well in current conditions when it is evaluated once per bar?
What are your suggestion how to improve further with regards to the issues with email notification and the 2nd script?
@sjolandersimon