Home › Forums › Trading System Mentor Course Community › Trading System Brainstorming › Group Collaboration System Ideas
- This topic is empty.
-
AuthorPosts
-
May 24, 2016 at 4:09 am #104058ChrisViridesMember
When 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
May 24, 2016 at 4:13 am #103743ChrisViridesMemberOn 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?
May 24, 2016 at 6:14 am #103744TrentRothallParticipantHi Paul
Quote:On 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?I Probably won’t trade this, but i set up a Reg-T through IB to run my system because of the issues you mentioned. It isn’t hard but a bit of a process you need to a setup a company account to access it in Aus
A few things i saw
1. I don’t think your MCS code is right in your system, it seems to be mashed up with the code used for randomizing prices in stress testing. You might need to revisit that section. It might not affect results i am not sure?
2
your results are not too different to mine, might be from the above. But like Said mentioned your exit in the looping isn’t quite right. I removed the LStop section in there and added a bit to the Exit condition above the looping. Oh, also removed the MCS just to simplify the code for now.
The results are the same as mine now, someone else might want to check though
Code://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(“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 LExSetup = C > LIS;
LEx = Ref(LExSetup,-1);//=================================================================================
//Looping
//=================================================================================
Buy = 0;
Sell = 0;
PriceAtBuy = 0;
LBIT = 0;
//=================================================================================
for (j = 1; j < BarCount; j++) { if (PriceAtBuy==0 AND LE[j]) { Buy[j] = True; PriceAtBuy = LEPrice[j]; BuyPrice[j] = LEPrice[j]; LBIT[j] = 1; if (LBIT[j]>1 AND (LEx[j] 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 AND (LEx[j] OR OnSecondLastBarOfDelistedSecurity[j]))
{
Sell[j] = True;
SellPrice[j] = O[j];
PriceAtBuy = 0;
}
}
}//———————————————————————————
LESetup = IIf(LBIT==0 OR Sell==1,BuySetUp,0); //Long Entry Setup
LExSetup1 = IIf(LBIT>0 AND Sell==0,LExSetup,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();May 24, 2016 at 6:29 am #103745TrentRothallParticipantEdit to above:
Results are a bit different to mine but similar
Here is my code, i have a exit after x-days though but you can make it 50 days and should be ok.
ps. I left my filters etc off, they are just from the course
Code:_SECTION_BEGIN(“Parameters”);
//=====================================================================================
//Parameters
//=====================================================================================
MAp1 = Param(“Long MA”,100,1,500,5);
MA1 = MA(Close, MAp1);MAp2 = Param(“Short MA”,5,1,100,1);
MA2 = MA(Close, MAp2);
//————————————————————————————
BollTopPer = Param(“Bollinger Band Top Period”,5,1,100,1);
BollTopWid = Param(“Bollinger Band Top Width”,1.5,0.1,10,0.1);
BollTop = BBandTop(C, BollTopPer, BollTopWid);BollBotPer = Param(“Bollinger Band Bottom Period”,5,1,500,1);
BollBotWid = Param(“Bollinger Band Bottom Width”,1.5,0.1,10,0.1);
BollBot = BBandBot(C, BollBotPer, BollBotWid);BBWidth = ((BollTop – BollBot)/BollBot)*100;
BBPercP = Param(“BollBand Width > x%”, 5,1,100,1);
//————————————————————————————
ATRp = Param(“Limit Price: ATR period”,10,1,200,5);
ATRmulti = Param(“Limit Price: ATR Multi”,0.5,0,100,.1);
ATRVal = ATR(ATRp)*ATRmulti;BuyLimP = L – ATRval;
TickLo = IIf(L<0.10,0.001,IIf(L<2.00,0.005,0.01));
BuyLimVal = round(BuyLimP/TickLo);
BuyLim = BuyLimVal * TickLo;
//------------------------------------------------------------------------------------
FailSafeEx = Param("Fail Safe Exit: # Days",6,1,100,1);
//=====================================================================================
_SECTION_END();//=====================================================================================
//Entry + Exit
//=====================================================================================
Cond1 = OptFilt AND UniverseFilt AND IndexUp AND HDBFilter;
Cond2 = Close > MA1;
Cond3 = Close < BollBot; Cond4 = BBWidth > BBPercP;BuySetup = Cond1 AND Cond2 AND Cond3 AND Cond4;
OnLastTwoBarsOfDelistedSecurity = BarIndex() >= (LastValue(BarIndex()) -1) AND !IsNull(GetFnData(“DelistingDate”));
OnSecondLastBarOfDelistedSecurity = BarIndex() == (LastValue(BarIndex()) -1) AND !IsNull(GetFnData(“DelistingDate”));LE = Ref(BuySetup,-1) AND (L <= Ref(BuyLim,-1) AND NOT OnLastTwoBarsOfDelistedSecurity); LEPrice = Min(Open,ref(BuyLim,-1)); //------------------------------------------------------------------------------------- LExSetup = C > MA2;
LEx = Ref(LExSetup,-1);LExSetup1 = FailSafeEx;
LEx1 = Ref(LExSetup1,-1);//=================================================================================
//Looping
//=================================================================================
Buy = 0;
Sell = 0;
PriceAtBuy = 0;
LBIT = 0;
//=================================================================================
for (j = 1; j < BarCount; j++) { if (PriceAtBuy==0 AND LE[j]) { Buy[j] = True; PriceAtBuy = LEPrice[j]; BuyPrice[j] = LEPrice[j]; LBIT[j] = 1; if (LBIT[j]>1 AND (LEx[j] OR OnSecondLastBarOfDelistedSecurity[j]))
{
Sell[j] = True;
SellPrice[j] = Open[j];
PriceAtBuy = 0;
}
}else
if (PriceAtBuy > 0)
{
LBIT[j] = LBIT[j-1]+1;if (LBIT[j]>1 AND (LEx[j] OR OnSecondLastBarOfDelistedSecurity[j]))
{
Sell[j] = True;
SellPrice[j] = Open[j];
PriceAtBuy = 0;
}if (LBIT[j] > LEx1[j])
{
Sell[j] = True;
SellPrice[j] = Open[j];
PriceAtBuy = 0;
}
}
}
//———————————————————————————
LEsetup = IIf(LBIT == 0 OR Sell == 1,BuySetup,0);
LExSetup2 = IIf(LBIT >= 1 AND Sell == 0,LExSetup OR (LBIT == LEx1),0);
//———————————————————————————
Short = Cover = False;
//=====================================================================================May 24, 2016 at 7:43 am #104069SaidBitarMemberDarryl Vink wrote:Darryl Vink wrote:Realised that the results I posted last time where from using 10% equity on each position. Here are the more realistic results:using the following code as setup and entry (gapFilter removed ):
Code:// moving averages
longMALength = Param(“Long MA length”,100,50,200,10);
shortMALength = Param(“Short MA length”,5,50,200,10);
longMA = MA(C, longMALength);
shortMA = MA(C, shortMALength);// ATR and ADX setup
atrMultiplier = Param(“ATR multiplier”,1,0.5,2,0.1);
atrBuyLength = Param(“Buylimit ATR length”,10,5,30,1);
adxPeriod = Param(“ADX period”,8,8,30,2);
adxMin = Param(“ADX Min”, 30,20,60,5);// setup for bollinger bands
bolliPeriod = Param(“Bollinger Period”,5,5,100,5);
topBandStd = Param(“B-Band top”,2,1.0,3,0.2);
botBandStd = Param(“B-Band bot”,1,1.0,3,0.2);
bolliTop = BBandTop(C,bolliPeriod,topBandStd);
bolliBot = BBandBot(C,bolliPeriod,botBandStd);
bolliWidthMin = Param(“Bollinger width min”,3,1,7,1);
bolliWidth = ((bolliTop – bolliBot)/bolliBot)*100;//=========================================================
// Entry and Exit signals
//=========================================================
cond1 = C > longMA;
cond2 = L < bolliBot; cond3 = bolliWidth > bolliWidthMin;
cond4 = optionalFilter AND HDBFilter AND volFilter;
cond5 = ADX(adxPeriod) > adxMin;
buySetup = cond1 AND cond2 AND cond3 AND cond4 AND cond5;
buyLimit = C – atrMultiplier*ATR(atrBuyLength);And now the same with some leverage.
20 positions @ 10% of equity:Also removing the bb width condition provide a bit better results
What I am trying is to reduce the number of rulesMay 24, 2016 at 11:15 am #104070ChrisViridesMemberThanks 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.
May 24, 2016 at 3:58 pm #104071SaidBitarMemberRegarding the first system I think the results are OK, but not so encouraging to be tradable.
I have an idea I am not sure if it is profitable or not, I think it should be. So it is clear that i did not test it yet.
the idea is as follows:
[ol]
[li]The stock makes X days high (50 days)[/li]
[li]then retraces to the MA (20 days)[/li]
[li]Buy on Stop order a tick above the High of the day it crosses the MA[/li]
[li]Sell on the X days High (so the value should be saved in a variable in order not to change)[/li]
[li]Trailing stop should be 5% bellow the low of the entry day[/li]
[li]the distance between the entry and the exit (X days High ) should be more than 10% (to keep W/L ratio around 2)[/li][/ol]
May 24, 2016 at 4:09 pm #104072SaidBitarMemberSaid Bitar wrote:Regarding the first system I think the results are OK, but not so encouraging to be tradable.
I have an idea I am not sure if it is profitable or not, I think it should be. So it is clear that i did not test it yet.
the idea is as follows:
[ol]
[li]The stock makes X days high (50 days)[/li]
[li]then retraces to the MA (20 days)[/li]
[li]Buy on Stop order a tick above the High of the day it crosses the MA[/li]
[li]Sell on the X days High (so the value should be saved in a variable in order not to change)[/li]
[li]Trailing stop should be 5% bellow the low of the entry day[/li]
[li]the distance between the entry and the exit (X days High ) should be more than 10% (to keep W/L ratio around 2)[/li][/ol]
maybe another option will be to have a condition for the number of Bars between the day it made the new high and the retrace to the MA, i will test with 50 and start decreasing from there. the aim is to be sure that the stock is having healthy entrancement and not Down trend.
May 24, 2016 at 4:17 pm #104073SaidBitarMemberhere is an example to make things clear, still the rules that i mentioned are not implemented.
but to give idea how it will be looking
May 24, 2016 at 5:23 pm #104074JulianCohenParticipantSo you would set Entry < HHV - (HHV * 0.1) as a condition? Just checking...
May 24, 2016 at 5:42 pm #104075SaidBitarMemberThe entry should be the H + 0.01 of the signal bar
and the( HV (highest value) – EntryPrice (H+0.01) ) / EntryPrice (H+0.01) > 0.1May 24, 2016 at 5:45 pm #104076SaidBitarMemberor it can be like this:
BuyStop = H + 0.01
TStop = L * 0.95SellTarget = HV
WL = (SellTarget – BuyStop ) / (BuyStop – TStop ) >= 2
May 24, 2016 at 6:00 pm #104077JulianCohenParticipantOK…I would think about using TStop = H * 0.95 as the setup bar could be a long one and the low would be far away. This way the TStop is keeping close to the entry level and you can then decide if you want 5% or 10% from the same point. Does that make sense?
May 24, 2016 at 6:09 pm #104078JulianCohenParticipantOh wait a minute….I see what you have done…no need to correct me ha ha
May 25, 2016 at 4:55 pm #104079SaidBitarMemberFrom initial testing i do not think this system is profitable
maybe i need to optimize some values
-
AuthorPosts
- You must be logged in to reply to this topic.