Loading...

Plus+ Python

Modified Whiplash Trading Strategy with Buy & Sell Signals: Python

Modified Whiplash Trading Strategy with Buy & Sell Signals: Python


Strategy Description
Outlined in the book "Street Smarts: High Probability Short-Term Trading Strategies" by Laurence A. Connors and Linda Bradford Raschke, Whiplash is a fairly simple strategy that tries to take advantage of intraday market movement following a big gap. Typically there is a gap in the morning followed by a reversal in the afternoon, and the expectation is that the price action reversal continues into the next day. But because cryptocurrency markets do not ever close, and instead trade 24/7, we will modify the strategy slightly. Instead of an overall "Gap", the strategy is modified so that it must take out the previous days' high or low extreme and then follow remaining rules.

Strategy Rules and Conditions
  • Market must trade lower (or higher) than previous days' low (or high)
  • The closing price must be higher than the Opening price
  • Price must close in the top 50% of the days' trading range
  • Buy signal at the close of day where the above conditions are met
  • Signals are meant for one day forward and trailing stops to protect gains is recommended for the strategy


  • The Code
    The code loads the data from CryptoDataDownload from any exchange and mimics logic for loading data into Pandas DataFrames found in other examples. We then create several columns that represent the Boolean logic outlined in the above strategy rules. If all conditions are True for a given signal, then a "signal" is produced. The full data history and new columns are saved in a CSV file for you called 'whiplash_strategy.csv' once it completes. Every line of code is commented. Less than 50 lines of code TOTAL

    Plus+ membership required

    Create a Plus+ account to view the live codebase.

    This article has a fully working, notebook-ready code block. Sign up for Plus+ to access it and the rest of the 20+ premium articles.

    Subscribe to Plus+ Browse Plus+ articles