Hello everyone,

I had a question earlier on this group for finding signals from multiple
time frames.

I managed to write a code to get desired output.



In short –

The system is to find buy signal on daily chart. And for that day, trade
intraday based on 1 min chart.

The base time interval is daily to search for signals on daily chart
basis, and then after a signal received for a particular day, time frame
is converted to 1 minute for intraday trading. After switching to 1
minute time frame buy and sell signals are derived from multiple
criteria based on combination multiple indicators.

Start. Daily chart - >

    Loop, check each daily bar and find a buy signal - >

       If daily buy signal –>

          For each daily bar after a buy signal - expand the day to 1
minute chart ->

            Loop to check each 1 min intraday bar ->

               Look for intraday buy signal using patterns and indicators
->

                  Buy - >

                     Apply trailing stop and stoploos and scan realtime
->

                        Sell ->  Sell if stoploss or trailstop hit. else
sell at last minutes of day closing session. End.



The code has gone lengthy, the loops are larger, I did some fine-tuning
where I don't run loops or skip them whenever they are not needed.

For backtesting in this sequence I have to scan daily bars till I hit a
buy signal, after a daily buy signal I expand that day to 1 minute bar.
And then trade on this 1 minute chart, find a buy signal on 1 min chart,
and sell on stoploss or trailing stop.

Still for 500 scrip's intraday backtesting of last 3 days it freezes
and takes a good 2 hour to execute.

This extremely slow, the good part is AmiBroker is pretty robust. At the
end I get the result perfectly but this slowness is a big issue for me,
I can't start using the formula in real trade since the scanning
duration goes more than 2 hours for RT data feeding.

Sometime system gets so buys and start receiving this error - Error 47.
Exception occurred during AFL formula execution at address: 467B39,
Code:C0000005.

What dose error 47 means?

There are no syntax errors, if I limit the number of bars to execute
then without changing anything in the code, it executes perfectly. For
longer loops I start getting the error.

37747 data bars used during this check. Total execution time: 886.614
sec.

Approximately ALL past and ALL future quotes are needed to calculate the
formula properly

Is there any reference on how to harden the code, or optimize AFL code
for maximum speed for execution, and to skip unnecessary steps? Did
anyone of you face this problem? What measures were done to fix this?
any ideas?



Thanks



Reply via email to