Home › Forums › Trading System Mentor Course Community › Trading System Brainstorming › Short Swing Trading
- This topic is empty.
-
AuthorPosts
-
February 21, 2016 at 4:42 pm #101438SaidBitarMember
Hi All
this strategy is based on the book Short Swing Trading that was deposited by Nick in this forum. So few weeks ago i coded it exactly as it is.
I will post parts/all the code so we can verify it and work to improve it.here is a summary for those that did not read/finish the book yet
//General Information and Source
Source : Short Swing Trading book
System Type : Swing Trading
System Duration : Daily
//
//Index Filter50 Days MA of the $SPX
//
//Entry+DI Crossing or touching -DI
Enter if the price passed the last significant high
//
//ExitInitial Stop:
just bellow the previous significant low
Trailing Stop:
just bellow the low of the new significant bar
if the ROC(C,1) > 5% the trailing stop is 50% of the bar
//
//Position size5% Risk on any one trade
//
*/February 21, 2016 at 4:54 pm #102861SaidBitarMemberhere are the results of single run
Universe Russell 3000
Price filter from 10 – 100$
1/1/1995 – 2/17/2016February 21, 2016 at 4:55 pm #102863SaidBitarMemberFebruary 21, 2016 at 4:57 pm #102864SaidBitarMemberHere how a trade looks like
February 21, 2016 at 5:09 pm #102865SaidBitarMemberEntry condition 1
the stock should be above the 50 days MACode://Stock MA
PF1 = ParamField(“Channel Top Price Field”,3);
MAD = Param(“Share MA Duration”, 50,1,300,1);
MaVal = MA(PF1,MAD);Entry condition 2
+DI Crossing or touching -DI
Enter if the price passed the last significant high
duration of Directional movement is 8 periodsCode://Directional Movement
DIPeriod = Param(“DI Periods”,8,1,300,1);
PlusDI = PDI(DIPeriod);
MinusDI = MDI(DIPeriod);Buy entry
Enter if the price passed the last significant high
inside bars are not countedCode:StopBuyPrice = IIf(H < Ref(H,-1) AND L > Ref(L,-1),IIf(Ref(H,-1) < Ref(H,-2) AND Ref(L,-1) > Ref(L,-2),Ref(H,-2) + 0.01 ,Ref(H,-2) + 0.01),H + 0.01);here i am checking to remove the inside bars for the last 3 days and the stop buy price is 1 cent above the high
in order to check more than 3 days (which is more as per the book) then a loop should be created but for the moment i will leave it like thisEntry Conditions
Code://Conditions
Cond1 = C > MaVal;
Cond2 = Cross(PlusDI,MinusDI); // test with touching
Cond3 = HDBFilter AND UniverseFilter AND IndexFilt AND OptFilt;note that the index filter is 200 days MA of the $SPX
the reason that i moved touching condition is that the universe is huge enough maybe later it can be tested with touching conditionFebruary 21, 2016 at 5:15 pm #102866SaidBitarMemberInitial Stop:
just bellow the previous significant low
just bellow is 0.5% of the price bellow the lowCode:InitialStop = IIf(H < Ref(H,-1) AND L > Ref(L,-1),IIf(Ref(H,-1) < Ref(H,-2) AND Ref(L,-1) > Ref(L,-2),Ref(L,-2) * 0.995,Ref(L,-2) * 0.995),L *0.995);
InitialRisk = C – InitialStop;again here loop can be used to determine the exact low but i think the above condition is capable of catching it.
Buy Set up
Code:BuySetUp = Cond1 AND Cond2 AND Cond3;
LE = Ref(BuySetUp,-1) AND NT==0 AND H >= Ref(StopBuyPrice,-1) ;NT is just to check if the stock is going to be delisted
Trailing Stop:
just bellow the low of the new significant bar
if the ROC(C,1) > 5% the trailing stop is 50% of the barCode://=================================================================================================
//Looping
//=================================================================================================
Buy = 0;
Sell = 0;
PriceAtBuy = 0;
LBIT = 0;
LStop = Null;
ROCD = Ref(ROC(C,1),-1);//————————————————————————————————-
for( j = 3;j < BarCount;j++) { if(PriceAtBuy == 0 AND LE[j]) { Buy[j] = True; BuyPrice[j] = Max(O[j],StopBuyPrice[j-1]); PriceAtBuy = BuyPrice[j]; LBIT[j] = 1; LStop[j] = InitialStop[j-1]; LStop[j-1] = InitialStop[j-1]; if(LBIT[j] > 1 AND C[j-1] <= LStop[j-1]) { Sell[j] = True; SellPrice[j] = Open[j]; PriceAtBuy = 0; } } if(PriceAtBuy > 0)
{
LBIT[j] = LBIT[j-1] + 1;
if(LBIT[j] > 1)
{
if(H[j-1] < H[j-2] AND L[j-1] > L[j-2])
{
if(H[j-2] < H[j-3] AND L[j-2] > L[j-3])
{
LStop[j] = Max(LStop[j-1],L[j-3] * 0.995);
}
else
{
LStop[j] = Max(LStop[j-1],L[j-2] * 0.995);
}
}
else
if(ROCD[j] >= 5)
{
LStop[j] = Max(LStop[j-1],(H[j-1]-L[j-1])/2 + L[j-1]);
}
else
{
LStop[j] = Max(LStop[j-1],L[j-1] * 0.995);
}
}if(LBIT[j] > 1 AND (C[j-1] <= LStop[j-1] OR NTEx[j])) { Sell[j] = True; SellPrice[j] = Open[j]; PriceAtBuy = 0; } } } //-------------------------------------------------------------------------------------------------
February 21, 2016 at 5:20 pm #102867SaidBitarMemberSo technically that’s all, everything else i.e. plotting and exploring and filters are as per the course.
February 21, 2016 at 8:46 pm #102862Nick RadgeKeymasterNice work. Thanks Said.
A low Profit Factor is reason to investigate the system a little deeper. A low profit factor is easier to cope with when you have a high trade frequency, but less so when you have a low trade frequency.
-
AuthorPosts
- You must be logged in to reply to this topic.