Last active
October 4, 2019 22:51
-
-
Save larrybotha/14496191eb25e962ed090fb3ed360e4c to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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