- Joined
- 27 November 2017
- Posts
- 1,200
- Reactions
- 1,884
All,
I was hoping that someone could provide assistance in helping with coding up some CBT code so I can trace what Market Regime is in use when Buy Signal is initiate and then once this is working I can leverage of the code to add more data points.
Code located here - https://www.aussiestockforums.com/threads/amibroker-tips-and-tricks.35508/#post-1076776
Statement of Requirements
- BUY is initiated
- Return status of RegimeFilter array to Backtest trade list
But now need to map the correct data into CBT.
Code in main AFL
StaticVarSet( Name() + "Regime Filter ", RegimeFilter );
Code in CBT
for( trade = bo.GetFirstOpenPos(); trade; trade = bo.GetNextOpenPos() )
{
// read Regime Filter values and display as custom metric
symbolRegime = StaticVarGet( trade.Symbol + "Regime Filter" );
trade.AddCustomMetric( "Entry Regime Filter", Lookup( symbolRegime, trade.EntryDateTime ) );
NumTrades++;
}
// iterate through closed trades
for ( trade = bo.GetFirstTrade( ); trade; trade = bo.GetNextTrade( ) )
{
// read Regime Filter values and display as custom metric
symbolRegime = StaticVarGet( trade.Symbol + "Regime Filter" );
trade.AddCustomMetric( "Entry Regime Filter", Lookup( symbolRegime, trade.EntryDateTime ) );
}
Any ideas would be appreciated. Just a push in the right will do, but this is the one area where I am really struggling. The more I play with it I am sure that I can crack it open.
Cheers
Trav
I was hoping that someone could provide assistance in helping with coding up some CBT code so I can trace what Market Regime is in use when Buy Signal is initiate and then once this is working I can leverage of the code to add more data points.
Code located here - https://www.aussiestockforums.com/threads/amibroker-tips-and-tricks.35508/#post-1076776
Statement of Requirements
- BUY is initiated
- Return status of RegimeFilter array to Backtest trade list
RegimeFilter = IIf( VolatileBear, Volatile Bear, IIf( QuietBear, Quiet Bear, IIf( QuietBull, Quiet Bull, IIf( VolatileBull, Volatile Bull, Null))));
I can get the following in the Trade List
But now need to map the correct data into CBT.
Code in main AFL
StaticVarSet( Name() + "Regime Filter ", RegimeFilter );
Code in CBT
for( trade = bo.GetFirstOpenPos(); trade; trade = bo.GetNextOpenPos() )
{
// read Regime Filter values and display as custom metric
symbolRegime = StaticVarGet( trade.Symbol + "Regime Filter" );
trade.AddCustomMetric( "Entry Regime Filter", Lookup( symbolRegime, trade.EntryDateTime ) );
NumTrades++;
}
// iterate through closed trades
for ( trade = bo.GetFirstTrade( ); trade; trade = bo.GetNextTrade( ) )
{
// read Regime Filter values and display as custom metric
symbolRegime = StaticVarGet( trade.Symbol + "Regime Filter" );
trade.AddCustomMetric( "Entry Regime Filter", Lookup( symbolRegime, trade.EntryDateTime ) );
}
Any ideas would be appreciated. Just a push in the right will do, but this is the one area where I am really struggling. The more I play with it I am sure that I can crack it open.
Cheers
Trav