Outliers, stock splits, price anomalies


An unusual price deviation in historical or live price data was detected. Automatically set by calling a price or contractUpdate function; sensitivity can be set with the Outlier variable. PriceJump can be evaluated in scripts for handling outliers and stock splits or merges. Afterwards reset it to 0 for 'arming' it for the next price deviation.

0 - No price anomaly since the last reset.
1 - Outlier detected, see below.
2..10 - Stock split by the given factor detected, f.i. 4 for a 1:4 stock split.
-2..-10 - Stock merge by the given factor detected, f.i. -4 for a 4:1 stock merge. 




Sensitivity factor of the outlier detection for historical and for live prices (default = 1.1+2*sqrt(BarPeriod/1440)). All outliers above the given factor or below its reciprocal are suppressed with a 0.0001 EMA factor. For instance, Outlier = 1.15; suppresses all outliers that deviate from the last price by more than 15% in any direction. PriceJump is set to 1 when an outlier was detected. Negative ask-bid spreads are also suppressed. Set Outlier to 0 for not detecting splits, outliers, and negative spreads; set it to between 1 and 2 for detecting them; set it to above 2 for high volatility assets and for treating splits as outliers. 




Number of outliers and price jumps detected so far in historical or live data (Zorro 2.42 or above). Can be reset to 0 for starting a new count.





function run()
  Outlier = 1.05;  // detect and suppress price deviations by more than 5%
  PriceJump = 0;   // in case it was set before
  if(PriceJump >= 2) { // stock split detected 
    printf("\nStock split %i:1 - manually close all open contracts!",PriceJump);
    for(open_trades) cancelTrade(ThisTrade); // clear the open trade list
    PriceJump = 0;
    setf(TradeMode,PHANTOM); // suspend further trading

See also:

tick, TickTime, price


► latest version online