AmiBroker Error 701

119 views
Skip to first unread message

SteveJ

unread,
Oct 6, 2021, 2:59:03 PM10/6/21
to Adaptrade Builder
When I transfer code to AmiBroker for a short strategy and attempt a backtest I receive the message:-

Error 701. Missing buy/sell variable assignments.

The formula that you are trying to backtest does not contain proper Buy and Sell rules. Buy and Sell rules should be written as assignments as shown below:

Buy = Cross( Close, MA( Close, 50 ) );
Sell = Cross( MA( Close, 50 ), Close ) );

Help please.

Mike Bryant

unread,
Oct 6, 2021, 3:28:36 PM10/6/21
to adaptrad...@googlegroups.com

Did you install the code that comes with Builder that is required by AmiBroker? From the user’s guide (Getting Started, Installation):

 

Platform Files: Builder includes several functions and indicators that need to be installed into the trading platforms for Builder-generated strategies to run properly. If these functions are not installed, the strategies generated by the program will not compile or run. These functions must be installed separately for each platform you intend to use for trading. Please read the sections below for the platforms you intend to use. To determine if the platform files have been updated for the current release and therefore need to be re-installed (if installed previously), please refer to the Release Notes page at Adaptrade.com or see the notes on the trial download page for the current release.

AmiBroker Installation Notes. AmiBroker strategies created by Builder require an associated "include" file: ASBuilderCommon.afl. This file can be found in the AFL folder in the Adaptrade Builder folder after Builder is installed. This file needs to be copied to the Include folder in the AmiBroker Formulas folder under Program Files. The full path under 64-bit Windows is C:\Program Files\AmiBroker\Formulas\Include. This file provides basic functionality that all AmiBroker strategies generated by Builder require.

 

Mike Bryant

Adaptrade Software

SteveJ

unread,
Oct 6, 2021, 7:16:17 PM10/6/21
to Adaptrade Builder
Thank you Mike.

I have copied that file to the "Include" directory but it appears it is not being 'included' in the AmiBroker script when I try to run a backtest.

If I open  ASBuilderCommon.afl in Notebook then copy the entire contents to the beginning of the Builder generated code the code backtests as expected.

Mike Bryant

unread,
Oct 6, 2021, 7:21:52 PM10/6/21
to adaptrad...@googlegroups.com

All AmiBroker strategies generated by Builder include the following line near the top of the strategy, just under the comment block:

 

#include <ASBuilderCommon.afl>

 

That’s where the required code is included in the strategy. You should not directly copy the code from ASBuilderCommon.aft directly into the strategy code.

 

If for some reason the strategy code you’re looking at doesn't contain the #include statement shown above, it’s not a valid Builder-generated strategy for AmiBroker. In that case, you should rerun the strategy; i.e., “Evaluate” it from the Evaluation menu, making sure AFL (“Ami”) is selected as the code type. In general, if you want to build strategies for AmiBroker, you should select the AmiBroker code type prior to building.

SteveJ

unread,
Oct 7, 2021, 2:13:27 PM10/7/21
to Adaptrade Builder
Thanks. I've resolved this by reinstalling AmiBroker which, for some reason, wasn't recognising  ASBuilderCommon.afl  
Reply all
Reply to author
Forward
0 new messages