Real Time Scanning

Are there any changes that needs to be made to an AFL while scanning(AR) for Buy/Sell/Short/Cover from a watchlist using
"1 Recent Bar(s)" ,I kept the AR on and started the scan soon after market open ,after wtaching it continously for 15min(I was using 5 min periodicity) ,I didnt find a single trade pop up during that period,however when i switched to "1 Recent Day(s)"and clicked on scan, there were a couple of trades during that period,but they never showed up while using “1 Recent Bar(s)” ,I had 2 windows open, the analysis window and a single chart with all symbols(using plot foreign) in the watchlist, am i missing something ?

Check out Plotshapes in Amibroker documentation and include plotshapes afl code to show entries and exits in your chart . Then your chart will show entry and exits on the relevant bar in real time. Charts update in realtime default setting every 1 second and you dont need to run a scan or exploration .

Example code in is a good start.

I have been trading using charts for a few years now and I still do, I now have a larger portfolio of symbols, so trading using chart is
no longer feasible, also since i have been trading through charts ,with entry and exits at close of candle ,I use the below code,so arrows appear on the chart only after the candle close,could that be the reason for trades not popping up during he scan.
bi = BarIndex();
barcomplete = bi < LastValue( bi );

I think, the reason for this is very simple (if not obvious):

  • If you set periodicity to 5 min and range to 1 recent bar, the Scan/Exploration (by default) will only analyse the last 5 min bar of each issue.

  • If you set periodicity to 5 min and range to 1 recent day, the Scan/Exploration will check all 5 min bars during 1 recent day - so you will get much more results. There are lots of 5 min bars during one session…

You can easily check it by yourself. Run this simple code as a Scan or Exploration with the above settings and compare how many Buy signals (in case of a Scan) or rows (in case of Exploration) will you get in both cases:

Buy = 1; 
Sell = 0;
Filter = 1;

Of course it is also very important what kind of formula are you using. Different formulas will give you different number of signals with the above settings.

1 Like

Yes,I am aware of that , but since i intend to use it for realtime trading , when i use 1recent day a lot of signals(repeated) will be sent to the trading platform at each scan,hence I have been advised to use 1recent Bar

… in that case you need to modify your formula, because your:

barcomplete = bi < LastValue( bi );

… will never be true for the last bar and you won’t get any signals when scanning with the Range set to 1 recent bar.

Oops,I though as much , If i dont use barcomplete = bi < LastValue( bi ); and scan using 1recent bar , buy/sell signal will pop up and remain there until the candle closes,updating the entry price many times before the end of 5 minutes.

Think logically. If you want to keep the Range set to 1 recent bar, and you are going to run this scanner on the live market, you should modify your formula so that it checks all your conditions not for the last bar (which is constantly changing), but for the bar which is second to last. This bar is always completed. You can do it i.e. using Ref() function.


Will do thank you very much.

1 Like

Is there a way to scan the market at the close of candle,my signals(buy/sell) are generated based close of candle (5min),the market here open at 9:15;00 ,if at 9:12:00 i choose AR time 5m and click on scan the next scan will happen only at 9:17:00,is there a way to make it happen at every 5 min interval instead ie at 9:20:00,9:25:00 ,9:30:00 regardless of what time i click on scan.