Stochastic Oscillator Buy / Sell Signal

Hi,



In the, where the Stochastic Oscillator is described, it is stated that: 

The crossover signal is generated as follows:

● The crossover of the “fast %K” above the “slow %D” is considered as the buy signal.

● The crossover of the “fast %K” below the “slow %D” is considered as the sell signal.

Stochastic-Oscillator-PDFwatermark.pdf - Google Drive )



However, in the Jupyter notebook file, Technical Indicators Based Momentum Strategy, 

Buy signal is calculated as stock_data['fastd'] > stock_data['slowd']) & (stock_data['fastk'] > stock_data['slowk'] for stochastic indicator. 

 

# Buy signal
stock_data.loc[(stock_data['SAR'] < stock_data['Close']) & (stock_data['fastd'] > stock_data['slowd'])
               & (stock_data['fastk'] > stock_data['slowk']), 'new_signal'] = 1

# Exit signal
stock_data.loc[(stock_data['SAR'] > stock_data['Close']) & (stock_data['fastd'] < stock_data['slowd'])
               & (stock_data['fastk'] < stock_data['slowk']), 'new_signal'] = 0

Why it is different between pdf and jupyter notebook?

Also, the stocks are bought every time the condition is satisfied? 

Thanks,
Boris

Hi Boris,


  1. Thank you very much for pointing this out. We have made the required changes to the jupyter notebook.
  2. Yes, the long entry signal is generated every time the condition gets satisfied.





    Regards,

    Akshay