Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. const bullishMachineConfig = {
  2. initial: 'findingStock',
  3.  
  4. on: {
  5. MARKET_TRENDING_DOWN: 'bearish',
  6. MARKET_TRENDING_SIDEWAYS: 'evaluatingGeneralMarket',
  7. },
  8.  
  9. states: {
  10. findingStock: {
  11. on: {
  12. STOCK_FOUND: 'watchingForEntrySignal',
  13. }
  14. },
  15.  
  16. watchingForEntrySignal: {
  17. on: {
  18. STOCK_DEVIATES_FROM_MARKET: 'findingStock',
  19. NO_SIGNAL: 'watchingForEntrySignal',
  20. WPR_ENTERS_OVERSOLD: 'watchingForEntryConfirmation'
  21. }
  22. },
  23.  
  24. watchingForEntryConfirmation: {
  25. on: {
  26. STOCK_DEVIATES_FROM_MARKET: 'findingStock',
  27. NO_CONFIRMATION: 'watchingForEntryConfirmation',
  28. MAX_CONFIRMATION_PERIOD_EXCEEDED: 'watchingForEntrySignal',
  29. STOCK_CLOSES_ABOVE_7_DMA: {
  30. target: 'watchingForFollowThroughRules',
  31. cond: '7dmaIsAbove30dma',
  32. }
  33. }
  34. },
  35.  
  36. watchingForFollowThroughRules: {
  37. entry: 'waitOneDay',
  38.  
  39. on: {
  40. STOCK_DEVIATES_FROM_MARKET: 'findingStock',
  41. NO_FOLLOW_THROUGH: 'watchingForFollowThroughRules',
  42. MAX_FOLLOW_THROUGH_PERIOD_EXCEEDED: 'watchingForEntrySignal',
  43. STOCK_CLOSES_ABOVE_PREVIOUS_DAYS_CLOSE: 'tradePlaced'
  44. }
  45. },
  46.  
  47. tradePlaced: {},
  48. }
  49. };
  50.  
  51. const bearishMachineConfig = {
  52. initial: 'findingStock',
  53.  
  54. on: {
  55. MARKET_TRENDING_UP: 'bullish',
  56. MARKET_TRENDING_SIDEWAYS: 'evaluatingGeneralMarket',
  57. },
  58.  
  59. states: {
  60. findingStock: {},
  61.  
  62. watchingForEntrySignal: {},
  63.  
  64. watchingForEntryConfirmation: {},
  65.  
  66. watchingForFollowThroughRules: {},
  67.  
  68. tradePlaced: {},
  69. }
  70. };
  71.  
  72. const prMachine = Machine({
  73. id: 'pr-machine',
  74.  
  75. initial: 'evaluatingGeneralMarket',
  76.  
  77. states: {
  78. evaluatingGeneralMarket: {
  79. on: {
  80. MARKET_TRENDING_UP: 'bullish',
  81. MARKET_TRENDING_DOWN: 'bearish',
  82. MARKET_TRENDING_SIDEWAYS: 'evaluatingGeneralMarket',
  83. }
  84. },
  85.  
  86. bullish: {
  87. ...bullishMachineConfig,
  88. },
  89.  
  90. bearish: {
  91. ...bearishMachineConfig,
  92. },
  93. }
  94. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement