Skip to content

Instantly share code, notes, and snippets.

@bnsheehy
Created January 4, 2022 22:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bnsheehy/48753cc12c38ceac6119afc9188db461 to your computer and use it in GitHub Desktop.
Save bnsheehy/48753cc12c38ceac6119afc9188db461 to your computer and use it in GitHub Desktop.
Point & Figure Pseudocode
If previous day’s plot_symbol = "X", then:
If current price >= previous price, then:
Today's plot_symbol = "X".
and copy yesterday's signal_name to today.
And if today's price is higher than the last high_point:
then make today's price the high_point,
and copy yesterday's signal_name to today.
And if today's price is higher than the high point from the last X column:
then today's signal_name = "BUY"
Else if today's price is less than the previous high times 1 - reversalAmount:
the plot_symbol reverses to "O",
and the low_point is today's price,
and reversal = 1,
and prev_high_point = last_high_point, saving this value to use in the Target Price calc below
and last_high_point = most recent high_point
and entry_o = previous day's closing price, used in next_entry and stop_loss calcs
And if today's price is lower than the last_low_point from the last O column:
then today's signal = "SELL".
Else:
copy yesterday's signal to today
Else:
plot_symbol = "X" (price is down but not enough to trigger a reversal)
and copy yesterday's signal to today.
If previous plot_symbol = "O", then:
If current price <= previous price, then:
Today's plot_symbol = "O".
and copy yesterday's signal_name to today.
And if today's price is lower than the most recent low_point,
then make today's price the low_point.
and copy yesterday's signal_name to today.
And if today's price is lower than the last_low_point from the last O column,
then today's signal = "SELL".
Else if today's price is greater than the last_high_point, times 1 + reversalAmount:
the plot_symbol reverses to "X",
and the high_point is today's price,
and reversal = 1,
and prev_low_point = last_low_point, saving this value to use in the Target Price calc below
and last_low_point = low_point
and entry_x = previous day's closing price, used in next_entry and stop_loss calcs
and if today's price is higher than the high point from the last X column:
then today's signal_name = "BUY".
Else copy yesterday's signal_name to today.
Else:
Plot Symbol = "O" (price is up but not enough to trigger a reversal)
and copy yesterday's signal_name to today.
Set high_point = current "high_point"
Set low_point = current "low_point"
Set last_high_point = current "last_high_point"
Set last_low_point = current "last_low_point"
Set prev_high_point = current "prev_high_point"
Set prev_low_point = current "prev_low_point"
If current signal_name = “BUY”
Set next_entry at one boxSize up from the price at the last reversal from X to O, which should be near the top of the previous X column
Set the stop_loss at one boxSize down from the price at the last reversal from O to X, which should be near the bottom of the previous O column
If previous signal_name = “SELL”:
Upon reversal from SELL to BUY, set the target_price equal to the size of the previous X column, times the boxSize, added to the bottom of the previous X column. Once calculated, it does not change for the balance of the current BUY signal.
Else:
Set next_entry at one boxSize down from the price at the last reversal from O to X, which should be near the bottom of the previous O column
Set the stop_loss at one boxSize up from the price at the last reversal from X to O, which should be near the top of the previous X column
If previous signal_name = “BUY”
Upon reversal from BUY to SELL, set the target_price equal to the size of the previous O column, times the boxSize, subtracted from the top of the previous O column. Once calculated, it does not change for the balance of the current SELL signal.
Set entry_x = current "entry_x"
Set entry_o = current "entry_o"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment