Generate a buy/sell signal before the completion of a bar (LIVE)

sebinho

Member
Joined
Nov 19, 2022
Posts
11
Likes
3
Hi Guys,

I am currently writing some studies/strategies but I am having some issues. It works well if I accept to wait for the current bar to be complete. In this scenario I will get a signal once the bar is complete and my specific conditions have been met.
But I would like to generate a LIVE buy/sell signal, as soon as my conditions are met for the current bar and NOT when the current bar is complete. This creates a delay in my orders that have a big impact on the quality of my entries.

Can someone help me with this? If I was not clear, let me know.

Thanks a lot 🙏
 

sebinho

Member
Joined
Nov 19, 2022
Posts
11
Likes
3
Even a simple example on how to draw a figure (like a dot or something) while a bar is in progress would help a lot.
 

Donovan2580

Well-known member
Joined
Sep 13, 2020
Posts
433
Likes
237
I am no coder, but perhaps you could look at some of the included studies for a hint??

Many of them update intra-bar.... I think VWAP is one of them.

They have the source code for over 200 different studies here: If you have already tried that let me know and I might be able to help by sharing a study that I had custom made. :)

 

MrSharky

Well-known member
Joined
Jul 21, 2022
Posts
100
Likes
36
If you look at a moving average as a example. There is a option in the Settings menu of the indicator under the Option tab, "Bar Updates". If you tick that option the indicator updates live as the bar updates in real time. Could that be something you are looking for.
 

sebinho

Member
Joined
Nov 19, 2022
Posts
11
Likes
3
I am no coder, but perhaps you could look at some of the included studies for a hint??

Many of them update intra-bar.... I think VWAP is one of them.

They have the source code for over 200 different studies here: If you have already tried that let me know and I might be able to help by sharing a study that I had custom made. :)

Thanks for the feedback. I did spend quite some time looking at those available studies. They did help quite a bit and I am able to create a live indicator.
But I am having trouble trying to create a live marker or signal.
Would you mind sharing a bit of your study?
Much appreciated
 

sebinho

Member
Joined
Nov 19, 2022
Posts
11
Likes
3
If you look at a moving average as a example. There is a option in the Settings menu of the indicator under the Option tab, "Bar Updates". If you tick that option the indicator updates live as the bar updates in real time. Could that be something you are looking for.
Thanks! I will check out the source code to see if something can be of use there.
 

sebinho

Member
Joined
Nov 19, 2022
Posts
11
Likes
3
Thanks! I will check out the source code to see if something can be of use there.
I finally was able to make it work by looking at how the moving averages have been coded (see MABase.java in the publicly available studies).
Basically we have to actively make use of the functions OnBarUpdate() and OnBarClose().

Java:
  @Override
  public void onBarUpdate(DataContext ctx)
  {
    if (!getSettings().isBarUpdates()) return;
    doUpdate(ctx);
  }

  @Override
  public void onBarClose(DataContext ctx)
  {
    doUpdate(ctx);
  }

Then you will be able to generate live indicators/markers/... by doing custom calculations in the doUpdate() function.

Thanks for all your help guys!
 

Shtick Hustler

Well-known member
Joined
Oct 15, 2020
Posts
106
Likes
46
There's another way you can get better entries without having to monitor intrabar data:
Predict the price where an intrabar signal might occur (like price crossing a MA by 2 points) and, for each bar, submit an exit entry order for that price (i.e: an on-stop-buy order if going long).
 
Last edited:
Top