Daily indicators and signals for all symbols using exploration

Hello,

I am using task scheduler (using OLE and javascript) to have amibroker (running on vps) export and upload csv exploration file every 10 minutes containing various parameters for all stock symbols including buy /sell historical prices moving averages volumes obv etc. All stocks data is regularly updated through ami quote. I use the data on a personalized server side portfolio manager app.

I run the exploration using a saved analysis project using 'last bar' as the time.

My problem is as follows -

Out of over 5000 stocks, not all are active currently. So some have data only till 2016 or March 2017. Some stocks do not get the latest day's data sometimes. So instead of 24 January 2018, their last data might be of 20 January 2018.

But when amibroker outputs the csv file it seems to treat the last data date of the stock as today's data.

So sometimes I see a stock being recommended as Buy or Sell even though it's data has not been updated for a year. Sometimes a stock data has not been updated for three days but I see it's price and volume and 3 days moving average instead of showing N/A.

I'm sure there must be a simple way to avoid this.

I am using standard afl codes like add column close open MA etc.

So how do I get the exploration data to treat missing data as missing instead of using the last available data for the symbol?

Hello @Neole

If you want to receive signals only for the stocks which have been active today, you can simply add this to your Filter :

ActiveToday = Now(3) == LastValue( DateNum());

Filter = YourOtherCriteria AND ActiveToday;

Thanks to this, only the issues which have been quoted today, will be placed in the Exploration output.

http://amibroker.com/guide/afl/now.html
http://amibroker.com/guide/afl/datenum.html

Regards.

1 Like

Thanks Milosz!

This definitely is helpful. However, sometimes I might need the indicators for the stock for yesterday or last week even if today's data is not available for any reason.

  1. Is there a way the exploration can leave today's and any other unavailable dates' data blank in the csv instead of skipping the symbol altogether?

  2. If (1) is not possible, how do I change your Filter to only exclude stocks whose data is not available for the past 3 days? I tried variations with the Now() and datenum() functions but could not get anything working.

My exploration afl has this kind of data -

AddColumn(Open,"Open",1.4);
AddColumn(High,"High",1.4);
AddColumn(Low,"Low",1.4);
AddColumn(Close,"Close",1.4);
AddColumn( MA(C,1), "MA1", 1.4 );
AddColumn( MA(C,3), "MA3", 1.4 );
AddColumn( MA(C,5), "MA5", 1.4 );
AddColumn( MA(C,10), "MA10", 1.4 );
AddColumn( MA(C,20), "MA20", 1.4 );
AddColumn( MA(C,45), "MA45", 1.4 );
AddColumn( MA(C,60), "MA60", 1.4 );
AddColumn( MA(C,180), "MA180", 1.4 );
AddColumn( MA(C,365), "MA365", 1.4 );
AddColumn(Ref(Volume, -7 ),"Volume-7Day",1.0);
AddColumn(Ref(Volume, -6 ),"Volume-6Day",1.0);
AddColumn(Ref(Volume, -5 ),"Volume-5Day",1.0);
AddColumn(Ref(Volume, -4 ),"Volume-4Day",1.0);
AddColumn(Ref(Volume, -3 ),"Volume-3Day",1.0);
AddColumn(Ref(Volume, -2 ),"Volume-2Day",1.0);
AddColumn(Ref(Volume, -1 ),"Volume-1Day",1.0);
AddColumn(Volume,"Volume",1.0);
AddColumn( macd(), "MACD", 1.4 );
AddColumn(Close,"PriceClose",1.4);
AddColumn(Ref(Close, -1 ),"Price-1Day",1.2);
AddColumn(Ref(Close, -2 ),"Price-2Day",1.2);
AddColumn(Ref(Close, -3 ),"Price-3Day",1.2);
AddColumn(Ref(Close, -4 ),"Price-4Day",1.2);
AddColumn(Ref(Close, -5 ),"Price-5Day",1.2);
AddColumn(Ref(Close, -6 ),"Price-6Day",1.2);
AddColumn(Ref(Close, -7 ),"Price-7Day",1.2);
AddColumn( MA(C,2), "MA2", 1.2 );
AddColumn( Ref(MA(C, 2),-2), "MA2-2", 1.2 );
AddColumn( Ref(MA(C, 2),-4), "MA2-4", 1.2 );
AddColumn( Ref(MA(C, 2),-6), "MA2-6", 1.2 );
AddColumn( Ref(MA(C, 2),-8), "MA2-8", 1.2 );
AddColumn( Ref(MA(C, 2),-10), "MA2-10", 1.2 );
AddColumn( Ref(MA(C, 2),-12), "MA2-12", 1.2 );
AddColumn( Ref(MA(C, 2),-14), "MA2-14", 1.2 );
AddColumn( MA(C,3), "MA3", 1.2 );
AddColumn( Ref(MA(C, 3),-3), "MA3-3", 1.2 );
AddColumn( Ref(MA(C, 3),-6), "MA3-6", 1.2 );
AddColumn( Ref(MA(C, 3),-9), "MA3-9", 1.2 );
AddColumn( Ref(MA(C, 3),-12), "MA3-12", 1.2 );
AddColumn( Ref(MA(C, 3),-15), "MA3-15", 1.2 );
AddColumn( Ref(MA(C, 3),-18), "MA3-18", 1.2 );
AddColumn( Ref(MA(C, 3),-21), "MA3-21", 1.2 );
AddColumn( MA(C,9), "MA9", 1.2 );
AddColumn( Ref(MA(C, 9),-9), "MA9-9", 1.2 );
AddColumn( Ref(MA(C, 9),-18), "MA9-18", 1.2 );
AddColumn( Ref(MA(C, 9),-27), "MA9-27", 1.2 );
AddColumn( Ref(MA(C, 9),-36), "MA9-36", 1.2 );
AddColumn( Ref(MA(C, 9),-45), "MA9-45", 1.2 );
AddColumn( Ref(MA(C, 9),-54), "MA9-54", 1.2 );
AddColumn( Ref(MA(C, 9),-63), "MA9-63", 1.2 );
AddColumn( MA(C,36), "MA36", 1.2 );
AddColumn( Ref(MA(C, 36),-36), "MA36-36", 1.2 );
AddColumn( Ref(MA(C, 36),-72), "MA36-72", 1.2 );
AddColumn( Ref(MA(C, 36),-108), "MA36-108", 1.2 );
AddColumn( Ref(MA(C, 36),-144), "MA36-144", 1.2 );
AddColumn( Ref(MA(C, 36),-180), "MA36-180", 1.2 );
AddColumn( Ref(MA(C, 36),-216), "MA36-216", 1.2 );
AddColumn( Ref(MA(C, 36),-252), "MA36-252", 1.2 );
AddColumn( MA(C,110), "MA110", 1.2 );
AddColumn( Ref(MA(C, 110),-110), "MA110-110", 1.2 );
AddColumn( Ref(MA(C, 110),-220), "MA110-220", 1.2 );
AddColumn( Ref(MA(C, 110),-330), "MA110-330", 1.2 );
AddColumn( Ref(MA(C, 110),-440), "MA110-440", 1.2 );
AddColumn( Ref(MA(C, 110),-550), "MA110-550", 1.2 );
AddColumn( Ref(MA(C, 110),-660), "MA110-660", 1.2 );
AddColumn( Ref(MA(C, 110),-770), "MA110-770", 1.2 );

I managed to get the Filter to filter only stocks active in the past 3 days -

ActiveToday = Now(3) == LastValue( DateNum());
ActiveYesterday = Now(3)-1 == LastValue( DateNum());
ActiveDayBeforeYesterday = Now(3)-2 == LastValue( DateNum());
Filter = ActiveToday or ActiveYesterday or ActiveDayBeforeYesterday ;
2 Likes