AB 7.0.0 WIN 11 usinf IQfeed data
Have started backtesting with intraday data and getting some apparently random errors in computing the profit amount even though the entry and exit prices are (presumed) correct.
The %change and %profit are correct based on Entry and Exit prices
I don't know if the report summaries for average profit is correct or not.
Backtests were done with 30 min time frame
Examples 1 symbol COIN:
Entry price = 301.415
Exit price = 300.59
%Change = -0.27%
Profit = -30.20 (Incorrect, should be -0.825)
%Profit = -0.27%
Example 2 symbol AMD:
Entry price = 165.55
Exit price = 168.65
%Change = 1.87%
Profit = 208.55 (Incorrect,should be 3.10)
%Profit = 1.87%
![]()
![]()
// File: Trading MACD Acceleration
// November 1, 2025
// version 0.1
Vers = 0.1;
//
// Purpose of this program is to Backtest programs
// - There are 5 time frames being tested: 15, 30, 60, 120 minutes and Daily
// Acceleration is defined as:
// - MACDslope > 0 and MACDslope > ref(MACDslope,-1)
// - MACDslope < 0 and MACDslope < ref(MACDslope,-1)
//
// Trade signal:
// - Initiate trade - Acceleration in current timeframe
// - Hold Trade - Acceleration in smaller time frame and MACD slope in direction of trade
//
// Trades require only one time frame to initiate
//
//
//
// ===================================================== Gereral Variables and parameters ===============================================
//
bi = barindex();
lbi = lastvalue( bi );
ai = lbi - bi[0];
//
Pgm_Title = "MACD Acceleration Backtest " + vers;
TimeFrame = Param("TimeFrame",1,1,5,1);
TFoptimize = Optimize("TFoptimize",TimeFrame,1,5,1);
debug = Param( "debug", 0, 0, 1, 1 );
//
//
//
TA_Left = 0;
TA_Right = 2;
TA_Center = 1;
//
//
Trading_time = 1 ;
//Trading_time = Now(3) > 063000 and Now(3) < 130000;
//
// ================================================================= Price Chart ========================================================
//
Switch (TFoptimize)
{
case 1: TF = in15minute; break;
case 2: TF = 2*in15minute; break;
case 3: TF = inhourly; break;
case 4: TF = 2*inhourly; break;
case 5: TF = inDaily; break;
}
//
TimeFrameSet( TF );
//
price = (O+H) / 2;
MACD1 = MACD(12,26);
MACDslope = MACD1 - ref(MACD1,-1);
MACD_Bullaccelete = ref(MACDslope,-1) > 0 and MACDslope > ref(MACDslope,-1);
MACD_Bearaccelete = ref(MACDslope,-1) < 0 and MACDslope < ref(MACDslope,-1);
//
TimeFrameRestore();
//
Buy = Trading_time and MACD_Bullaccelete;
Sell = Trading_time and (MACDslope < 0);
//
BuyPrice = Open;
SellPrice = Open;
ShortPrice = Open;
CoverPrice = Open;
//
StartEquity = 100000;
Max_Pos = 10;
//
SetTradeDelays( 0,0,0,0);
//SetOption( "PriceBoundChecking", False ) ;
SetOption( "AllowPositionShrinking", True );
SetChartOptions( 0, chartShowArrows );
SetOption( "futuresmode", False );
SetOption( "InitialEquity", StartEquity );
SetOption( "MinShares", 1 );
SetOption( "MaxOpenPositions", Max_Pos );
SetOption( "MaxOpenLong", Max_Pos );
SetPositionSize( 100 / Max_Pos, spsPercentOfEquity );
//SetPositionSize( 20000, spsValue );