function processPullbacks() { $watches = new watchlist(); $watches->set_variable("watchlist_tradetype", PULLBACK_TRADE); while ($watches->loadNext()) { $tId = $watches->get_variable("watchlist_ticker_id"); $wId = $watches->get_variable("watchlist_id"); $calcHigh = $watches->get_variable("watchlist_high"); $calcLow = $watches->get_variable("watchlist_low"); $ticker = new ticker(); $ticker->set_variable("ticker_id", $tId); if ($ticker->load()) { $dayHigh = $ticker->get_variable("today_high"); $symbol = strtoupper($ticker->get_variable("ticker_symbol")); echo "Testing " . $symbol . " PrevHigh=" . $calcHigh . " DayHigh=" . $dayHigh . "<br>\n"; if ($dayHigh > $calcHigh) { echo " RECALC AND HIGHLIGHTING\n<br>"; $className = adminControlWatchlist::GetWatchClassName(PULLBACK_TRADE); $watchlistAdmin = new $className($wId); $watchlistAdmin->Edit($calcLow, $dayHigh); // highlight the abandon price highlights::watchlistHighlight($wId, W_ENTRY_ZONE, 0, highlights::EVENT_START_DAY); } } } }
$watchlistId = intval($_GET['edit_id']); } else { if (isset($_POST['watchlist_id'])) { $watchlistId = intval($_POST['watchlist_id']); } else { if (isset($_GET['zone_id'])) { $watchlistId = intval($_GET['zone_id']); } else { header('Location: admin.editall.php'); } } } $watchlistItem = new watchlist(); $watchlistItem->set_variable('watchlist_id', $watchlistId); if ($watchlistItem->load()) { $tradeType = $watchlistItem->get_variable('watchlist_tradetype'); } // Save any edited data if (isset($_POST["low"]) || isset($_GET['zone_id'])) { $className = adminControlWatchlist::GetWatchClassName($tradeType); $watchlistAdmin = new $className($watchlistId); } if (isset($_POST["low"])) { $low = isset($_POST["low"]) ? $_POST["low"] : 0; $high = isset($_POST["high"]) ? $_POST["high"] : 0; $top = isset($_POST["top"]) ? $_POST["top"] : 0; $bottom = isset($_POST["bottom"]) ? $_POST["bottom"] : 0; $t1 = isset($_POST["t1"]) ? $_POST["t1"] : 0; $t2 = isset($_POST["t2"]) ? $_POST["t2"] : 0; $t3 = isset($_POST["t3"]) ? $_POST["t3"] : 0; $tip = isset($_POST["tip"]) ? $_POST["tip"] : 0;
$tradeType = intval($_GET['tt']); } else { $tradeType = BREAKOUT_TRADE; } $counter = 1; while (true) { if (!isset($_POST[$counter])) { break; } $watchId = $_POST[$counter]; $watchlist = new watchlist(); $watchlist->set_variable('watchlist_id', $watchId); if ($watchlist->load()) { $low = floatval($_POST['low_' . $watchId]); $high = floatval($_POST['high_' . $watchId]); $oldLow = floatval($watchlist->get_variable('watchlist_low')); $oldHigh = floatval($watchlist->get_variable('watchlist_high')); if ($oldLow != $low || $oldHigh != $high) { $className = adminControlWatchlist::GetWatchClassName($tradeType); $updateWatch = new $className(); $updateWatch->UpdateWatch($watchlist, $low, $high); } } $counter++; } $watchlists = array(); $watchlists = ticker_group_info::retrieveAdminWatchlistArray($tradeType); ?> <!DOCTYPE html>
private function updateWatchlist() { $ticker = new ticker(); $date = date('Y-m-d H:i:s'); $deleteIds = array(); echo "\n\nUpdating Watchlist\n"; while ($ticker->loadNext()) { $tickerId = $ticker->get_variable('ticker_id'); $tickerSymbol = $ticker->get_variable('ticker_symbol'); $last = floatval($ticker->get_variable('last')); $low = floatval($ticker->get_variable('today_low')); $high = floatval($ticker->get_variable('today_high')); $watchlist = new watchlist(); $watchlist->set_variable('watchlist_ticker_id', $tickerId); while ($watchlist->loadNext()) { $zoned = $watchlist->get_variable('watchlist_is_zoned'); $watchlistId = $watchlist->get_variable('watchlist_id'); $bottom = floatval($watchlist->get_variable('watchlist_bottom')); $top = floatval($watchlist->get_variable('watchlist_top')); $watchlistLow = floatval($watchlist->get_variable('watchlist_low')); $tradeType = $watchlist->get_variable('watchlist_tradetype'); switch ($tradeType) { case SHORT_TRADE: case BACKDRAFT_TRADE: if ($zoned == 0 && ($last >= $bottom || $high >= $bottom) && ($last <= $top || $low <= $top && $low > 0)) { echo $watchlist->markZoned($tradeType); } else { if ($zoned == 1 && $last <= floatval($watchlist->get_variable('watchlist_target1'))) { $deleteIds[] = $watchlistId; } } break; case LONG_TRADE: case PULLBACK_TRADE: if ($zoned == 0 && $last >= $bottom && ($last <= $top || $low <= $top && $low > 0)) { echo $watchlist->markZoned($tradeType); } else { if ($zoned == 1 && $last >= floatval($watchlist->get_variable('watchlist_target1'))) { $deleteIds[] = $watchlistId; } } break; case REVERSAL_TRADE: if ($zoned == 0 && ($last <= $top || $low <= $top && $low > 0)) { echo $watchlist->markZoned($tradeType); } else { if ($zoned == 1 && $last >= floatval($watchlist->get_variable('watchlist_target1'))) { $deleteIds[] = $watchlistId; } } break; case BREAKOUT_TRADE: if ($zoned == 0 && ($last >= $watchlistLow || $low >= $watchlistLow)) { echo $watchlist->markZoned($tradeType); } else { if ($zoned == 1 && $last >= floatval($watchlist->get_variable('watchlist_target1'))) { $deleteIds[] = $watchlistId; } } break; case BREAKDOWN_TRADE: $lowerThanLastAndNotZero = $last <= $watchlistLow && $last != 0; $lowerThanLowAndNotZero = $low <= $watchlistLow && $low != 0; if ($zoned == 0 && ($lowerThanLastAndNotZero || $lowerThanLowAndNotZero)) { echo $watchlist->markZoned($tradeType); } else { if ($zoned == 1 && $last <= floatval($watchlist->get_variable('watchlist_target1'))) { $deleteIds[] = $watchlistId; } } break; } } } foreach ($deleteIds as $wId) { echo "\n\n\nDELETING WATCHLIST ID " . $wId . " because it passed T1 "; $watchlist = new watchlist(); $watchlist->set_variable('watchlist_id', $wId); $watchlist->delete(); } }
function startOfDayUpdate() { // Update the highlights with start of day trigger highlights::eventTrigger(highlights::EVENT_START_DAY); // Make sure no expired users get emails. user::resetAllExpiredEmailUpdates(); // Delete previously deleted watchlists watchlist::pruneDeletedWatchlistIds(); watchlist::deleteZonedTickers(BREAKOUT_TRADE); watchlist::deleteZonedTickers(BREAKDOWN_TRADE); watchlist::deleteZonedTickers(LONG_TRADE); watchlist::deleteZonedTickers(SHORT_TRADE); watchlist::deleteZonedTickers(PULLBACK_TRADE); watchlist::deleteZonedTickers(BACKDRAFT_TRADE); $deleteIds = array(); $deleteHoldingsIds = array(); $holdings = new holdings(); while ($holdings->loadNext()) { $hid = $holdings->get_variable("holdings_id"); $tid = $holdings->get_variable("holdings_ticker_id"); $action = $holdings->get_variable("holdings_last_action"); $hidden = $holdings->get_variable("holdings_abandon_hide"); $tradeType = $holdings->get_variable("holdings_tradetype"); if (IsAbandoned($action) && $hidden == 0) { $deleteHoldingsIds[] = $hid; echo "\nDELETING Holdings ID " . $hid . " because it was abandoned"; $watchlist = new watchlist(); $watchlist->set_variable("watchlist_ticker_id", $tid); $watchlist->set_variable("watchlist_tradetype", $tradeType); while ($watchlist->loadNext()) { $deleteIds[] = $watchlist->get_variable("watchlist_id"); } } else { if (($tradeType == REVERSAL_TRADE || $tradeType == SHORT_TRADE) && $hidden == 0) { $hitT3 = $holdings->get_variable("holdings_t3_marked"); if ($hitT3 == 1) { $deleteHoldingsIds[] = $hid; echo "\nDELETING Holdings ID " . $hid . " because topped reversal/shorts"; $watchlist = new watchlist(); $watchlist->set_variable("watchlist_ticker_id", $tid); $watchlist->set_variable("watchlist_tradetype", $tradeType); while ($watchlist->loadNext()) { $deleteIds[] = $watchlist->get_variable("watchlist_id"); } } } else { if (($tradeType == BACKDRAFT_TRADE || $tradeType == PULLBACK_TRADE) && $hidden == 0) { $hitT1 = $holdings->get_variable("holdings_t1_marked"); if ($hitT1 == 1) { $deleteHoldingsIds[] = $hid; echo "\nDELETING Holdings ID " . $hid . " because topped pullback/backdraft"; $watchlist = new watchlist(); $watchlist->set_variable("watchlist_ticker_id", $tid); $watchlist->set_variable("watchlist_tradetype", $tradeType); while ($watchlist->loadNext()) { $deleteIds[] = $watchlist->get_variable("watchlist_id"); } } } } } } foreach ($deleteIds as $wid) { echo "\n\n\nDELETING Watchlist ID " . $wid . " because it is abandoned or topped out reversal/shorts"; $watchlist = new watchlist(); $watchlist->set_variable('watchlist_id', $wid); $watchlist->delete(); } foreach ($deleteHoldingsIds as $hid) { echo "\n\n\nDELETING Holdings ID " . $hid . " because it is abandoned or topped out reversal/shorts"; $holdings = new holdings(); $holdings->set_variable('holdings_id', $hid); // instead of deleting, mark it as hidden if ($holdings->load()) { $tickerInfo = new ticker(); $tickerInfo->set_variable('ticker_id', $holdings->get_variable('holdings_ticker_id')); if ($tickerInfo->load()) { $holdings->set_variable('holdings_ticker_symbol', $tickerInfo->get_variable('ticker_symbol')); } $holdings->set_variable('holdings_abandon_hide', 1); $holdings->set_variable('holdings_abandon_date', date('Y-m-d H:i:s')); $holdings->update(); } // replace this //$holdings->delete(); } // delete the tickers that are no longer used. $ticker = new ticker(); $deleteIds = array(); while ($ticker->loadNext()) { $tid = $ticker->get_variable("ticker_id"); // reset the high and low $last = $ticker->get_variable("last"); $ticker->set_variable("today_high", $last); $ticker->set_variable("today_low", $last); $ticker->set_variable("last_high", $last); $ticker->set_variable("last_low", $last); $ticker->update(); $watchlist = new watchlist(); $watchlist->set_variable("watchlist_ticker_id", $tid); if (!$watchlist->load()) { $holding = new holdings(); $holding->set_variable("holdings_ticker_id", $tid); $holding->set_variable("holdings_abandon_hide", 0); if (!$holding->load()) { $deleteIds[] = $tid; } } } foreach ($deleteIds as $tid) { echo "\n\n\nDELETING TICKER ID " . $tid . " because it is no longer used"; $ticker = new ticker(); $ticker->set_variable('ticker_id', $tid); $ticker->delete(); } $tickerHist = new ticker_history(); while ($tickerHist->loadNextDistinctTicker()) { $ticker = new ticker(); $tid = $tickerHist->get_variable('history_ticker_id'); $ticker->set_variable('ticker_id', $tid); if (!$ticker->load()) { echo "\nTicker History Cleanup:: Removing " . $tid . "\n"; ticker_history::removeTickerHistory($tid); } } // try to reconcile any payments that are not currently known. // now doing this whenever a payment is received. //payment_info::reconcileAllPaymentUids(); }