Skip to content

Instantly share code, notes, and snippets.

@larrybotha
Last active October 4, 2019 22:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save larrybotha/14496191eb25e962ed090fb3ed360e4c to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const bullishMachineConfig = {
initial: 'findingStock',
on: {
MARKET_TRENDING_DOWN: 'bearish',
MARKET_TRENDING_SIDEWAYS: 'evaluatingGeneralMarket',
},
states: {
findingStock: {
on: {
STOCK_FOUND: 'watchingForEntrySignal',
}
},
watchingForEntrySignal: {
on: {
STOCK_DEVIATES_FROM_MARKET: 'findingStock',
NO_SIGNAL: 'watchingForEntrySignal',
WPR_ENTERS_OVERSOLD: 'watchingForEntryConfirmation'
}
},
watchingForEntryConfirmation: {
on: {
STOCK_DEVIATES_FROM_MARKET: 'findingStock',
NO_CONFIRMATION: 'watchingForEntryConfirmation',
MAX_CONFIRMATION_PERIOD_EXCEEDED: 'watchingForEntrySignal',
STOCK_CLOSES_ABOVE_7_DMA: {
target: 'watchingForFollowThroughRules',
cond: '7dmaIsAbove30dma',
}
}
},
watchingForFollowThroughRules: {
entry: 'waitOneDay',
on: {
STOCK_DEVIATES_FROM_MARKET: 'findingStock',
NO_FOLLOW_THROUGH: 'watchingForFollowThroughRules',
MAX_FOLLOW_THROUGH_PERIOD_EXCEEDED: 'watchingForEntrySignal',
STOCK_CLOSES_ABOVE_PREVIOUS_DAYS_CLOSE: 'tradePlaced'
}
},
tradePlaced: {},
}
};
const bearishMachineConfig = {
initial: 'findingStock',
on: {
MARKET_TRENDING_UP: 'bullish',
MARKET_TRENDING_SIDEWAYS: 'evaluatingGeneralMarket',
},
states: {
findingStock: {},
watchingForEntrySignal: {},
watchingForEntryConfirmation: {},
watchingForFollowThroughRules: {},
tradePlaced: {},
}
};
const prMachine = Machine({
id: 'pr-machine',
initial: 'evaluatingGeneralMarket',
states: {
evaluatingGeneralMarket: {
on: {
MARKET_TRENDING_UP: 'bullish',
MARKET_TRENDING_DOWN: 'bearish',
MARKET_TRENDING_SIDEWAYS: 'evaluatingGeneralMarket',
}
},
bullish: {
...bullishMachineConfig,
},
bearish: {
...bearishMachineConfig,
},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment