Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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,
- },
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement