Home › Forums › Trading System Mentor Course Community › Trading System Brainstorming › Group Collaboration System Ideas
- This topic is empty.
-
AuthorPosts
-
May 17, 2016 at 6:40 pm #104010SaidBitarMember
when it is bad day nothing i can do to fix it
I checked the code many times
i could not find anythingstill my results are far from what everyone is posting, i have half the number of trades
here is my code maybe there is mistake somewhere and i did not see
Code:SetBarsRequired(sbrAll,0);_SECTION_BEGIN(“Monte Carlo”);
//=================================================================================================
//MCS Monte Carlo Part 1 of 2
//=================================================================================================
RUNS = Param(“Number of Runs:”,1000,1,25000,1);
Run = Optimize(“MC Run”,1,1,RUNS,1);
MCP = Param(“Probability of Ignoring any Entry Signal %”, 25, 0,100,1);
run = Optimize(“RUNS”,1,1,1,1);
//=================================================================================================
_SECTION_END();_SECTION_BEGIN(“Historical Database Testing”);
//=================================================================================================
//Historical database 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″,0);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(“$XSO”);
if(ASXList == “9: ASX Emerging Companies”) HistDB = IsIndexConstituent(“$XEC”);
if(ASXList == “10: Excluding ASX 300”) HistDB = IsIndexConstituent(“$XKO”)==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”,1);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 == “13: Russell MidCap”) USHistDB = IsIndexConstituent(“$RMC”);//————————————————————————————————-
HDBFilter = HistDB AND USHistDB;//=================================================================================================
_SECTION_END();_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 (“Index Filter”);
//=================================================================================================
//Index Filter
//=================================================================================================
IndexSwitch = ParamToggle(“Index Filter”,”On|Off”,1);
“”;
“Foreign Ticker Symbol: ” ;
IndexCode = ParamStr(“Index Code”,”$SPX”);
Index = Foreign(IndexCode,”C”);
IndMA = Param(“Index Filter MA Period”,50,1,1000,1);
IndexFilter = Index > MA(Index,IndMA) ;
IndexFilterDown = Index <= MA(Index,IndMA); IndexFilt = IIf(IndexSwitch,1,IndexFilter); //================================================================================================= _SECTION_END(); _SECTION_BEGIN ("Optional Price & Volume Filters"); //================================================================================= //Optional Price & Volume Filters //================================================================================= PF = ParamField("Price Field",6); PriceTog = ParamToggle("Price Filter","Off|On",1); MinSP = Param("Minimum Share Price - $",1,0.00,1000,0.01); MaxSP = Param("Maximum Share Price - $",100,0.00,1000,0.01); MinMaxSP = PF >= MinSP AND PF <= MaxSP; PriceFilt = IIf(PriceTog,MinMaxSP,1); //--------------------------------------------------------------------------------- TOTog = ParamToggle("Turnover Filter","Off|On",0); Turnover = PF*V; MinTO = Param("Minimum Turnover - $",500000,0,10000000,1000); TOMA = Param("Turnover MA",5,1,200,1); AveTO = MA(Turnover,TOMA); TOFilter = AveTO > MinTO AND Turnover > MinTO;
TOFilt = IIf(TOTog,TOFilter,1);
//———————————————————————————
VolTog = ParamToggle(“Volume Filter”,”Off|On”,0);
MinVol = Param(“Minimum Volume”,500000,0,10000000,1000);
VolFilter = Volume > MinVol;
VolFilt = IIf(VolTog,VolFilter,1);
//———————————————————————————
AveVolTog = ParamToggle(“Average Volume Filter”,”Off|On”,1);
MinAveVol = Param(“Minimum Average Volume”,500000,0,10000000,1000);
AVPer = Param(“Volume EMA”,7,1,200,1);
AveVol = EMA(V,AVPer) > MinAveVol;
AveVolFilt = IIf(AveVolTog,AveVol,1);
//———————————————————————————
OptFilt = PriceFilt AND TOFilt AND VolFilt AND AveVolFilt;//=================================================================================
_SECTION_END();_SECTION_BEGIN (“Parameters”);
//=================================================================================
//Parameters
//=================================================================================
LongMAP = Param(“Long MA”,100,1,1000,1);
ShortMAP = Param(“Short MA”,5,1,1000,1);
LongMA = MA(C,LongMAP);
ShortMA = MA(C,ShortMAP);
//———————————————————————————
Cond1 = C > LongMA;
Cond2 = C < ShortMA; BBPeriod = Param("BB MA Period",5,5,100,5); BBStdev = Param("BB Std dev value", 1.5, 0.5, 2, 0.5); BBBot = BBandBot(C,BBPeriod,BBStdev); BBTop = BBandTop(C,BBPeriod,BBStdev); BBWidth = (BBTop - BBBot)/ BBBot *100; Cond3 = BBWidth > 5;
Cond4 = IndexFilter AND OptFilt AND HDBFilter ;
Cond5 = C < BBBot; //================================================================================= //Entry & Exit //================================================================================= NTPeriod = 30; DN = DateNum(); LastDate = Status("rangetodate"); NT = LastDate - LastValue(DN) >= NTPeriod AND DN == LastValue(DN);
LastBarExit = BarIndex() == LastValue(BarIndex());
NTEx = IIf(NT,LastBarExit,0);
//———————————————————————————LESetUp = Cond1 AND Cond2 AND Cond3 AND Cond4 AND Cond5;
ATRPer = Param(“Limit Price: ATR Periods”,10,1,100,0.01);
ATRM = Param(“Limit Price: ATR Multiple”,0.5,0,100,0.01);
ATRVal = ATR(ATRPer)* ATRM;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;LE = Ref(LESetUp,-1) AND L <= Ref(BuyLim,-1) AND NT==0; //--------------------------------------------------------------------------------- //MCS code if (MCP) LE = LE && Random()*100 >= MCP;
//———————————————————————————
LEPrice = Min(Ref(BuyLim,-1),Open);//———————————————————————————
//———————————————————————————
MAExPeriod = Param(“MA Exit Period”, 5, 2, 200,1);
LExSetUp = Close > MA(C, MAExPeriod);
LEx = Ref(LExSetUp,-1);//=================================================================================
//Looping
//=================================================================================
Buy = 0;
Sell = 0;
LPriceAtBuy = 0;
LBIT = 0;//=================================================================================
for (j = 1; j < BarCount; j++) { if (LPriceAtBuy==0 AND LE[j]) { Buy[j] = True; LPriceAtBuy = LEPrice[j]; BuyPrice[j] = LEPrice[j]; LBIT[j] = 1; if (LBIT[j]>1 AND LEx[j])
{
Sell[j] = True;
SellPrice[j] = Open[j];
LPriceAtBuy = 0;
}
if (LBIT[j] >= 1 AND NTEx[j])
{
Sell[j] = True;
SellPrice[j] = C[j];
LPriceAtBuy = 0;
}
}
else
if (LPriceAtBuy > 0)
{
LBIT[j] = LBIT[j-1]+1;if (LBIT[j]>1 AND LEx[j])
{
Sell[j] = True;
SellPrice[j] =Open[j];
LPriceAtBuy = 0;
}
if (LBIT[j] >= 1 AND NTEx[j])
{
Sell[j] = True;
SellPrice[j] = C[j];
LPriceAtBuy = 0;
}
}}
May 17, 2016 at 6:56 pm #104011StephaneFimaMemberSaid,
I guess that this portion of code
NTPeriod = 30;
DN = DateNum();
LastDate = Status(“rangetodate”);
NT = LastDate – LastValue(DN) >= NTPeriod AND DN == LastValue(DN);
LastBarExit = BarIndex() == LastValue(BarIndex());
NTEx = IIf(NT,LastBarExit,0);is related to adressing the historical constituents, right?
Just one idea if this is the case, have you tried Craig’s code, i.e.OnSecondLastBarOfDelistedSecurity = BarIndex() == (LastValue(BarIndex())-1) AND !IsNull(GetFnData(“DelistingDate”));
OnLastTwoBarsOfDelistedSecurity = BarIndex() >= (LastValue(BarIndex())-1) AND !IsNull(GetFnData(“DelistingDate”));and LE = Ref (LESetUp,-1) AND L<=Ref (BuyLim,-1) AND NOT OnLastTwoBarsOfDelistedSecurity; Normally it should give yout the same results but mlaybe worth testing
May 17, 2016 at 7:07 pm #104013SaidBitarMemberIt is to close the delisted stocks
I tried with the other code that you suggested still same result.
May 17, 2016 at 7:22 pm #104014StephaneFimaMemberI think I’ve found it.
In my code, I do not have your second condition (Cond2 = C < ShortMA;) as an entry condition.
This probably explains why you have less tradesMay 17, 2016 at 7:40 pm #104015SaidBitarMemberthis condition is not important because all the time it is true since the close is under the lower BB , it is over there because i was testing one thing and i did not remove it
May 17, 2016 at 7:46 pm #104016SaidBitarMemberI was comparing the results of exploration between my code and the code that Maurice posted, i found that he has some stocks that are more than 100$ even though his code is specifying that it should be between 5 and 100 .
for example CHTR and TSLA
May 17, 2016 at 8:10 pm #104012AnonymousInactiveSaid Bitar wrote:when it is bad day nothing i can do to fix itI checked the code many times
i could not find anythingHi Said, your original rules you posted had no index filter but… you have it activated in Cond4. Is that the problem?
May 17, 2016 at 8:17 pm #104018AnonymousInactiveMy results from single run:
position score: default
dates: 01/01/2000 to 01/01/2016
20 positions @ 5% of equityMay 17, 2016 at 8:31 pm #104019SaidBitarMemberit was condition 4 i found it after checking trade by trade
thanks also to Darryl
now i can sleep
May 17, 2016 at 8:34 pm #104020SaidBitarMemberfeels good
stupid mistakes all the time
anyhow it is good that we are all aligned
May 18, 2016 at 12:44 am #104017LeeDanelloParticipantSaid Bitar wrote:I was comparing the results of exploration between my code and the code that Maurice posted, i found that he has some stocks that are more than 100$ even though his code is specifying that it should be between 5 and 100 .for example CHTR and TSLA
Thanks I picked that up and changed the filter setting in Cond3 from VolFilt to OptFilt
So as a check, I should have looked at the Open Int field in the quote editor to check that the unadjusted price criteria was being met.
May 18, 2016 at 1:54 am #103979AnonymousInactiveI better catch up quick I’m liking what I’m seeing. well done guys n gals
May 18, 2016 at 2:13 am #103728LeeDanelloParticipantI definitely can’t keep up with Said. Way to quick for me. I’m on the slow burn.
May 18, 2016 at 5:45 am #103729ChrisViridesMemberResults from Single Run Backtest:
Position Score: Random
1/1/2000 – 1/1/2016
20 Positions @ 5% eachMay 18, 2016 at 7:10 am #104023JulianCohenParticipantJust a quick question. When do you use OpenInt as opposed to Close?
-
AuthorPosts
- You must be logged in to reply to this topic.