C++ Trading
Framework (Professional Software Solutions) |
Currently integrated into BTSeqMgr - in stdafx.h"
//For BTSeqMgr undefine all below AND BARMGR_NORAREAVG
#define SEQ_HW 1 // Switch BTSeqMgr to Strategy external Testing Mode
#define BGM_BT 1 // Activate BT Functions in BGM/BCM Modules
Central new BTDlg Bar Processing hook:
int CBTSession::RunScript(const char *pFn,CTxt &txtErr)
int CBTSession::RunBTCmd(const char *pCmd,CTxt &txtErr)
int CPTStrat::Session_ProcessBar(CBTStratParMgr *pParMgr,BOOL bNewRun,CTxt &txtErr,CBarCalcData *pNewTick)
CBTSeqMgrDlg::ThreadBTRun
CPTStrat::Session_ProcessBar(CBTStratParMgr *pParMgr,BOOL bNewRun,CTxt &txtErr,CBarCalcData *pNewTick)
Processes new Bar against the startegy logic
pParMgr = Strategy
Parameters
bNewRun = One time
TRUE when a new data run starts
pNewTick= New
Bar
float m_fStratPar[BCM_MAXSTRATPAR]; // mirror of Strategy parameter
bNewRun == TRUE
a) Initialize the local strategy parameterr in m_fStratPar[]
b) Initialize the BCM parameter (fMinMove, fAmtPerPt, fComm, nBGMMode, fStockPosAmt,
bDiag)
c) Call CXXXStrat ::OnStratSetInputs() - to allow custom strategy logic to
initialize its internal parameters
CXXXStrat ::OnCalcTracks(int nDataTrack,CBarCalcData *pBar,BOOL
bAdd)
a) Check if first time: GetNumStratTrack() < 1) -
if yes - add calc tracks: GetBCM1()->AddCalcTrack()
b) Run calculations for each calc track: pTrack->CalcTrackBar(pBar);
Saves the track values into the Cal Bar: pBar->SetColFltVal(iColBar,fVal[iCol]);
c) Real Strat processing: int ret = m_pBCM1->GetIBCMStrat()->OnProcessNewBar(NULL);
CXXXStrat ::OnProcessNewBar(float
*pValOut)
a) CalcNewBar() -
establish new bar: m_pBarLast1, m_nStratBarNbr1
set local calc values: fVal =
GetBarLast1()->GetBarVal(BAR_XXX);
b) OnCheckForNewSetup() - check if we found a new
Startegy Setup trigger:
CTrdSetup *pSetLast = GetLastSetup();
if setup: pSetLast = AddSetup( 1,GetBarLast1(),txtData,m_txtColHdr);
in CPTStrat::AddSetup(int nDir,CBarCalcData *pBar1,const char *pMsg,const char *pHdr)
c) CPTStrat::OnProcessSetups(float *pValOut) -
processes EACH setup:
pSetup->AddTickSetupBar(pBarNewTick,pValOut);
CXXXStrat ::OnCalcSetup(CTrdSetup *pSetup,float *pValOut)
c1) Custom logic to transition strategy stages:
//====== CHECK STRATEGY STAGE ================================
switch (nStage)
{
case 1:
break;
case 2:
break;
case BCM_SET_ENTRYSTAGE: // still trying to enter
can call: pSetup->ExitSetup(GetBarLast1(),NULL,pValOut);
break;
case BCM_SET_ENTRYSTAGE+1:
can call: pSetup->ForceExit(txtData);
break;
}
pSetup->SaveBarVal(pValOut);
m_nStage = 1 - initial value - set in InitSetup
BCM_SET_ENTRYSTAGE=10 // when we try to enter=10, 11=actually entered
BCM_SET_DONESTAGE 20 // Setup has completed
BCM_SET_KILLSTAGE 30 // Setup has killed itself
m_bTickByTick == FALSE
New Bars are all newly closed bars
m_bTickByTick == TRUE
New Bars are new ticks WITHIN a newly forming bar -
accumulates the new bar values using m_BarNewTick
m_bIntraBarTick
Name | Description |
CBTStratParMgr | In BTSeqssion - m_StratPar - Strategy Parameter Manager |
CPTStrat::Session_ProcessBar | Processes new Bar againstthe startegy logic |
WaitStartOpt | |