# This module turns trading on and off based on the retracement and recovery of the equity curve
if curMarket == 0:
if len(synthEquity) > 0: print(myDate[curBar],” “, synthEquity[-1])
prevStopTrading = stopTrading
equCurveRet,equCurveRec = calcEquCurveRetandRec(synthEquity,100,equityAnchor)
if equCurveRet >= 0.10 and stopTrading == False:
stopTrading = True
equityAnchor = len(synthEquity)
print(myDate[curBar],”, stopTrading,”,equCurveRet)
equCurveRet,equCurveRec = calcEquCurveRetandRec(synthEquity,100,equityAnchor)
if stopTrading == True and equCurveRec >= 0.10:
stopTrading = False
equityAnchor = len(synthEquity)
print(myDate[curBar],”, startTrading,”,equCurveRec,”,”,equityAnchor)
synthMP = 0
if len(synthTrade[curMarket].mp) != 0:
synthMP = synthTrade[curMarket].mp[-1]
# Now you have to weave your synthetic orders inside the real order directives
if mp < 1 and dnCloses == 2 and stopTrading == False:
price = myOpen[D]
tradeName = “ESBuyNDC”
numShares = posSize
enterLongPosition(price,posSize,tradeName,sysMarkDict)
unPackDict(sysMarkDict)
if synthMP < 1 and dnCloses == 2: price = myOpen[D] tempMP = 1 # print(myDate[curBar],” “,mySymbol,” Buy @ “,price,” “,tempMP) synthMP = synthTrade[curMarket].setSynthTradeInfo(‘l’,tempMP,myDate[curBar],curBar,posSize,price) # Long Exits if mp == 1 and barsSinceEntry > 4:
price =myOpen[D]
tradeName = “4thDayOut”
numShares = curShares
exitPosition(price, curShares, tradeName, sysMarkDict)
unPackDict(sysMarkDict)
if synthMP == 1 and synthTrade[curMarket].barsSinceEntry > 4:
price = myOpen[D]
tempMP = 0
tempPosSize = synthTrade[curMarket].numShares[-1]
# print(myDate[curBar],” “,mySymbol,” LiqLong @ “,price,” “,tempMP,” “,tempPosSize)
synthMP = synthTrade[curMarket].setSynthTradeInfo(‘lx’,tempMP,myDate[curBar],curBar,tempPosSize,price)
Article written by George Pruitt
Quantified Models YouTube Channel
We have several videos available on our YouTube channel that you may find very useful in developing trading systems.
We hope this information has been useful to you.






