Help with restructuring my script?

Hi @Milosz

I would really like your input after you expressed interest in making suggestions on how to simplify the complexity of the script I am developing.

The script tries to do Price Action analysis. This involves identifying patterns, Support/Resistance lines, isolating major or smaller moves/legs of price, calculating the strength of those moves etc. This analysis is done for each bar, it cannot be done in an array style operation, it is way too complex.

4 Timeframes are used. The highest is used only only to identify major Support/Resistance lines. The other timeframes are analysed more rigorously.

Some data from the higher timeframe goes to the lower timeframe. For example the Swing Highs and Lows of the higher >Timeframe become Support/Resistance lines of the lower timeframe. Also an S/R line that originates to much higher TF swing, has a lot more strength for the much lower Timeframes.

The script checks for the status( "actionEX" ) and behaves differently if it is in one of the following modes:
actionBacktest, actionExplore, actionIndicator

When in actionExplore mode, it is autorun every 1sec, and checks if there is a new bar formed. If so, it does all the necessary calculations.

The bulk of the script code is dedicated to actionExplore mode.
When in actionBacktest, it basically runs all bars (with barindex() from 0 to barcount-1) and applies all the calculation of the script in the actionExplore mode. (I admit I have very little experience in real backtesting, but some tests I had run with this script were without any problem).

Here is the 5min chart during Bar Replay:
run

Here is the analysis window during Bar Replay:
run2

@Milosz had proposed I could use MDI windows (for the 4 timeframes). They would still need to produce staticvars that would need to be read from the lower timeframes. Also, I need to somehow hold the execution of the lower TF scripts, until the higher TF script finishes processing in case multiple Timeframe bars develope at the same time. For example when time is 16:00 exactly, then I have formed a new bar in 1Hour, 15min, 5min and 1min. Since 1min S/R lines are depended on higher Timeframes, I need to process them first.

I also need to figure out how to do the BACKTESTING of such a setup.

Bob, in your prior thread, I have offered you some suggestions regarding how to avoid problems with your complex TimeFrameCode and how to make it simpler and more effective. You can make use of them and try them out or not. But at the same time I don't know all the details of your system and its full specification - and it is not my role to dive into all aspects of your complex system. Whether you use AA Window or not - depends on you. You can also have one code for backtesting purposes and another - light and effective solution for realtime trading. You need to experiment on your own and choose the most appropriate way.

Besides I'm not an expert when it comes to sole price analysis and backtesting. I concentrate on volume analysis and news flow analysis as merging these two, gives me the edge that I'm looking for. When volume price analysis is backed up by interesting news flow (or news events) the odds are in my favor. I love AmiBroker because it allows me to create really unique tools - impossible to code in any other technical analysis program that I know ( I'm only an amateur coder...)

There are many experienced users on this forum who can give you better advices regarding backtesting, but I encourage you to try out some alternative solutions on your own, before asking about every detail on the forum. Let me give you an example. Today you have asked me - I quote:

Those MDI windows you had suggested, will run automatically when a new bar forms, or I have to activate them with a timer?

Firstly, we have already discussed this issue in details in another thread, secondly you can check this out on your own, in a few seconds ...

Regards.

Thank you for your thoughts Milosz.