Creating a trading system from scratch

How many lines of code you are comfortable with


  • Total voters
    61

UberMachine

Well-Known Member
my question is why the 5 trades is it based on past experience or it a random number because backtest shows more sharpe and sortino ratio in 2,3,4 trades..?
Actually, its just to diversify my stakes. I started trading only in NIFTY 50 and made it 10%. So its not some sort of a fixed number.
In case of FO, it could be from 7-10. Again, this diversifies your stakes so that both your profits and losses are spread over.
If you have multiple strategies (say 3 or 4), then 3 of them are enough. Its a number used after trying out; no hard fast rules.
If you diversify among sectors (I do it), then its even better.
Another tip is to pick 2 stocks from 4 or 5 sectors
Do all this after proper backtesting
 

UberMachine

Well-Known Member
For everybody watching this thread, the present method of executing trades via notebook is not recommended.
The right way is to turn them into python scripts, which I would cover soon.
Also, create 2 separate copies of the system, one for live trading and one for backtesting.
We would soon turn our complex code into something more simple so that we coud just present our backtesting rules for the system to perform the rest.
Also, get used to the payoff concept I introduced somewhere in the middle of this thread.

The original system proposed in the post has been now changed so that
  1. We place orders only when the price is below open
  2. We place only STOP LOSS LIMIT orders so that our stock is picked at exactly the price we expect
  3. We exclude open = high cases from the results
  4. Added commission
This would improve our returns and also provide more realistic backtesting results
 

ncube

Well-Known Member
Definitely but presently my system works with zero memory (it just looks back 1 day) and I target intraday returns rather than returns.
I am trying out creating a series of individual recommendtions which when combined would produce better results. Also, working on including more memory into the system (such as trend) but the real problem is setting them up automatically on a daily basis to do the execution.

Another reason this strategy works may be the fact that every possible information is incorporated into the pre open data itsel and it may provide an edge since we make the move early. This system has a doomsday scenario where all stocks open short and end high for around 15-20 days but the chances of it happening are way too low
When previous day data is used to identify the stocks, it will be influenced by the market trend on that day, below is the difference in the returns for last 10 days on NIFTY50. The trend has been predominantly down last 10 days.

Returns shorting the top 5 :
1538663083704.png

Returns shorting the bottom 5 :
1538663134963.png


If we analyze these results it is clear that during downtrend the weaker stocks tend to fall further compared to top 5.
 

VJAY

Well-Known Member
When previous day data is used to identify the stocks, it will be influenced by the market trend on that day, below is the difference in the returns for last 10 days on NIFTY50. The trend has been predominantly down last 10 days.

Returns shorting the top 5 :
View attachment 29137
Returns shorting the bottom 5 :
View attachment 29138

If we analyze these results it is clear that during downtrend the weaker stocks tend to fall further compared to top 5.
Thanks ncube for the results....Yes that what now happening....we shorting strong scrips in bearish market....so its giving some negative results....I think we can use some sort trend find and take trade as per overall trend...means with major market trend
 

pannet1

Well-Known Member
Thanks ncube for the results....Yes that what now happening....we shorting strong scrips in bearish market....so its giving some negative results....I think we can use some sort trend find and take trade as per overall trend...means with major market trend
how to know the market is bearish or bullish.
if this can be defined then we backtest it with these parameters, then we could use this findings for our future trades.
it could be dumb like .. if nifty closed down yesterday, we assume the market is bearish .. and vice versa.
 

VJAY

Well-Known Member
how to know the market is bearish or bullish.
if this can be defined then we backtest it with these parameters, then we could use this findings for our future trades.
it could be dumb like .. if nifty closed down yesterday, we assume the market is bearish .. and vice versa.
Dear pannet,
yes its not easy to get perfectness with any parameters...but as chart readers we can judge it with some chart help...though this strategy some kind negative in only in strong bearish market...not in mild and sideways I think ...
as example I only can tell most bearish situation we use what ncube said other type market just stick with what we have now....though its only view only ...you also can give some your views ...other also ...so we can find a way
for me only marked are is some strong bearishness.....its just simple by chart

1538665057285.png
 
When previous day data is used to identify the stocks, it will be influenced by the market trend on that day, below is the difference in the returns for last 10 days on NIFTY50. The trend has been predominantly down last 10 days.

Returns shorting the top 5 :
View attachment 29137
Returns shorting the bottom 5 :
View attachment 29138

If we analyze these results it is clear that during downtrend the weaker stocks tend to fall further compared to top 5.
But the question is does this strategy work for long stocks???
 

ncube

Well-Known Member
But the question is does this strategy work for long stocks???
No, in my backtest long stocks did not work. Please refer to @UberMachine post

Actually, the exact reverse strategy doesn't work; it results in a net loss in the long run. Got to find a long strategy that's net profitable so that they could be merged.
One of the intuitive reasons may be, selling happens impusively while buying takes time based on trend. So if you have figured out a trend following system that works, then this could be a great combination
 

Similar threads