SwingFish Trading Insights
    0; // --- Compute desired (immediate) state --- $desired = []; if ($live) $desired['media_mode'] = 'live'; elseif ($draft && $active_positions) $desired['media_mode'] = 'capture'; else $desired['media_mode'] = 'cam'; if ($draft) $desired['info_mode'] = 'session'; elseif ($ctrader) $desired['info_mode'] = 'ctrader'; elseif ($live) $desired['info_mode'] = 'livestream'; else $desired['info_mode'] = 'idle'; $desired['show_chart'] = !$live && !$draft; $desired['show_draft'] = $draft; // --- Time constraints (seconds) before transitioning to the resting/default state --- // The delay only applies when idling out (e.g. screenshot→cam, session→idle). // Returning to an active state (e.g. trade reopens) is always immediate. $delays = [ 'media_mode' => 900, // 15 min — keep screenshot after positions close 'info_mode' => 0, // immediate — draft/ctrader data may no longer be valid 'show_chart' => 0, // immediate 'show_draft' => 0, // immediate ]; $resting = [ 'media_mode' => 'cam', 'info_mode' => 'idle', 'show_chart' => false, 'show_draft' => false, ]; // --- Read saved state --- $saved = []; if (file_exists($stateCacheFile)) { $saved = @unserialize(@file_get_contents($stateCacheFile)); if (!is_array($saved)) $saved = []; } $now = time(); $state = []; foreach ($desired as $key => $newValue) { $oldValue = isset($saved[$key]['value']) ? $saved[$key]['value'] : null; $since = isset($saved[$key]['since']) ? $saved[$key]['since'] : $now; if ($newValue !== $oldValue) { // Only delay when heading TO the resting value, and (for media_mode) // only coming FROM 'capture' - the 5min grace period is for keeping // the trade screenshot up after positions close, not for keeping a // dead 'live' embed around after the stream ends. $fromCapture = $key !== 'media_mode' || $oldValue === 'capture'; if ($oldValue !== null && $newValue === $resting[$key] && $fromCapture && ($now - $since) < $delays[$key]) { $state[$key] = ['value' => $oldValue, 'since' => $since]; } else { $state[$key] = ['value' => $newValue, 'since' => $now]; } } else { $state[$key] = ['value' => $newValue, 'since' => $now]; } } @file_put_contents($stateCacheFile, serialize($state), LOCK_EX); // --- Export layout variables --- $media_mode = $state['media_mode']['value']; $info_mode = $state['info_mode']['value']; $show_chart = $state['show_chart']['value']; $show_draft = $state['show_draft']['value']; // --- Purge LiteSpeed's /blog page cache when the header status badge // would change ($live or $info_mode flipped) - otherwise it can keep // showing a stale "Active Position"/Trading Room button on cached /blog // pages for up to litespeed.conf.cache-ttl_pub (1800s). $pos0's live text // isn't tracked here - that changes often while already showing the badge // and isn't worth a purge on its own. $badgeCacheFile = CACHE . 'tradingroom.badge'; $badgeNow = ['live' => $live, 'info_mode' => $info_mode]; $badgeSaved = @unserialize(@file_get_contents($badgeCacheFile)); if ($badgeSaved !== $badgeNow) { @file_put_contents($badgeCacheFile, serialize($badgeNow), LOCK_EX); if (is_array($badgeSaved)) { @file_get_contents(ULOCAL.'lib/3rd/wordpress/lscache-purge.php'); } }
  • Trading Room
  • Fx News
    • Economic Calendar
    • Market News
    • Market News - Archive
    • Squawk Services
  • Signals
  • Money
    • Trading Business
    • Funded Accounts (Prop)
    • Brokers
    • SwingFish Rebate
  • Insights
    • Trading Decoded [40]
    • Trading Room Journal [1698]
    • Forex Signals [411]
    • Market News [7747]
    • Prop Firms [42]
    • Traders Library [63]
    • Broker & Technology [23]
    • SwingFish Updates [146]
    • Video Archive
    • The Book
  • Apps
    • - All Apps
    • SwingFish Intra (vWap Suite) 2.473
    • vWap Meeseeks
    • SwingFish Helper 2.918
    • Stop Syncer 2.0402
    • TL Trader
    • StreamDeck 4 cTrader 0.4102
    • Prop Risk Indicator
