Forum Replies Created
-
AuthorPosts
-
ChrisViridesMember
Darryl,
I edited the Graph file so that the setups are on the same date as the buys.
Plot(Ref(setupSignals,-1),”# Buy orders placed”,colorGrey40,styleHistogram|styleOwnScale,0,maxScale);
This code is top stuff, thanks
ChrisViridesMemberDoes anyone actually plan on trading this system?
If not, why?ChrisViridesMemberBingo, thanks very much.
ChrisViridesMemberI get similar results to Darryl and Said, but when I run it with 20 positions at 5% each (no margin) the system goes broke by about 2009. Does anybody else get a similar result?
ChrisViridesMemberPaul Leavitt
[email protected]
skype: paul.leavittChrisViridesMemberRegarding Amibroker Performance tips:
https://www.amibroker.com/guide/x_performance.htmlIn short, having lots of ram is great but you do get to a point of diminishing returns. Having a good ssd and CPU are very important
Not sure about Bootcamp, but running a virtual machine means you need alot of ram, as you are running both operating systems, and you also get a performance hit, as both operating systems are sharing all the resources, cpu, screen, ram, disks.
Julien, have you considered the MS Surface Book?
ChrisViridesMemberThanks Said and Trent for your help, it appears that I may have an amibroker configuration problem as I get similar results to you when I run the code on my laptop.
ChrisViridesMemberOn a slightly related note, is everyone in Australia who is thinking of trading this system, have a reg-t account? Currently I have a cash account and the settlement delay will decrease the trade frequency significantly. I am looking at doing what is required to set up a reg-t account, is anybody else?
ChrisViridesMemberWhen I run your code, I get very similar results to my original code. Looking at your code and comparing it on a chart, it appears to do the same thing. If you run my code, do you get similar results as per my previous post?
Thanks for your help…….again
ChrisViridesMemberSince my last post I have been trying to get similar CAR/MDD ratios as you guys. Can you guys see anything in my code that is logically wrong. I have inserted all of it except the Chart Plotting.
Thanks in advance, its probably something super simple that is staring right at my blind self.
Please also see Parameters as well as Single Backtest Screenshot:
Universe: Russell 1000
Dates: 1/1/2000 – 1/1/2016Code://The rules are as follows:
// – No index Filter
// – Min average Volume is 500K
// – Close is above MA 100 days
// – BB (5,1.5)
// – Close bellow the lower band
// – BB width is greater than 5% (BBWidth = (BBTop – BBBot)/ BBBot *100;)
// – Buy on limit order if the price drops a bit under the low (0.5ATR(10))
// – Sell cross with MA 5days_SECTION_BEGIN(“Monte Carlo Coding”);
// MCS Monte Carlo Part 1 of 2
Runs = Param(“Number of Runs”,100,0,100000,100);
Run = Optimize(“Run”,1,1,Runs,1);
MCP = Param(“Probability of Ignoring any Entry Signal %”,5,1,100,1);
function RandPercent(percent)
{
perc = percent/100;
rand = 1+(perc – mtRandom() * (perc*2));
return rand;
}
MCRP = Param(“Random Percent”,2.5,1,100,1);
_SECTION_END();_SECTION_BEGIN(“Historical Data Base Testing”);
//===========================================================================
//Historical Data Base Testing
//===========================================================================
ASXList = ParamList(“ASX Historical Watchlist:”,”1: Off|2: ASX 20|3: ASX 50|4: ASX 100|5: ASX 200|6: ASX 300|7: ASX All Ordinaries|8: ASX Small Ordinaries|9: ASX Emerging Companies|10: Excluding ASX 300|11: In XAO but Exc ASX 100|12: Exc XAO”,0);HistDB = 1; //set to 1 to start
if(ASXList == “1: Off”) HistDB = 1;
if(ASXList == “2: ASX 20”) HistDB = IsIndexConstituent(“$XTL”);
if(ASXList == “3: ASX 50”) HistDB = IsIndexConstituent(“$XFL”);
if(ASXList == “4: ASX 100”) HistDB = IsIndexConstituent(“$XTO”);
if(ASXList == “5: ASX 200”) HistDB = IsIndexConstituent(“$XJO”);
if(ASXList == “6: ASX 300”) HistDB = IsIndexConstituent(“$XKO”);
if(ASXList == “7: ASX All Ordinaries”) HistDB = IsIndexConstituent(“$XAO”);
if(ASXList == “8: ASX Small Ordinaries”) HistDB = IsIndexConstituent(“$XKO”) AND NOT IsIndexConstituent(“$XTO”);
if(ASXList == “9: ASX Emerging Companies”) HistDB = IsIndexConstituent(“$XEC”);
if(ASXList == “10: Excluding ASX 300”) HistDB = IsIndexConstituent(“$XKO”) == 0;
if(ASXList == “11: In XAO but Exc ASX 100”) HistDB = IsIndexConstituent(“$XAO”) AND NOT IsIndexConstituent(“$XTO”);
if(ASXList == “12: Exc XAO”) HistDB = IsIndexConstituent(“$XAO”) == 0;//————————————————————————–
USList = ParamList(“US Historical Watchlist:”,”1: Off|2: Russell 1000|3: Russell 2000|4: Russell 3000|5: NASDAQ 100|6: Dow Jones Industrial Average|7: S&P 500|8: S&P 100|9: S&P MidCap 400|10: S&P SmallCap 600|11: S&P 1500|12: Russell MicroCap|13: Russell MidCap”,0);USHistDB = 1; //set to 1 to start
if(USList == “1: Off”) USHistDB = 1;
if(USList == “2: Russell 1000”) USHistDB = IsIndexConstituent(“$RUI”);
if(USList == “3: Russell 2000”) USHistDB = IsIndexConstituent(“$RUT”);
if(USList == “4: Russell 3000”) USHistDB = IsIndexConstituent(“$RUA”);
if(USList == “5: NASDAQ 100”) USHistDB = IsIndexConstituent(“$NDX”);
if(USList == “6: Dow Jones Industrial Average”) USHistDB = IsIndexConstituent(“$DJI”);
if(USList == “7: S&P 500”) USHistDB = IsIndexConstituent(“$SPX”);
if(USList == “8: S&P 100”) USHistDB = IsIndexConstituent(“$OEX”);
if(USList == “9: S&P MidCap 400”) USHistDB = IsIndexConstituent(“$MID”);
if(USList == “10: S&P SmallCap 600”) USHistDB = IsIndexConstituent(“$SML”);
if(USList == “11: S&P 1500”) USHistDB = IsIndexConstituent(“$SP1500”);
if(USList == “12: Russell MicroCap”) USHistDB = IsIndexConstituent(“$RUMIC”);
if(USList == “12: Russell MidCap”) USHistDB = IsIndexConstituent(“$RMC”);//————————————————————————–
HDBFilter = HistDB AND USHistDB; //combine both lists for a filter//==========================================================================
_SECTION_END();_SECTION_BEGIN(“Index Filter”);
//============================================================================
//Index Filter
//============================================================================
“”;
“Index Filter:”;
IndexTog = ParamToggle(“Index Filter”,”Off|On”, 0);
IndexCode = ParamStr(“Index Symbol”,”$XAO.asx”);
Index = Foreign(IndexCode, “Close”);
IndexMA = Param(“Index Filter MA”, 200,2,1000,1);
IndexFilterUp = Index > MA(Index,IndexMA);
IndexUp = IIf(IndexTog, IndexFilterUp, 1 );
//============================================================================
_SECTION_END();//===========================================================================
//Optional Price, Volume and Liquidity Filters
//===========================================================================
_SECTION_BEGIN(“Price Filter (Optional)”);
PriceTog = ParamToggle(“Price Filter”,”Off|On”, 0);
PF = ParamField(“Price Field”, 3);
MinSP = Param(“Minimum Share Price – $”, 5,0.00,1000,.01);
MaxSP = Param(“Maximum Share Price – $”, 100,0.00,1000,.01);
MinMaxSP = PF >= MinSP AND PF <= MaxSP; PriceFilt = IIf(PriceTog, MinMaxSP, 1); _SECTION_END(); _SECTION_BEGIN("Turnover Filter (Optional)"); TOTog = ParamToggle("Turnover Filter","Off|On", 0); Turnover = PF *V; MinTO = Param("Minimum Turnover - $", 500000,0,10000000,1000); TOMA = Param("Turnover MA", 7,1,200,1); AveTO = EMA(Turnover, TOMA); TOFilter = AveTO > MinTO AND Turnover > MinTO;
TOFilt = IIf(TOTog, TOFilter, 1);
_SECTION_END();_SECTION_BEGIN(“Liquidity Filter (Optional)”);
liqTog = ParamToggle(“Liquidity Filter”,”Off|On”, 0);
MinLiq = Param(“Minimum Liquidity”, 500000,0,10000000,1000);
liMA = Param(“Liquidity MA”, 7,1,200,1);
aveLiq = EMA(V, liMA);
liqFilter = aveLiq > MinLiq;
liqFilt = IIf(liqTog, liqFilter, 1);
_SECTION_END();OptFilt = PriceFilt AND TOFilt AND liqFilt;
//=================================================================================_SECTION_BEGIN(“Universe Filter”);
//============================================================================
//Universe Filter
//============================================================================
“”;
“Universe Filter:”;
Universe = ParamList(“Universe Filter:”, “1: Off|2: Resources|3: Industrials”,0);
UniverseFilter = 1;
if (Universe == “1: Off”) UniverseFilter = 1;
if (Universe == “2: Resources”) UniverseFilter = InGics(“10”) OR InGics(“151040”);
if (Universe == “3: Industrials”) UniverseFilter = InGics(“10”) == 0 AND InGics(“151040”) == 0;
//============================================================================
_SECTION_END();_SECTION_BEGIN(“Parameters”);
//=================================================================================
//Parameters
//=================================================================================
ATRPeriod = Param(“ATR Period”, 10,1,100,1);
ATRMultiply = Param(“ATR Multiplier”,0.5,0,10,.01);
SellMAParam = Param(“Sell MA Period”, 5,2,200,1);
BuyMAParam = Param(“Long MA Period”, 100,2,200,1);//=================================================================================
//BuySetup and Buy Rules
//=================================================================================
UpperBB = BBandTop(C,5,1.5);
LowerBB = BBandBot(C,5,1.5);
BBWidth = ((UpperBB – LowerBB)/ LowerBB) * 100;
ATRStop = ATR(ATRPeriod) * ATRMultiply;
IsFilter = OptFilt AND IndexUp AND UniverseFilter AND HDBFilter;Cond1 = C > MA(C, BuyMAParam);
Cond2 = C < LowerBB; Cond3 = BBWidth > 5;BuySetup = Cond1 AND Cond2 AND Cond3 AND IsFilter;
BuyStop = L – ATRStop;
OnLastTwoBarsOfDelistedSecurity = BarIndex() >= (LastValue(BarIndex()) -1) AND !IsNull(GetFnData(“DelistingDate”));
OnSecondLastBarOfDelistedSecurity = BarIndex() == (LastValue(BarIndex()) -1) AND !IsNull(GetFnData(“DelistingDate”));//=================================================================================
//Entry and Exit Signals
//=================================================================================LE = Ref(BuySetup,-1) AND L <= Ref(BuyStop,-1) AND NOT OnLastTwoBarsOfDelistedSecurity; //Long Entry LEPrice = Min(O,Ref(BuyStop,-1)); //Entry Price //--------------------------------------------------------------------------------- //initial stop LIS = MA(C,SellMAParam); //Long Initial Stop //MCS code part 2 if (MCP) LE = LE && Random()*100 >= MCP;
Short = Cover = False;//=================================================================================
//Looping
//=================================================================================
Buy = 0;
Sell = 0;
PriceAtBuy = 0;
LBIT = 0;
LStop = Null;
//=================================================================================
for (j = 1; j < BarCount; j++) { if (PriceAtBuy==0 AND LE[j]) { Buy[j] = True; PriceAtBuy = LEPrice[j]; BuyPrice[j] = LEPrice[j]; LStop[j] = LIS[j]; LStop[j-1] = LIS[j-1]; LBIT[j] = 1; if (LBIT[j]>1 AND C[j-1] >= LStop[j-1] OR OnSecondLastBarOfDelistedSecurity[j])
{
Sell[j] = True;
SellPrice[j] = O[j];
PriceAtBuy = 0;
}
}else
if (PriceAtBuy > 0)
{
LBIT[j] = LBIT[j-1]+1;if (LBIT[j]>1)
{
LStop[j] = LIS[j];
}if (LBIT[j]>1 AND C[j-1] >= LStop[j-1] OR OnSecondLastBarOfDelistedSecurity[j])
{
Sell[j] = True;
SellPrice[j] = O[j];
PriceAtBuy = 0;
}
}
}//———————————————————————————
InitialExit = C >= LStop;
LESetup = IIf(LBIT==0 OR Sell==1,BuySetUp,0); //Long Entry Setup
LExSetup = IIf(LBIT>0 AND Sell==0,InitialExit,0); //Long Exit Setup
//———————————————————————————
Short = Cover = False;//=================================================================================
//Exploration
//=================================================================================
Filter = Buy OR Sell OR LESetup OR LExSetup OR LBIT > 0;//=================================================================================
//Interpretation Window
//=================================================================================
AddTextColumn(WriteIf(LESetup,”Buy Setup”,””),”Entry Signal”,1.2,colorDefault,IIf(LESetup,colorBrightGreen,colorDefault),130);
AddTextColumn(WriteIf(LExSetup,”Exit”,””),”Exit Signal”,1.2,colorDefault,IIf(LExSetup,colorRed,colorDefault),100);
AddTextColumn(WriteIf(Buy,”Buy”,””),”Today’s Entries”,1.2,colorDefault,IIf(Buy,colorGreen,colorDefault),130);
AddTextColumn(WriteIf(Sell,”Sell”,””),”Today’s Exits”,1.2,colorDefault,IIf(Sell,colorRed,colorDefault),130);
AddColumn(LBIT,”LBIT”,1.0);
SetSortColumns(-3,-4,-5,-6,1);//=================================================================================
_SECTION_END();
_SECTION_BEGIN (“Backtesting”);
//=================================================================================
//Backtesting Parameters & Position Sizing
//=================================================================================
SetTradeDelays(0,0,0,0);
Capital = Param(“Initial Equity $”,100000,1000,10000000,100);
SetOption(“InitialEquity”,Capital);
MaxPos = Param(“Maxium Open Positions”,20,1,100,1);
SetOption(“MaxOpenPositions”,MaxPos);
SetPositionSize(100/MaxPos,spsPercentOfEquity);
SetOption(“CommissionMode”, 3);
SetOption(“CommissionAmount”, 0.005);
PositionScore = mtRandom();//=================================================================================
_SECTION_END();ChrisViridesMemberResults from Single Run Backtest:
Position Score: Random
1/1/2000 – 1/1/2016
20 Positions @ 5% eachChrisViridesMemberI think this is a super idea, I will try contribute.
ChrisViridesMemberSounds good.
After 4 pm is good for me during the week. Anytime on the weekend also works.
ChrisViridesMemberTrenRoth wrote:Hi,just out of curiosity what does the flag++; do in the loop?
its the equivilent of the following:
flag = flag +1;
it just increments by 1, you can use — to decrement also.
ChrisViridesMemberThis maybe simplifying things, but when your commission drag increases, your edge has to increase to maintain similar profitability. Is your increased edge negated by the increased commission drag?
I like your thinking, let us know how your results fare.
-
AuthorPosts