Good Luck
Offtopic: Is it true that if i am ages under 21 years i can start an IB account with just 3,000 USD? This is good news!
Do they enforce the 100 trade rule?
Where did you find this information?
Thanks!
_SECTION_BEGIN("VSA");
/*Variables*/
/***********/
Cap = SetOption("InitialEquity", Param("What is your starting capital?", 7500, 0, 1000000)); /*Your starting capital*/
percap = Param("What is the largest size of each trade, in terms of % of equity?", Optimize("% of equity",25, 1,100,5), 1, 100, 1); /*The largest possible size of each trade in terms of % equity*/
risk= Param("What % of your capital are you willing to risk per trade?", 1, 0, 100); /*The % of capital that is going to be risked per trade*/
W= Param("Number of bars to compare lowest close (for Covering)", 5, 0, 100); /*The number of previous bars today's close will be compared to*/
X= Param("Number of bars to compare highest close (for Selling)", 5, 0, 100); /*The number of previous bars today's close will be compared to*/
Y= Param("Trailing stop %", Optimize("Trailing stop %",3,0.1,10,0.1),0.1,10,0.1); /*The percentage to be used for the trailing stop. Can be optimized.*/
Z= Param("Number of bars to compare size of spread", 15, 0, 100); /*The number of previous bars today's spread will be compared to*/
spread= H-L; /*Size of the spread*/
mid= L + spread/2; /*The midpoint of a bar*/
avol= MA(Volume,10); /*Formula for Average Volume*/
sl_short=1+Y/100; /*Stop loss level for going Short*/
sl_long=1-Y/100; /*Stop loss level for going Long*/
/*Going Long*/
/************/
SetTradeDelays(1,1,1,1);
/*Buy Condition: Three consecutive up-thrust days with successively increasing volume*/
Buy = Ref(C,-2)<Ref(C,-1) AND Ref(C,-1)<C AND Ref(C,-2)<C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;
BuyPrice = Open;
/*Sell Condition #1: Three days where the close is sideways (+/- 5% of each other) and volume is successively decling but larger than average for the first two days*/
/*Sell = (Ref(C,-2)<1.025*Ref(C,-1) AND Ref(C,-2)>0.975*Ref(C,-1)) AND (Ref(C,-2)<1.025*C AND Ref(C,-2)>0.975*C) AND (Ref(C,-1)<1.025*C AND Ref(C,-1)>0.975*C);*/
/*Sell Condition #2: Sell on the bar with the smallest spread for the past 15 days, above average volume and a close towards the high with the bar in an uptrend.*/
Sell = spread<=LLV(spread,Z) AND V>avol AND C>mid AND C>=HHV(C,X);
SellPrice = Open;
/*Going Short*/
/*************/
/*Short Condition: Three consecutive down-thrust days with successively increasing volume*/
Short = Ref(C,-2)>Ref(C,-1) AND Ref(C,-1)>C AND Ref(C,-2)>C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;
ShortPrice = Open;
/*Cover Condition: Cover on bar with lowest close for X period, above average volume, small spread and with a close towards the low*/
Cover = spread<=LLV(spread, Z) AND V>avol AND C<mid AND C<=LLV(C,X);
CoverPrice = Open;
/*Applying a trailing stop*/
/*****************************************/
SetOption("AllowSameBarExit", 1);
SetOption("ActivateStopsImmediately",1);
trailARRAY_short = Null; //Holds the different prices that the trailing stop has been at (SHORT)
trailstop_short = 0; //Trailing stop price (SHORT)
//This loop does the following tasks:
// 1. Checks to see if we're shorting on the particular day, otherwise, removes the short signal.
// a. If a position is entered, the entry point is the Open of the NEXT DAY.
// 2. Applies the trailing stop as a percentage of the High.
// 3. Checks to see if the trailing stop has been broken by the High. If it has, the position is Covered and the trailing stop is reset.
// 4. If the High hasn't penetrated the stop, then the trailing stop moves lower.
for( i = 1; i < BarCount; i++ )
{
if( trailstop_short == 0 AND Short[ i ] ) //if there is a buy signal with no trailing stop moving under it, then buy on the next day's open
{
SetTradeDelays(1,1,1,1);
ShortPrice = Open;
trailstop_short = High[ i ] * sl_short;
}
else Short[ i ] = 0; //remove excess short signals
if( trailstop_short > 0 AND High[ i ] > trailstop_short ) //if the trailing stop is triggered, exit position immediately (intraday)
{
Cover[ i ] = 1;
SetTradeDelays(1,1,1,0);
CoverPrice[ i ] = trailstop_short;
trailstop_short = 0;
}
if( trailstop_short > 0 AND High[ i ] < trailstop_short ) //if the trailing stop isn't triggered, move it closer
{
trailstop_short = Min(High[ i ] * sl_short, trailstop_short);
trailARRAY_short[ i ] = trailstop_short;
}
}
trailARRAY_long = Null; //An array that holds the different prices that the trailing stop has been at (LONG)
trailstop_long = 0; //Trailing stop price (LONG)
//This loop does the following tasks:
// 1. Checks to see if we're buying on the particular day, otherwise, removes the buy signal.
// a. If a position is entered, the entry point is the Open of the NEXT DAY.
// 2. Applies the trailing stop as a percentage of the Low.
// 3. Checks to see if the trailing stop has been broken by the Low. If it has, the position is Sold and the trailing stop is reset.
// 4. If the Low hasn't penetrated the stop, then the trailing stop moves higher.
for( i = 1; i < BarCount; i++ )
{
if( trailstop_long == 0 AND Buy[ i ]) //if there is a buy signal with no trailing stop moving under it, then buy on the next day's open
{
SetTradeDelays(1,1,1,1);
BuyPrice = Open;
trailstop_long = Low[ i ] * sl_long;
}
else Buy[ i ] = 0; //remove excess buy signals
if( trailstop_long > 0 AND Low [ i ] < trailstop_long ) //if the trailing stop is triggered, exit position immediately (intraday)
{
Sell[ i ] = 1;
SetTradeDelays(1,0,1,1);
SellPrice[ i ] = trailstop_long;
trailstop_long = 0;
}
if (trailstop_long >0 AND Low[ i ] > trailstop_long ) //if the trailing stop isn't triggered, move it closer
{
trailstop_long = Max(Low[ i ] * sl_long, trailstop_long);
trailARRAY_long[ i ] = trailstop_long;
}
}
//This sub-section plots the price and the trailing stops.
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
Plot( trailARRAY_short,"SHORT - trailing", colorIndigo, styleThick );
Plot( trailARRAY_long, "LONG - trailing", colorBlue, styleThick);
/*Fixed Fractional Position Sizing*/
/**********************************/
SetCustomBacktestProc(""); //tells amibroker that we're running our own custom backtest procedure
if (Status("action") == actionPortfolio) //runs the code in the second part of the backtest procedure
{
bo = GetBacktesterObject();
bo.PreProcess();
for (i = 0; i<BarCount; i++) //cycles through all the bars
{
for (sig = bo.getfirstsignal(i); sig; sig = bo.getnextsignal(i)) //cycles through all the signals for the current bar
{
if (sig.IsEntry()) //if the bar involves an entry... this is used to catch all short entries. A nested if-statement is used to catch long entries.
{
psize=sig.PosSize;
sp = Foreign(sig.Symbol, "H"); //imports the High array for the current symbol
spi = sp[i] * sl_short; //uses the i-th High value to calculate the trailstop value, just like trailstop_short
bp = Foreign(sig.Symbol, "O"); //imports the Open array for the current symbol
bpi = bp[i]; //sets the i-th Open value
e=bo.Equity(); //the current equity of the portfolio
Check = (percap/100)*e; //converts the maximum % of equity per trade into maximum $ per trade
r=(risk/100)*e; //maximum risk per trade
psize=(r*bpi)/abs(bpi-spi); //calculates the fixed fractional position size for each short entry
if (sig.IsLong()) //if the bar involves a long entry...
{
sp = Foreign(sig.Symbol, "L"); //imports the Low array for the current symbol
spi = sp[i] * sl_long; //uses the i-th Low value to calculate the trailstop value, just like trailstop_long
psize=(r*bpi)/abs(bpi-spi); //sets the new position size, according to the new trailstop (ONLY FOR LONG TRADES)
}
if (psize>Check) //checks if the position size calculated is greater than the maximum $ per trade. If so, position becomes the max possible $ per trade
{
psize=Check;
}
sig.PosSize=psize;
}
}
bo.ProcessTradeSignals(i);
}
bo.PostProcess();
}
Last time I traded it (maybe 2 years ago) it was a spec
Good that its working out for you.
Playing devils advocate here...
In your back testing, I hope you have you taken the following into account -
1. commission and rates?
2. stocks that are (effectively) delisted. (I literally copied and pasted your script, and BNB came back as a search result - does that matter?)
Item 2 is easy to overcome... just mod your watch list.
Something which looks good may not be so if you are paying $15, $20 or $30 (ignoring IB) each time that you buy or sell.
Tim
Good work saiter.
Are you sure BLR is top200 though?
Last time I traded it (maybe 2 years ago) it was a spec.
My comment is that your shorting system has some potential but your long method needs some work.
Or is it shorting in a down trend has potential and going long in an uptrend is hard work??
Saiter, what have you concluded so far from your results?
You mean long in a down trend?
Given his parameters no doubt!
Hi saiter, have you considered lowering youre timeframes a bit to account for market volatility and generate more trade signals?
3 days of rising volume and the move might already be gone by the time your system generates a signal.
Saiter, have you tried the system but with ommitting the volume data?
ie. only consider price action.
What are you observations?
Well it looks like my trading plan/system isn't going to work.
Unfortunately, as I'm under the age of 21, I'm restricted to a cash account at Interactive Brokers, meaning that I cannot short any stocks. Furthermore, I'm unable to trade FOREX as I can't switch to a margin account (underage).
Does anyone know of any other brokers that offer both FOREX and Australian stocks for a low comission?
Thanks.
You would find it hard to short with IB anyway. They haven't had much on their list recently.
Looks like you need a bucket shop. They are always willing to let you trade.
The only one I know of is commsec and that'd cost $20+$40 for a round trip to short. The other option is belldirect with a $30 round trip for going long ONLY. I can't go long atm and come out positive.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?