AddToComposite and sync point

I am using Amibroker to explore trading strategies. I typically use backtesting feature of the tool.

I really like the tool for its conceptual simplicity and fast performance.

I have one doubt regarding AddToComposite. I understand that the composite ticker is updated as formula is being applied to various symbols.

I was wondering if there is a notion of sync-point function that we can use in the AFL code, which pauses the execution of subsequent code till all the earlier instances of AddToComposites have been executed for all the symbols. Something similar to pthread_join for POSIX thread (

The closest technique that I found is the one that is noted in section "Using the Optimizer as a Task Scheduler' of the document - "Introduction to the AmiBroker AddToComposite". The technique however seemed like a workaround.

with regards

No, you can't wait for that because updates to composite symbol via AddToComposite are completely asynchronous and done in different dedicated thread from your formula running thread. That way formula threads do not need synchronization because they don't do the work - they just send data to be added to updating thread. The updating thread is doing the work for them.

But you can use StaticVarAdd instead of AddToComposite. Static variable operations are atomic and you can read the value via StaticVarGet and it is valid at each point (of course it will contain values added upto current symbol)

Hi @Tomasz
Thanks for clarification..

I will read more about StaticVarAdd and try to use it instead of AddToComposite..

with regards

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