Creating a trading system from scratch

How many lines of code you are comfortable with


  • Total voters
    61

UberMachine

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.
But not so sure unless we look back for a considerable period of time since we don't know in advance when the reverse would happen.
I have done something on individual stocks by calculating streaks, both winning and losing; there is no statistical significance on the next day irrespective of past winning or losing streak. But its simple; I haven't included any complex trend in it.
 

UberMachine

Well-Known Member
So, we can say whether the market is bullish or bearish but we cannot predict whether the market would be bullish or bearish within a day; I may be biased here.

A few things we could do
  1. Track other indices such as sgxnifty, dow and see whether it has got any correlation
  2. Stop trading when the preopen index is +/- some high percentage (possibly z-score)
  3. Advise from experienced traders who would ask to stop
And you can also design a system that could predict with reasonable accuracy that whether the markets would be bullish or bearish. For me to believe that system, it must have 2/3 accuracy across atleast 20 indices. I read somewhere that there is a Bayesian method that is successful but that would make things too complex.

And for information, I lost on the first day but made profit in the last 2 days with my new improved strategy. But need to see how it works when the market turns bullish.
 
So, we can say whether the market is bullish or bearish but we cannot predict whether the market would be bullish or bearish within a day; I may be biased here.

A few things we could do
  1. Track other indices such as sgxnifty, dow and see whether it has got any correlation
  2. Stop trading when the preopen index is +/- some high percentage (possibly z-score)
  3. Advise from experienced traders who would ask to stop
And you can also design a system that could predict with reasonable accuracy that whether the markets would be bullish or bearish. For me to believe that system, it must have 2/3 accuracy across atleast 20 indices. I read somewhere that there is a Bayesian method that is successful but that would make things too complex.

And for information, I lost on the first day but made profit in the last 2 days with my new improved strategy. But need to see how it works when the market turns bullish.
Which improved strategy???
 
Master is there a way to test
Code:
import random
x=(random.randint(1,10)*5)
y=x+5
just to backtest how system fares against little random stock selection for orders as in
iloc[x:y]
to understand risk management is priority or strategy

//update
added to backtester seems to work
Code:
import random
for name, group in grouped:

    x=(random.randint(0,45))

    y=x+5


    temp = group.sort_values(by='ret', ascending=False).iloc[x:y]

    collect.append(temp)

orders = pd.concat(collect)
 
Last edited:

pannet1

Well-Known Member
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

View attachment 29140
i am going by ncube's view only .... i think you got me wrong ...what i meant to say is

1) for systematic trading we need to have parameters ... all i am saying is we need to define it.
2) i think its important for UM ... not needing to go backwards ... for knowing the market (bearish, bullish, sideways) ... the maximum look back period could be 1 day

UM got a super computer that could churn any data we throw at it .... so we just need ideas (parameters)
 

VJAY

Well-Known Member
i am going by ncube's view only .... i think you got me wrong ...what i meant to say is

1) for systematic trading we need to have parameters ... all i am saying is we need to define it.
2) i think its important for UM ... not needing to go backwards ... for knowing the market (bearish, bullish, sideways) ... the maximum look back period could be 1 day

UM got a super computer that could churn any data we throw at it .... so we just need ideas (parameters)
Ok got it...The highlighted part is important...from this we hardly make any parameters for trend ...anyway from views tips of all we may be find some development with this strategy...
 

VJAY

Well-Known Member
Simplest nifty bearish indicator for selection day could be (nifty today open<previous close and today close<prev day high)
IMO this strategy only some negatives on strong bearish sentiments....in other situation its good...so sytong bearsih we unable to find with this step
 

VJAY

Well-Known Member
Master is there a way to test
Code:
import random
x=(random.randint(1,10)*5)
y=x+5
just to backtest how system fares against little random stock selection for orders as in
iloc[x:y]
to understand risk management is priority or strategy

//update
added to backtester seems to work
Code:
import random
for name, group in grouped:

    x=(random.randint(0,45))

    y=x+5


    temp = group.sort_values(by='ret', ascending=False).iloc[x:y]

    collect.append(temp)

orders = pd.concat(collect)
Dear Shivam,
What code is this?Its not plots anything?
 

Similar threads