Read the manual, was: HAndle AFL Processes

Hello Tomaz, I created a process to get the last signal of my criteria, and then use it on an exploration case works well as process 1, however when I try to use the same process over the processes of the watchlist it does not work as process 2, please advise how to solve those processes.

process 1:

last = -1;
for( i = BarCount - 2; i > 0 AND last == -1; i-- )
{
    //highestHigh=Max(H[i],highestHigh);
    //lowestLow=Min(lowestLow,L[i]);
    if( Buy[i] == 1 )
    {
        last = 1;
        //break;
    }
    else
        if( Sell[i] == 1 )
        {
            last = 0;
            //break;
        }

}
AddtextColumn( WriteIf( last == 1, "L", WriteIf( last == 0, "S", "" ) ), "Last signal", format = 1.2, fgcolor = colorWhite,  bkcolor = IIf( last == 1, colorGreen, IIF( last == 0, colorRed, colorDefault ) ) );

process 1:

last= -1;
Watchlist = CategoryGetSymbols( categoryWatchlist, WatchListNum );
if( Status( "stocknum" ) == 0 )
{
	
	for( k = 0; ( sym = StrExtract( Watchlist, k ) ) != "" ; k++ )
	{
		for( i = BarCount - 2; i > 0  AND last = -1; i-- )
		{
			if( Buy[i] == 1 )
			{
				last[i] = 1;
			}
			else
				if( Sell[i] == 1 )
				{
					last[i] = 0;
				}

		}
		SetForeign( sym );
	}

	RestorePriceArrays();
}

You don't need to use the other (second) code (which is incorrect by the way).

Use the FIRST CODE FOR BOTH CASES, i.e. one and multiple symbols.

To process a watch list in Analysis window set an APPLY TO to "Filter"

It is all documented in the MANUAL
https://www.amibroker.com/guide/h_newanalysis.html


Quote from manual:

Basic operations

Selecting the symbol to apply analysis to.

Click on the drop down arrow in the Apply to combo to select operation mode: All symbols / Current symbol / Filter

Defining Filter

If Apply To is set to Filter, Analysis window will be run on the symbols that match filtering criteria that are definable in the Filter Settings window. To open Filter Settings window press Filter button


ALWAYS a SINGLE AFL is needed to process ANY number of symbols.
Don't use loops to iterate thru symbols! That is WRONG.

Analysis window is designed to process multiple symbols in PARALLEL using multiple THREADS. Loop is just nonsensical since you are limiting yourself to single thread.

https://www.amibroker.com/guide/h_multithreading.html

to be specific I want to count the number of symbols in Buy mode and count the number of symbols in Sell mode based on the previous signal.

and using Process 1 to generate previous signal over exploration work well however, using the same process over the watchlist does not work, are there any way to use Process 1 to count the Buy symbol in Buy Mode and Sell over Watchlist using code because I want to draw the buy symbol and sell symbol time-series data on the chart to apply some analysis on it?

Hello Tomaz, IS there any response of that case? @Tomasz

Your description is unclear.

There are many ways to count signals in multiple symbols and they don't require any loop or thinking about "processes" or whatever, for example in exploration:

Buy = .... your code
Filter = Buy;
AddColumn( Buy, "Buy" );
AddSummaryRows(1);

You can use composites AFL Function Reference - ADDTOCOMPOSITE

Or you can use StaticVarAdd AFL Function Reference - STATICVARADD

Click on those links and familiarize with existing functionality before reinventing the wheel.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.