Simulataneously maintaining array of different timeframes for a instrument

I want to run my code in different time frames in one single analysis. That means I set the periodicity to the lowest timeframe (that i want to use) and then loop through every time frame in my code to generate arrays and trades. So for example for Stock AAAA I want to trade on 1, 2, 3, 4, 5 minutes so i set periodicity to 1 minute in analysis settings and then loop through the time frames in my code as shown below. Also I want to be able to place trades in different timeframes and these I want them to be treated separately from one another. For example For Stock AAAA I may have a Long position starting at 10AM on 5 minutes timeframe and then another Long trade that opens at 10:03AM in 3 Minute timeframe an then a Short trade opening at 10:15 in 1 minute timeframe. I want these 3 trades howing up as 3 indicidual trades in the trade list. So in summary Stock + timeframe combination can have a Long or short trade open simultaneously. All this from one single analysis window.

for (tfCounter=1; tfCounter<=5;tfCounter++)
{
Timeframeset(tfCounter * in1minute);
// my code
TimeframeRestore();
}

I want the tradelist to look something like below. Notice the custom column timeframe.

When i open the trades (show current trade arrows) it will open in base periodicity and then I have to manually switch to the respective time frame.
How can i achieve this. All i need is some inspiration. :innocent:

You can do this easily, just follow closely the instructions given in manual
https://www.amibroker.com/guide/h_timeframe.html

Please do read carefully the "orange boxes" in the guide.

The most important one, is once you have your trading rules coded for different interval, you MUST call TimeFrameExpand on all compressed arrays as instructed in the manual, quote:

IMPORTANT: TimeFrameExpand IS REQUIRED for any formula that uses TimeFrame* functions. If you don't expand time compressed data you will have incorrect timestamps (see description below in "How it works").

2 Likes

Very educational thread!

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