- Joined
- 2 August 2016
- Posts
- 897
- Reactions
- 1,492
@martyjames maybe, but maybe not if you have a longer holding period like in a classic trend following system.@martyjames I don't trade anything other than the All ordinaries as a whole. Picking winners as you suggested would be difficult as sometimes they go out of favor as quickly as they come in.
Skate.
Back test period: 01/01/2022 to 18/08/2022, CAR was -23.44% and Max. system % drawdown -18.52%. Actual traded return for same period was CAR -18% (Filter version, drawdown performed no better).
I can't comment on its effectiveness, but here is how you code it:Hi Skate and system traders
Apologies if this is bit off topic. In system tests using Norgate data has anyone had any success to their systems by adding the stocks' sector strength:
Buy= (my system buy rules) + (and the sector of the stock (GICS classification, real estate, technology etc etc) has ROC(c,10)>x, or above its 200 ema etc etc)
If so, how do you code it?
Thanks
Marty
Hey @Sid23, yeah correct.@Cam019, is your backtest from "System Building and Idea Testing" thread?
I did it in another way but did not manage to find a great edge due to the fact norgate data has a quite vague and wide sector definition.I can't comment on its effectiveness, but here is how you code it:
I get that not many people here may be interested in small caps, but...I did it in another way but did not manage to find a great edge due to the fact norgate data has a quite vague and wide sector definition.
Interesting, obviously was talking about asx sector as defined in nortgate data, a dozen or so with not difference between a oil explorer or caltex, and mining can be gold mine, lithium or coal.I get that not many people here may be interested in small caps, but...
If anyone reading this knows Python and web scraping, and can give me some hints on scraping scraping this site:
Sector tracker
The latest information on ASX listed stocks sorted by their given sector. See what announcements the companies have made and price movements.smallcaps.com.au
and the other sectors, please PM me. I have scraped other sites, just having issues with this one. BTW, you need to view frame source, not view page source.
Likewise, if there is a better source for stocks in a given sector, that is updated on a regular basis, please let me know.
Hello Skate
Re your post #7300 and the loop processing time, I've noticed several threads in the Amibroker forum where headmaster Tomasz discourages the use of looping, in favour of much faster and efficient array processing commands.
View attachment 145426
If you look at the afl code in the Marsten Parker video I linked to in an earlier post, you will see that he is using the addtocomposite function to aggregate his market breadth filter counts.
Cheers
Joe.
//==================================
// ConnorsTPS Long Only ===
// AFL By Willzy ===
//==================================
// --- BackTest Settings --- //
// Set Trading Costs
SetOption("CommissionMode", 2); // Fixed $/Trade
SetOption("CommissionAmount",2); // $2 Commission
Spread = 0.0020; // Spread = 0.2% - may need adjustment based on instrument being traded
// Account Finance Settings
SetOption("InterestRate",0);
SetOption("MarginRequirement",10); // Set For CFD type trading
// Trade Logic Settings
SetOption("AllowSameBarExit",False);
SetOption("ActivateStopsImmediately",False);
SetOption("AllowPositionShrinking",True);
SetOption("PriceBoundChecking",True);
SetOption("ReverseSignalForcesExit",False);
SetOption("UsePrevBarEquityForPosSizing",False);
SetOption("DisableRuinStop", True);
// --- Custom Functions --- //
// --- Backtest Method --- //
SetOption( "PortfolioReportMode", 0 );
SetOption("NoDefaultColumns",False);
SetOption("ExtraColumnsLocation", 1 );
// --- Monte Carlo Settings --- //
SetOption( "MCEnable", 2 );
SetOption( "MCRuns", 1000 );
SetOption( "MCStrawBroomLines", 10 );
SetOption( "MCNegativeDrawdown", 0 );
SetOption( "MCChartEquityScale", 0 );
SetOption( "MCUseEquityChanges", 0 );
// --- Position Sizing --- //
nPos = 1;
Leverage = 2;
SetOption( "InitialEquity", 10000 );
SetOption( "MaxOpenPositions", nPos );
// --- Variables and Parameters --- //
// Set maximum number of scale in trades - (original TPS logic - 1 2 3 4 )
maxScaleIn = 4;
// Indicator variables
maPeriod = 200;
rsiPeriod = 2;
rsiEntryLimit = 25;
rsiExitLimit = 70;
// --- Calcualte Indicators --- //
rsiIndicator = RSI(rsiPeriod);
SMA = MA(Close,maPeriod);
// --- Trading System Logic --- //
upTrend = 1;//C>MA(C,maPeriod);
buySignal = upTrend AND rsiIndicator < rsiEntryLimit AND Ref(rsiIndicator,-1) < rsiEntryLimit;
entryLong = buySignal;
entryPrice = Close * (1 + Spread);
sellSignal = rsiIndicator > rsiExitLimit;
exitLong = sellSignal;
exitPrice = Close;
// --- Combine Entries Exits and Stops --- //
Buy = Sell = Short = Cover = 0;
BuyPrice = entryPrice;
SellPrice = exitPrice;
// Initialize Arrays
PositionArray = Null;
LastEntryPriceArray = Null;
nBar = Null;
// Loop over all bars
for( i = 1; i < BarCount; i++ ){
if( EntryLong[i] ) // if entry signal on this bar
{
Position = PositionArray[i] = 1;
lastEntryPrice = lastEntryPriceArray[i] = BuyPrice[i];
for( j = i; j < BarCount; j++ ) // step forward one bar at a time to process the trade
{
// Remove Excess buySignals Until Exit is activated and i == j
nBar[j] = j - i;
if( nBar[j] > 0 )
{
buySignal[j] = 0;
entryLong[j] = 0;
// Check for ScaleIn First
if( upTrend[j] == 1 && Close[j] < lastEntryPrice && Position < maxScaleIn )
{
Position += 1;
PositionArray[j] = Position;
lastEntryPrice = BuyPrice[j];
lastEntryPriceArray[j] = lastEntryPrice;
continue;
}
lastEntryPriceArray[j] = lastEntryPriceArray[j-1];
PositionArray[j] = PositionArray[j-1];
// If Exit Signal Sell on Current Bar
if( ExitLong[j] )
{
lastEntryPrice = lastEntryPriceArray[j] = Null;
Position = 0;
Sell[j] = 1;
i = j;
break;
}
}
// If No Exit Detected
else
if( j == BarCount - 1 )
{
i = j;
break;
}
}
}
}
takeAction = PositionArray > Ref(PositionArray,-1);
Buy = IIf((PositionArray == 1 AND takeAction), 1, IIf(takeAction, sigScaleIn, 0 ));
// Set Position Sizing here because it requries PositionArray input as variable
SetPositionSize( Leverage * PositionArray * 10, spsPercentOfEquity );
// --- Create Figures and Plots --- //
// Plot Price
PlotOHLC( O, H, L, C, "Price", colorBlack, styleBar );
// Plot Indicators
Plot(MA(Close,maPeriod),"SMA",colorBlue,styleLine);
//Plot Entry Exit and Setup Signals
PlotShapes( IIf( Buy == 1, shapeHollowCircle, IIf(Buy > 1 , shapeHollowCircle, shapeNone )), colorGreen, 0, BuyPrice, 0 );
PlotShapes( IIf( Sell == 1, shapeHollowCircle, shapeNone ), colorRed, 0 , SellPrice, 0 );
FirstVisibleBar = Status( "FirstVisibleBar" );
Lastvisiblebar = Status( "LastVisibleBar" );
for( b = Firstvisiblebar; b <= Lastvisiblebar AND b < BarCount; b++ ){
if( Buy[b] ){
PlotText( NumToStr( PositionArray[b], 2 ), b, Low[b]*0.99, colorBlack );
}
//if( Sell[b] ){
// PlotText( "Exit", b, SellPrice[b], colorBlue );
//}
}
// --- END --- //
// --- Create Explore Filter for Error Checking --- //
Filter = 1;
AddColumn( Close, "Close", 1.2, IIf( C<Ref(C,-1), colorRed, colorGreen ) );
AddColumn( buySignal, "BuySig", 1 );
AddColumn( entryLong, "EntryLong", 1 );
AddColumn( PositionSize, "PosSize", 1 );
AddColumn( nBar, "nBar", 1 );
AddColumn( positionArray, "PositionArray", 1 );
AddColumn( lastEntryPriceArray, "lastEntryPriceArray", 1.2 );
AddColumn( sellSignal, "SellSig", 1 );
AddColumn( exitLong, "ExitLong", 1 );
Skate, why can't there be an indicator in a system that identifies when the conditions that the system was designed for are present and turn the system 'on' when they are there and 'off' when they aren't?Trading when the market is clearly unfavourable for a 100% long-only systematic trader is a quick way to go broke.
Skate, why can't there be an indicator in a system that identifies when the conditions that the system was designed for are present and turn the system 'on' when they are there and 'off' when they aren't?
turn the system 'on' when they are and 'off' when they aren't?
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?