Forum Replies Created
-
AuthorPosts
-
SaidBitarMember
The good part i verified the entry and the position sizing for the scale in and they are OK
so after the close is 10% or more higher than the entry price scale in will hit.
50% of the position or 2.5% of equity on buy setup and 50% or 2.5% of equity on scale in
the bad news and still i am not sure it is mistake in the code or it is normal result that when using scale in even though Win Loss ratio increased but CAR and profit decreased.
this is snapshot of the result with scale in
and without scale in
SaidBitarMemberMonday 25/1
was bad day work and after work not much was done
Tuesday 26/1
[ol]
[li]Finished Module 25 (Very good module lots of new ideas and stuff that never imagined exits )[/li]
[li]Verified the Entry and position size for scale in[/li][/ol]
SaidBitarMemberThanks Craig
this makes perfect sense to use the previous close instead of the Open.
may be it will be also good if we add some variable to the minimum volume required since the volume is increasing with years and the minimum volume should not be the same in 1995 as in 2015
still i have to test it but what i have in mind is one thing link this
StartingYear = Param(“Backtest Starting year”,1995,1985,2050,1);
Coef = 2^((year() – StartingYear )/10);
MinVolume = Param(“minimum required volume”, 300000, 1000, 10000000, 100) * Coef;the result should be something like this
Year—Coef—Min Volume
1995—1—300000
1996—1.07—321000
1997—1.15—345000
1998—1.23—369000
1999—1.32—396000
2000—1.41—423000
2001—1.52—456000
2002—1.62—486000
2003—1.74—522000
2004—1.87—561000
2005—2—600000
2006—2.14—642000
2007—2.3—690000
2008—2.46—738000
2009—2.64—792000
2010—2.83—849000
2011—3.03—909000
2012—3.25—975000
2013—3.48—1044000
2014—3.73—1119000
2015—4—1200000
2016—4.29—1287000SaidBitarMemberFinally I found the problem
Buy = sigScaleIn;
should be Buy[j] = sigScaleIn;
looking much better
SaidBitarMemberthere is this option it will help, but the problem it will compare only to the volume of the last bar
the other option I did not test it yet may be it will work
poistionsize = MIN(-5, MA(V,20)*BuyPrice*0.05);
in theory this will compare the 5% of the equity with the 5% of the average volume
SaidBitarMemberTrenRoth wrote:Hi,just out of curiosity what does the flag++; do in the loop?
Flag is the variable that will carry the number of scale ins that are performed
SaidBitarMemberIt is becoming more difficult than what i imagined
here is the code for the loop so in the beginning i am buying then checking if there last close is 10% higher than the price at buy then adding the remaining part of the position.
Code:Buy = 0;
Sell = 0;
PriceAtBuy = 0;
LBIT = 0;
LStop = Null;
ScaleInTarget = Param(“Scale In Target”,10,0,100,1)/100 + 1;
Flag = 0;//———————————————————————————
for (j = 1; j < BarCount; j++) { if(PriceAtBuy == 0 AND LE[j]) { Buy[j] = True ; BuyPrice[j] = O[j]; PriceAtBuy = O[j]; LBIT[j] = 1; LStop[j] = Max(TrailStop[j-1], TrailStop[j]); LSTop[j-1] = TrailStop[j-1]; Flag ++; if(LBIT[j] > 1 AND (Close[j-1] <= LSTop[j-1] OR OnSecondLastBarOfDelistedSecurity[j])) { Sell[j] = True; SellPrice[j] = Open[j]; PriceAtBuy = 0; Flag = 0; } } else if(PriceAtBuy > 0)
{
LBIT[j] = LBIT[j-1] + 1;if(LBIT[j] > 1)
{
LStop[j] = Max(LStop[j-1], TrailStop[j]);
if(((C[j-1]/PriceAtBuy) > ScaleInTarget) AND Flag < 2 AND LBIT[j] > 1)
{
Buy = sigScaleIn;
BuyPrice = O[j];
Flag++;
}
}if(LBIT[j] > 1 AND (Close[j-1] <= LSTop[j-1] OR OnSecondLastBarOfDelistedSecurity[j])) { Sell[j] = True; SellPrice[j] = Open[j]; PriceAtBuy = 0; Flag = 0; } } }
SaidBitarMemberNormally i compare starting with MDD –> MAR –> Risk Reward Ratio –> CAR
so according to this the current system is the winner, even though i feel i can handle more MDD so i will leverage it . So even if CAR and MDD are doubled still looks good.
SaidBitarMemberNow i saw what you are talking about
use this
Code:SetBarsRequired(sbrAll,0);buySetup = Cross(MACD(),0);
longEntry = Ref(buySetup,-1);
trailStop = High * (1 – 0.2);Buy = 0;
Sell = 0;
longStop = Null;
priceAtBuy = 0;
longBIT = 0;
bELevel = Null;for (j=1; j < BarCount; j++) { if(priceAtBuy==0 AND longEntry[j]) { Buy[j] = True; BuyPrice = Open[j]; priceAtBuy = BuyPrice[j]; longStop[j] = Max(trailStop[j-1],trailStop[j]); longStop[j-1] = trailStop[j-1]; bELevel[j] = priceAtBuy[j]; longBIT[j] = 1; if(longBIT[j] > 1 AND Close[j-1] <= longStop[j-1]) { Sell[j] = True; SellPrice[j] = Open[j]; priceAtBuy = 0; } } else if(priceAtBuy > 0)
{
longBIT[j] = longBIT[j-1] + 1;if(longBIT[j] > 1)
{
longStop[j] = Max(longStop[j-1],trailStop[j]);
beLevel[j] = bELevel[j-1];
}if(longBIT[j] > 1 AND Close[j] > (bELevel[j-1]*1.1))
{
longStop[j] = Max(longStop[j],bELevel[j-1]);
}if(longBIT[j] > 1 AND Close[j-1] <= longStop[j-1]) { Sell[j] = True; SellPrice = Open[j]; priceAtBuy = 0; } } } // // plot setup SetChartOptions(0,chartShowArrows|chartShowDates); Plot(Close,"",colorDefault,styleBar); Plot(longStop,"",colorBlue,styleLine); PlotShapes(shapeUpArrow*Buy,colorGreen,0,L,-80); PlotShapes(shapeDownArrow*Sell,colorRed,0,H,-80); PlotShapes(shapehollowUpArrow*buySetup,colorGreen,0,L,-100);
SaidBitarMemberTry this
beLevel[j] = bELevel[j-1];
// i just noticed that you missed [j] for the left part of the equation
SaidBitarMemberjust to clarify the table
first col is the profit of increment of 10%, second is the profit value in $, col 3 new equity value, col 4 IC equity, col 5 RP equity, col 6 how much is risking only 2% of the portfolio, col 7 how much is risking 10% of the portfolio looks like ( the aim is to compare the $ value between 2%, 10% and the mixed solution), col 8 how much is the risk for the solution using 2% of IC and 10% of RP, last col is the % at risk in total (2% with the 10%)can this be coded with AFL ??
what will happen in case of drawdown money is moved from one to another or balancing is only with the increment of the portfolio equity
SaidBitarMemberTo be honest i imagined that it will be easier than this. i was trying to use the scale in feature to enter the trades but since it will inter in steps it was not possible to test with initial 25% of position then 75% of the position.
I think for this idea i need to use the custom backtest from Amibroker to implement it. Meanwhile i played around with the scale in function but with 50% of the position initially and the other 50% after the stock moves 10% from the buy price. the aim is to see if there is any improvements .
here is the snapshot of the strategy with entering the full position note that i removed all the random parts from the strategy so most probably it will be the same trades in all the tests. (file is attached)
but here is the general results
Profit 5195.4% CAR 20.74% MDD -25.89% Winners % 46.59%then i did optimization to see the results on different Scaling targets from 0% up to 15%
also attached is the result
as i was expecting the Win/Loss ratio increased and the Profit more than doubled, CAR increased and MDD decreased
results are pretty nice for 50-50
just to be sure that the code and the results are OK i need to make more tests and may be some manual checking over the weekend.
SaidBitarMemberHi all,
I got interested in trading in 2010 when my coworker told me that he had some shares in gold mining company EGO (Eldorado gold) and they were making lots of money for him. Instead of opening broker account to trade stocks I opened online account for CFDs and I was under capitalized and I was trading gold with no clue about anything just hit buy and sell buttons and mainly X200 leverage. as expected it did not take long before I lost my money. I stayed like this till 2012 I blew out my account three times mainly because did not know anything and I was under capitalized which was good otherwise I will lose all my money.
I decided that trading is not for me.
Mid 2013 I received a tip about NOK (Nokia) that soon they will go huge up, I work in telecom and worked for nokia for over 6 years, the guy that gave me the tip was a big manager so I said he knows what he is talking about but still I did not buy. till one day when the announcement that MSFT bought the mobile business from nokia hit the news and the prices started to fly high. that day I realized that I should have bought before, so I contacted my bank opened account and after few days I put the order to buy Nokia till that time the price was 7.8$ / share so it went up down up down and I was going with it. finally I sold it and it was OK trade, mainly because of the dividend that was paid.NOK experience taught me 2 things first that you can make money trading, second that I do not know how to trade.
I started to read books about trading, I was searching for answers for these questions what to buy, when to buy, how many , and when to sell. every book I read I used to program the idea in it and see the result I did not know about amibroker or any back testing software what I know is excel vba, SQL database visual basic and C# and with these I built my back testing software lots of hours to write and even more to run.
I stayed like this till I came across one video on YouTube for Nick (What Makes a Successful Trader?) then I said to myself this is what I am looking for I saw the video couple of times then I bought the unholy grail after reading it I said to myself now I am on the correct path. so I got amibroker, data and started coding BBO. the results were good I started trading it along the way I found out that I had some mistakes in the code. so I bought the strategy from the Chartist along with second income strategy. based on the BBO I made the WTT strategy and I trade it.
at the moment I trade three strategies one trend following and 2 mean reversion with almost same money allocation between trend following and mean reversion (2:1:1)
this is since mid 2015 and all of us we know how the market was since then till today.my aim from the course is learning the tricks and the mind set that will change an ordinary system to a better system
wow i talked so much :blush:
Said -
AuthorPosts