This AFL can be easily constructed. Rather than drawing lines on chart, use following method:
(1) Save the Entry Stop Loss and Target in a CSV at a particular path. This will give you full flexibility. You will be able to apply one SLTP on entire basket or modify per scrip.
(2) Parse the path and read the values per scrip/basket.
(3) Create watchlist and run analysis on watchlist with Auto Refresh Interval (with desired periodicity).
(4) Program the trade execution in the AFL.
Amibroker will automanage all the positions and it will work like a charm.
Here's the file parsing snippet for your reference
fh = fopen( "D:\\target.csv", "r" );
if( fh )
{
while( ! feof( fh ) )
{
line = fgets( fh );
sym = StrExtract( line, 0 );
if ( Name() == sym )
{
symfound=1;
symtyp = StrExtract( line, 1 );
symsl = StrToNum( StrExtract( line, 2 ) );
sympos = StrToNum( StrExtract( line, 3 ) );
symactive = StrExtract( line, 4 );
}
}
}