0; // --- Compute desired (immediate) state --- $desired = []; if ($live) $desired['media_mode'] = 'live'; elseif ($draft && $active_positions) $desired['media_mode'] = 'capture'; else $desired['media_mode'] = 'cam'; if ($draft) $desired['info_mode'] = 'session'; elseif ($ctrader) $desired['info_mode'] = 'ctrader'; elseif ($live) $desired['info_mode'] = 'livestream'; else $desired['info_mode'] = 'idle'; $desired['show_chart'] = !$live && !$draft; $desired['show_draft'] = $draft; // --- Time constraints (seconds) before transitioning to the resting/default state --- // The delay only applies when idling out (e.g. screenshot→cam, session→idle). // Returning to an active state (e.g. trade reopens) is always immediate. $delays = [ 'media_mode' => 900, // 15 min — keep screenshot after positions close 'info_mode' => 0, // immediate — draft/ctrader data may no longer be valid 'show_chart' => 0, // immediate 'show_draft' => 0, // immediate ]; $resting = [ 'media_mode' => 'cam', 'info_mode' => 'idle', 'show_chart' => false, 'show_draft' => false, ]; // --- Read saved state --- $saved = []; if (file_exists($stateCacheFile)) { $saved = @unserialize(@file_get_contents($stateCacheFile)); if (!is_array($saved)) $saved = []; } $now = time(); $state = []; foreach ($desired as $key => $newValue) { $oldValue = isset($saved[$key]['value']) ? $saved[$key]['value'] : null; $since = isset($saved[$key]['since']) ? $saved[$key]['since'] : $now; if ($newValue !== $oldValue) { // Only delay when heading TO the resting value, and (for media_mode) // only coming FROM 'capture' - the 5min grace period is for keeping // the trade screenshot up after positions close, not for keeping a // dead 'live' embed around after the stream ends. $fromCapture = $key !== 'media_mode' || $oldValue === 'capture'; if ($oldValue !== null && $newValue === $resting[$key] && $fromCapture && ($now - $since) < $delays[$key]) { $state[$key] = ['value' => $oldValue, 'since' => $since]; } else { $state[$key] = ['value' => $newValue, 'since' => $now]; } } else { $state[$key] = ['value' => $newValue, 'since' => $now]; } } @file_put_contents($stateCacheFile, serialize($state), LOCK_EX); // --- Export layout variables --- $media_mode = $state['media_mode']['value']; $info_mode = $state['info_mode']['value']; $show_chart = $state['show_chart']['value']; $show_draft = $state['show_draft']['value']; // --- Purge LiteSpeed's /blog page cache when the header status badge // would change ($live or $info_mode flipped) - otherwise it can keep // showing a stale "Active Position"/Trading Room button on cached /blog // pages for up to litespeed.conf.cache-ttl_pub (1800s). $pos0's live text // isn't tracked here - that changes often while already showing the badge // and isn't worth a purge on its own. $badgeCacheFile = CACHE . 'tradingroom.badge'; $badgeNow = ['live' => $live, 'info_mode' => $info_mode]; $badgeSaved = @unserialize(@file_get_contents($badgeCacheFile)); if ($badgeSaved !== $badgeNow) { @file_put_contents($badgeCacheFile, serialize($badgeNow), LOCK_EX); if (is_array($badgeSaved)) { @file_get_contents(ULOCAL.'lib/3rd/wordpress/lscache-purge.php'); } }

214.1

3435 December 14, 2017 SwingFish 1 min read

215 | +1.588% | 2 Setups

Leave a Reply Cancel reply

You must be logged in to post a comment.

Insights

  • Recent Posts
  • Trading Decoded [40]
  • Trading Room Journal [1698]
  • Forex Signals [411]
  • Market News [7747]
  • Prop Firms [42]
  • Traders Library [63]
  • Broker & Technology [23]
  • SwingFish Updates [146]
  • Video Archive
  • The Book

Recent Posts

  • The market is pricing in a 78% chance of a Bank of Canada rate hike
  • Indian Rupee trims gains as higher oil prices put renewed pressure despite repeated RBI interventions
  • Crude oil is keeping the bullish bias by staying above the 100/200 hour MAs
  • The full statement from the Bank of Canada rate decision for October 2026. Hikes by 25 basis points
  • Bank of Canada rate decision: Hike to 2.50%
  • The USDCAD is trading in a neutral swing area ahead of the Bank of Canada rate decision
  • 1905 | +0.163% | EURUSD
  • US September advance goods trade balance -134.9 billion vs -130.2 billion expected

176 Chat Members

  • zanderx20 zanderx20
  • MrJonas MrJonas
  • coolcat coolcat
  • Christian G. Christian G.
  • Perlimpinpin Perlimpinpin
  • Murilo Murilo
  • Torranceljx Torranceljx
  • Cool Moe Dee Cool Moe Dee

0x8 Trading AUDCAD AUDCHF AUDJPY AUDNZD AUDUSD BlueGuardian BTCUSD CADCHF CADJPY CHFJPY DAX Decoded DJI EnFoid ETHUSD EURAUD EURCAD EURGBP EURJPY EURNZD EURSGD EURUSD GBPAUD GBPCAD GBPCHF GBPJPY GBPNZD GBPUSD GOLD HK50 ICMarkets NASDAQ Nikkei NZDCAD NZDJPY NZDUSD SGDJPY USDCAD USDCHF USDCNH USDJPY USDMXN USDSGD WTI

SwingFish Trading Insights

SwingFish is a community-based project, by traders, for traders, with the goal of obtaining financial independence quickly and without the usual costs involved.

Info

  • About
  • Sitemap
  • FAQ
  • Terms

Community

  • Crew
  • Download / Shop
  • Trading Room

Follow

Reviews

ForexPeaceArmy Reviews for SwingFish

© SwingFish 2011-2026, All Rights Reserved. — We use cookies to keep things working — see what we know about you

Built with the sf2 theme.