/* TA-LIB Copyright (c) 1999-2025, Mario Fortier
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or
 * without modification, are permitted provided that the following
 * conditions are met:
 *
 * - Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 *
 * - Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in
 *   the documentation and/or other materials provided with the
 *   distribution.
 *
 * - Neither name of author nor the names of its contributors
 *   may be used to endorse or promote products derived from this
 *   software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/* Important:
 *  This file is automatically generated by the utility ta_codegen.
 *  Any modifications will be lost on next execution of ta_codegen.
 *
 *  Modifications should instead be done with the "C" source file
 *  in ta-lib\src\ta_func
 */

/* List of contributors:
 *
 *  Initial  Name/description
 *  -------------------------------------------------------------------
 *  AC       Angelo Ciceri
 *
 *
 * Change history:
 *
 *  MMDDYY BY   Description
 *  -------------------------------------------------------------------
 *  022705 AC   Creation
 */

// Import types from parent module
use super::*;

// Allow non-snake-case names to maintain TA-Lib API compatibility
#[allow(non_snake_case)]
#[allow(unused_variables)]
#[allow(dead_code)]
#[allow(unused_mut)]
#[allow(unused_assignments)]
impl Core {
    /// Lookback period for [`Core::cdlconcealbabyswall`]: the number of leading input values
    /// consumed before the first output value can be produced.
    pub fn cdlconcealbabyswall_lookback(&self) -> usize {
        #[allow(non_snake_case)]
        let ShadowVeryShort_rangeType: i32 = self.candle_settings.shadow_very_short.range_type;
        #[allow(non_snake_case)]
        let ShadowVeryShort_avgPeriod: i32 = self.candle_settings.shadow_very_short.avg_period;
        #[allow(non_snake_case)]
        let ShadowVeryShort_factor: f64 = self.candle_settings.shadow_very_short.factor;
        return (ShadowVeryShort_avgPeriod + 3) as usize;
    }
    /// A four-candle pattern: two black marubozus, then a black candle that gaps down but pokes its
    /// upper shadow into the prior body, then a larger black candle fully engulfing the third.
    /// Bullish reversal signal. A hit signals a bullish reversal.
    ///
    /// # Notes
    ///
    /// * Does not verify the preceding downtrend the pattern classically assumes.
    ///
    /// # Arguments
    ///
    /// * `startIdx` — Start index of the requested calculation range.
    /// * `endIdx` — End index of the requested calculation range (inclusive).
    /// * `inOpen` — Open prices per bar.
    /// * `inHigh` — High prices per bar.
    /// * `inLow` — Low prices per bar.
    /// * `inClose` — Close prices per bar.
    /// * `outBegIdx` — Set to the input index of the first output value.
    /// * `outNBElement` — Set to the number of output values written.
    /// * `outInteger` — +100 on a match, 0 otherwise; never emits -100 (pattern is always
    ///   bullish)
    ///
    /// # Errors
    ///
    /// Returns [`RetCode::OutOfRangeStartIndex`] when `endIdx < startIdx`.
    ///
    /// # Panics
    ///
    /// Input slices must cover `startIdx..=endIdx` and output slices must hold the number of values
    /// produced for that range: undersized slices panic or, for functions that forward to unchecked
    /// internals, cause undefined behavior. Sizing every output slice to the input length is always
    /// sufficient.
    ///
    /// # Examples
    ///
    /// ```
    /// use ta_lib::{Core, RetCode};
    ///
    /// let open: Vec<f64> = (0..252).map(|i| 100.0 + 10.0 * (0.1 * i as f64 - 0.05).sin()).collect();
    /// let high: Vec<f64> = (0..252).map(|i| 101.0 + 10.0 * (0.1 * i as f64).sin()).collect();
    /// let low: Vec<f64> = (0..252).map(|i| 99.0 + 10.0 * (0.1 * i as f64).sin()).collect();
    /// let close: Vec<f64> = (0..252).map(|i| 100.0 + 10.0 * (0.1 * i as f64).sin()).collect();
    ///
    /// let core = Core::new();
    /// let mut out_beg = 0;
    /// let mut out_nb = 0;
    /// let mut out = vec![0i32; 252];
    ///
    /// let ret = core.cdlconcealbabyswall(
    ///     0, open.len() - 1, &open, &high, &low, &close,
    ///     &mut out_beg, &mut out_nb, &mut out,
    /// );
    /// assert_eq!(ret, RetCode::Success);
    /// assert!(out_nb > 0);
    /// ```
    ///
    /// # See also
    ///
    /// [`Core::cdlmarubozu`] · [`Core::cdlengulfing`]
    ///
    /// Further reading:
    /// [ta-lib.org/functions/cdlconcealbabyswall](https://ta-lib.org/functions/cdlconcealbabyswall/)
    #[doc(alias = "ConcealingBabySwallow")]
    pub fn cdlconcealbabyswall(
        &self,
        startIdx: usize,
        endIdx: usize,
        inOpen: &[f64],
        inHigh: &[f64],
        inLow: &[f64],
        inClose: &[f64],
        outBegIdx: &mut usize,
        outNBElement: &mut usize,
        outInteger: &mut [i32],
    ) -> RetCode {
        if endIdx < startIdx {
            return RetCode::OutOfRangeStartIndex;
        }
        let mut startIdx = startIdx;
        let mut ShadowVeryShortPeriodTotal: [f64; 4 as usize] = [0.0_f64; 4 as usize];
        let mut i: usize = 0_usize;
        let mut outIdx: usize = 0_usize;
        let mut totIdx: usize = 0_usize;
        let mut ShadowVeryShortTrailingIdx: usize = 0_usize;
        let mut lookbackTotal: usize = 0_usize;
        #[allow(non_snake_case)]
        let ShadowVeryShort_rangeType: i32 = self.candle_settings.shadow_very_short.range_type;
        #[allow(non_snake_case)]
        let ShadowVeryShort_avgPeriod: i32 = self.candle_settings.shadow_very_short.avg_period;
        #[allow(non_snake_case)]
        let ShadowVeryShort_factor: f64 = self.candle_settings.shadow_very_short.factor;
        // Identify the minimum number of price bar needed
        // to calculate at least one output.
        lookbackTotal = self.cdlconcealbabyswall_lookback();
        // Move up the start index if there is not
        // enough initial data.
        if startIdx < lookbackTotal {
            startIdx = lookbackTotal;
        }
        // Make sure there is still something to evaluate.
        if startIdx > endIdx {
            (*outBegIdx) = 0;
            (*outNBElement) = 0;
            return RetCode::Success;
        }
        // Do the calculation using tight loops.
        // Add-up the initial period, except for the last value.
        ShadowVeryShortPeriodTotal[3] = 0.0;
        ShadowVeryShortPeriodTotal[2] = 0.0;
        ShadowVeryShortPeriodTotal[1] = 0.0;
        ShadowVeryShortTrailingIdx = startIdx - (ShadowVeryShort_avgPeriod) as usize;
        i = ShadowVeryShortTrailingIdx;
        while i < startIdx {
            let mut _candlerange_0: f64;
            match ShadowVeryShort_rangeType {
                0 => {
                    _candlerange_0 = (inClose[i - 3] - inOpen[i - 3]).abs();
                }
                1 => {
                    _candlerange_0 = inHigh[i - 3] - inLow[i - 3];
                }
                2 => {
                    _candlerange_0 = inHigh[i - 3] - inLow[i - 3] - (inClose[i - 3] - inOpen[i - 3]).abs();
                }
                _ => {
                    _candlerange_0 = 0.0;
                }
            }
            ShadowVeryShortPeriodTotal[3] = ShadowVeryShortPeriodTotal[3] + _candlerange_0;
            let mut _candlerange_1: f64;
            match ShadowVeryShort_rangeType {
                0 => {
                    _candlerange_1 = (inClose[i - 2] - inOpen[i - 2]).abs();
                }
                1 => {
                    _candlerange_1 = inHigh[i - 2] - inLow[i - 2];
                }
                2 => {
                    _candlerange_1 = inHigh[i - 2] - inLow[i - 2] - (inClose[i - 2] - inOpen[i - 2]).abs();
                }
                _ => {
                    _candlerange_1 = 0.0;
                }
            }
            ShadowVeryShortPeriodTotal[2] = ShadowVeryShortPeriodTotal[2] + _candlerange_1;
            let mut _candlerange_2: f64;
            match ShadowVeryShort_rangeType {
                0 => {
                    _candlerange_2 = (inClose[i - 1] - inOpen[i - 1]).abs();
                }
                1 => {
                    _candlerange_2 = inHigh[i - 1] - inLow[i - 1];
                }
                2 => {
                    _candlerange_2 = inHigh[i - 1] - inLow[i - 1] - (inClose[i - 1] - inOpen[i - 1]).abs();
                }
                _ => {
                    _candlerange_2 = 0.0;
                }
            }
            ShadowVeryShortPeriodTotal[1] = ShadowVeryShortPeriodTotal[1] + _candlerange_2;
            i += 1;
        }
        i = startIdx;
        // Proceed with the calculation for the requested range.
        // Must have:
        // - first candle: black marubozu (very short shadows)
        // - second candle: black marubozu (very short shadows)
        // - third candle: black candle that opens gapping down but has an upper shadow that extends into the prior body
        // - fourth candle: black candle that completely engulfs the third candle, including the shadows
        // The meanings of "very short shadow" are specified with TA_SetCandleSettings;
        // outInteger is positive (1 to 100): concealing baby swallow is always bullish;
        // the user should consider that concealing baby swallow is significant when it appears in downtrend, while
        // this function does not consider it
        outIdx = 0;
        loop {
            if ((if inClose[i - 3] >= inOpen[i - 3] { 1 } else { 0 - 1 })) as i32 == 0 - 1 && // 1st black
               ((if inClose[i - 2] >= inOpen[i - 2] { 1 } else { 0 - 1 })) as i32 == 0 - 1 && // 2nd black
               ((if inClose[i - 1] >= inOpen[i - 1] { 1 } else { 0 - 1 })) as i32 == 0 - 1 && // 3rd black
               ((if inClose[i] >= inOpen[i] { 1 } else { 0 - 1 })) as i32 == 0 - 1 && // 4th black
               ((if inClose[i - 3] >= inOpen[i - 3] { inOpen[i - 3] } else { inClose[i - 3] }) - inLow[i - 3]) < ((ShadowVeryShort_factor) * (if (ShadowVeryShort_avgPeriod) != 0 { (ShadowVeryShortPeriodTotal[3]) / (ShadowVeryShort_avgPeriod as f64) } else { match ShadowVeryShort_rangeType { 0 => (inClose[i - 3] - inOpen[i - 3]).abs(), 1 => (inHigh[i - 3]) - (inLow[i - 3]), _ => (inHigh[i - 3]) - (inLow[i - 3]) - ((inClose[i - 3]) - (inOpen[i - 3])).abs() } }) / (if (ShadowVeryShort_rangeType) == 2 { 2.0 } else { 1.0 })) && // 1st: marubozu
               (inHigh[i - 3] - (if inClose[i - 3] >= inOpen[i - 3] { inClose[i - 3] } else { inOpen[i - 3] })) < ((ShadowVeryShort_factor) * (if (ShadowVeryShort_avgPeriod) != 0 { (ShadowVeryShortPeriodTotal[3]) / (ShadowVeryShort_avgPeriod as f64) } else { match ShadowVeryShort_rangeType { 0 => (inClose[i - 3] - inOpen[i - 3]).abs(), 1 => (inHigh[i - 3]) - (inLow[i - 3]), _ => (inHigh[i - 3]) - (inLow[i - 3]) - ((inClose[i - 3]) - (inOpen[i - 3])).abs() } }) / (if (ShadowVeryShort_rangeType) == 2 { 2.0 } else { 1.0 })) &&
               ((if inClose[i - 2] >= inOpen[i - 2] { inOpen[i - 2] } else { inClose[i - 2] }) - inLow[i - 2]) < ((ShadowVeryShort_factor) * (if (ShadowVeryShort_avgPeriod) != 0 { (ShadowVeryShortPeriodTotal[2]) / (ShadowVeryShort_avgPeriod as f64) } else { match ShadowVeryShort_rangeType { 0 => (inClose[i - 2] - inOpen[i - 2]).abs(), 1 => (inHigh[i - 2]) - (inLow[i - 2]), _ => (inHigh[i - 2]) - (inLow[i - 2]) - ((inClose[i - 2]) - (inOpen[i - 2])).abs() } }) / (if (ShadowVeryShort_rangeType) == 2 { 2.0 } else { 1.0 })) && // 2nd: marubozu
               (inHigh[i - 2] - (if inClose[i - 2] >= inOpen[i - 2] { inClose[i - 2] } else { inOpen[i - 2] })) < ((ShadowVeryShort_factor) * (if (ShadowVeryShort_avgPeriod) != 0 { (ShadowVeryShortPeriodTotal[2]) / (ShadowVeryShort_avgPeriod as f64) } else { match ShadowVeryShort_rangeType { 0 => (inClose[i - 2] - inOpen[i - 2]).abs(), 1 => (inHigh[i - 2]) - (inLow[i - 2]), _ => (inHigh[i - 2]) - (inLow[i - 2]) - ((inClose[i - 2]) - (inOpen[i - 2])).abs() } }) / (if (ShadowVeryShort_rangeType) == 2 { 2.0 } else { 1.0 })) &&
               ((if (inOpen[i - 1]).max(inClose[i - 1]) < (inOpen[i - 2]).min(inClose[i - 2]) { 1 } else { 0 }) != 0) && // 3rd: opens gapping down
               (inHigh[i - 1] - (if inClose[i - 1] >= inOpen[i - 1] { inClose[i - 1] } else { inOpen[i - 1] })) > ((ShadowVeryShort_factor) * (if (ShadowVeryShort_avgPeriod) != 0 { (ShadowVeryShortPeriodTotal[1]) / (ShadowVeryShort_avgPeriod as f64) } else { match ShadowVeryShort_rangeType { 0 => (inClose[i - 1] - inOpen[i - 1]).abs(), 1 => (inHigh[i - 1]) - (inLow[i - 1]), _ => (inHigh[i - 1]) - (inLow[i - 1]) - ((inClose[i - 1]) - (inOpen[i - 1])).abs() } }) / (if (ShadowVeryShort_rangeType) == 2 { 2.0 } else { 1.0 })) && // and HAS an upper shadow
               inHigh[i - 1] > inClose[i - 2] &&                                      // that extends into the prior body
               inHigh[i] > inHigh[i - 1] &&
               inLow[i] < inLow[i - 1]                                                // 4th: engulfs the 3rd including the shadows
            {
                outInteger[outIdx] = 100;
                outIdx += 1;
            } else {
                outInteger[outIdx] = 0;
                outIdx += 1;
            }
            // add the current range and subtract the first range: this is done after the pattern recognition
            // when avgPeriod is not 0, that means "compare with the previous candles" (it excludes the current candle)
            // for( totIdx = 3; totIdx >= 1; totIdx -= 1 )
            totIdx = 3;
            loop {
                let mut _candlerange_3: f64;
                match ShadowVeryShort_rangeType {
                    0 => {
                        _candlerange_3 = (inClose[i - totIdx] - inOpen[i - totIdx]).abs();
                    }
                    1 => {
                        _candlerange_3 = inHigh[i - totIdx] - inLow[i - totIdx];
                    }
                    2 => {
                        _candlerange_3 = inHigh[i - totIdx] - inLow[i - totIdx] - (inClose[i - totIdx] - inOpen[i - totIdx]).abs();
                    }
                    _ => {
                        _candlerange_3 = 0.0;
                    }
                }
                let mut _candlerange_4: f64;
                match ShadowVeryShort_rangeType {
                    0 => {
                        _candlerange_4 = (inClose[ShadowVeryShortTrailingIdx - totIdx] - inOpen[ShadowVeryShortTrailingIdx - totIdx]).abs();
                    }
                    1 => {
                        _candlerange_4 = inHigh[ShadowVeryShortTrailingIdx - totIdx] - inLow[ShadowVeryShortTrailingIdx - totIdx];
                    }
                    2 => {
                        _candlerange_4 = inHigh[ShadowVeryShortTrailingIdx - totIdx] - inLow[ShadowVeryShortTrailingIdx - totIdx] - (inClose[ShadowVeryShortTrailingIdx - totIdx] - inOpen[ShadowVeryShortTrailingIdx - totIdx]).abs();
                    }
                    _ => {
                        _candlerange_4 = 0.0;
                    }
                }
                ShadowVeryShortPeriodTotal[totIdx] = ShadowVeryShortPeriodTotal[totIdx] + (_candlerange_3 - _candlerange_4);
                if totIdx == 1 { break; }
                totIdx -= 1;
            }
            i += 1;
            ShadowVeryShortTrailingIdx += 1;
            if !(i <= endIdx) { break; }
        }
        // All done. Indicate the output limits and return.
        (*outNBElement) = outIdx;
        (*outBegIdx) = startIdx;
        return RetCode::Success;
    }
    /// Unchecked variant of [`Core::cdlconcealbabyswall`], used for internal cross-indicator calls.
    ///
    /// Skips parameter validation and uses unchecked indexing internally. Every argument must
    /// satisfy the constraints documented on [`Core::cdlconcealbabyswall`]; an out-of-range
    /// parameter, an input slice not covering `startIdx..=endIdx`, or an undersized output slice
    /// may panic or cause undefined behavior. Prefer [`Core::cdlconcealbabyswall`].
    #[inline]
    pub fn cdlconcealbabyswall_unguarded(
        &self,
        mut startIdx: usize,
        endIdx: usize,
        inOpen: &[f64],
        inHigh: &[f64],
        inLow: &[f64],
        inClose: &[f64],
        outBegIdx: &mut usize,
        outNBElement: &mut usize,
        outInteger: &mut [i32],
    ) -> RetCode {
        let mut ShadowVeryShortPeriodTotal: [f64; 4 as usize] = [0.0_f64; 4 as usize];
        let mut i: usize = 0_usize;
        let mut outIdx: usize = 0_usize;
        let mut totIdx: usize = 0_usize;
        let mut ShadowVeryShortTrailingIdx: usize = 0_usize;
        let mut lookbackTotal: usize = 0_usize;
        #[allow(non_snake_case)]
        let ShadowVeryShort_rangeType: i32 = self.candle_settings.shadow_very_short.range_type;
        #[allow(non_snake_case)]
        let ShadowVeryShort_avgPeriod: i32 = self.candle_settings.shadow_very_short.avg_period;
        #[allow(non_snake_case)]
        let ShadowVeryShort_factor: f64 = self.candle_settings.shadow_very_short.factor;
        unsafe {
        assert!(endIdx < inOpen.len());
        assert!(endIdx < inHigh.len());
        assert!(endIdx < inLow.len());
        assert!(endIdx < inClose.len());
        let _assertLb = self.cdlconcealbabyswall_lookback();
        let _assertStart = if startIdx > _assertLb { startIdx } else { _assertLb };
        assert!(_assertStart > endIdx || endIdx - _assertStart < outInteger.len());
        lookbackTotal = self.cdlconcealbabyswall_lookback();
        if startIdx < lookbackTotal {
            startIdx = lookbackTotal;
        }
        if startIdx > endIdx {
            (*outBegIdx) = 0;
            (*outNBElement) = 0;
            return RetCode::Success;
        }
        *ShadowVeryShortPeriodTotal.as_mut_ptr().add(3) = 0.0;
        *ShadowVeryShortPeriodTotal.as_mut_ptr().add(2) = 0.0;
        *ShadowVeryShortPeriodTotal.as_mut_ptr().add(1) = 0.0;
        ShadowVeryShortTrailingIdx = startIdx - (ShadowVeryShort_avgPeriod) as usize;
        i = ShadowVeryShortTrailingIdx;
        while i < startIdx {
            let mut _candlerange_0: f64;
            match ShadowVeryShort_rangeType {
                0 => {
                    _candlerange_0 = (*inClose.as_ptr().add(i - 3) - *inOpen.as_ptr().add(i - 3)).abs();
                }
                1 => {
                    _candlerange_0 = *inHigh.as_ptr().add(i - 3) - *inLow.as_ptr().add(i - 3);
                }
                2 => {
                    _candlerange_0 = *inHigh.as_ptr().add(i - 3) - *inLow.as_ptr().add(i - 3) - (*inClose.as_ptr().add(i - 3) - *inOpen.as_ptr().add(i - 3)).abs();
                }
                _ => {
                    _candlerange_0 = 0.0;
                }
            }
            *ShadowVeryShortPeriodTotal.as_mut_ptr().add(3) = *ShadowVeryShortPeriodTotal.as_ptr().add(3) + _candlerange_0;
            let mut _candlerange_1: f64;
            match ShadowVeryShort_rangeType {
                0 => {
                    _candlerange_1 = (*inClose.as_ptr().add(i - 2) - *inOpen.as_ptr().add(i - 2)).abs();
                }
                1 => {
                    _candlerange_1 = *inHigh.as_ptr().add(i - 2) - *inLow.as_ptr().add(i - 2);
                }
                2 => {
                    _candlerange_1 = *inHigh.as_ptr().add(i - 2) - *inLow.as_ptr().add(i - 2) - (*inClose.as_ptr().add(i - 2) - *inOpen.as_ptr().add(i - 2)).abs();
                }
                _ => {
                    _candlerange_1 = 0.0;
                }
            }
            *ShadowVeryShortPeriodTotal.as_mut_ptr().add(2) = *ShadowVeryShortPeriodTotal.as_ptr().add(2) + _candlerange_1;
            let mut _candlerange_2: f64;
            match ShadowVeryShort_rangeType {
                0 => {
                    _candlerange_2 = (*inClose.as_ptr().add(i - 1) - *inOpen.as_ptr().add(i - 1)).abs();
                }
                1 => {
                    _candlerange_2 = *inHigh.as_ptr().add(i - 1) - *inLow.as_ptr().add(i - 1);
                }
                2 => {
                    _candlerange_2 = *inHigh.as_ptr().add(i - 1) - *inLow.as_ptr().add(i - 1) - (*inClose.as_ptr().add(i - 1) - *inOpen.as_ptr().add(i - 1)).abs();
                }
                _ => {
                    _candlerange_2 = 0.0;
                }
            }
            *ShadowVeryShortPeriodTotal.as_mut_ptr().add(1) = *ShadowVeryShortPeriodTotal.as_ptr().add(1) + _candlerange_2;
            i += 1;
        }
        i = startIdx;
        outIdx = 0;
        loop {
            if ((if *inClose.as_ptr().add(i - 3) >= *inOpen.as_ptr().add(i - 3) { 1 } else { 0 - 1 })) as i32 == 0 - 1 && ((if *inClose.as_ptr().add(i - 2) >= *inOpen.as_ptr().add(i - 2) { 1 } else { 0 - 1 })) as i32 == 0 - 1 && ((if *inClose.as_ptr().add(i - 1) >= *inOpen.as_ptr().add(i - 1) { 1 } else { 0 - 1 })) as i32 == 0 - 1 && ((if *inClose.as_ptr().add(i) >= *inOpen.as_ptr().add(i) { 1 } else { 0 - 1 })) as i32 == 0 - 1 && ((if *inClose.as_ptr().add(i - 3) >= *inOpen.as_ptr().add(i - 3) { *inOpen.as_ptr().add(i - 3) } else { *inClose.as_ptr().add(i - 3) }) - *inLow.as_ptr().add(i - 3)) < ((ShadowVeryShort_factor) * (if (ShadowVeryShort_avgPeriod) != 0 { (*ShadowVeryShortPeriodTotal.as_ptr().add(3)) / (ShadowVeryShort_avgPeriod as f64) } else { match ShadowVeryShort_rangeType { 0 => (*inClose.as_ptr().add(i - 3) - *inOpen.as_ptr().add(i - 3)).abs(), 1 => (*inHigh.as_ptr().add(i - 3)) - (*inLow.as_ptr().add(i - 3)), _ => (*inHigh.as_ptr().add(i - 3)) - (*inLow.as_ptr().add(i - 3)) - ((*inClose.as_ptr().add(i - 3)) - (*inOpen.as_ptr().add(i - 3))).abs() } }) / (if (ShadowVeryShort_rangeType) == 2 { 2.0 } else { 1.0 })) && (*inHigh.as_ptr().add(i - 3) - (if *inClose.as_ptr().add(i - 3) >= *inOpen.as_ptr().add(i - 3) { *inClose.as_ptr().add(i - 3) } else { *inOpen.as_ptr().add(i - 3) })) < ((ShadowVeryShort_factor) * (if (ShadowVeryShort_avgPeriod) != 0 { (*ShadowVeryShortPeriodTotal.as_ptr().add(3)) / (ShadowVeryShort_avgPeriod as f64) } else { match ShadowVeryShort_rangeType { 0 => (*inClose.as_ptr().add(i - 3) - *inOpen.as_ptr().add(i - 3)).abs(), 1 => (*inHigh.as_ptr().add(i - 3)) - (*inLow.as_ptr().add(i - 3)), _ => (*inHigh.as_ptr().add(i - 3)) - (*inLow.as_ptr().add(i - 3)) - ((*inClose.as_ptr().add(i - 3)) - (*inOpen.as_ptr().add(i - 3))).abs() } }) / (if (ShadowVeryShort_rangeType) == 2 { 2.0 } else { 1.0 })) && ((if *inClose.as_ptr().add(i - 2) >= *inOpen.as_ptr().add(i - 2) { *inOpen.as_ptr().add(i - 2) } else { *inClose.as_ptr().add(i - 2) }) - *inLow.as_ptr().add(i - 2)) < ((ShadowVeryShort_factor) * (if (ShadowVeryShort_avgPeriod) != 0 { (*ShadowVeryShortPeriodTotal.as_ptr().add(2)) / (ShadowVeryShort_avgPeriod as f64) } else { match ShadowVeryShort_rangeType { 0 => (*inClose.as_ptr().add(i - 2) - *inOpen.as_ptr().add(i - 2)).abs(), 1 => (*inHigh.as_ptr().add(i - 2)) - (*inLow.as_ptr().add(i - 2)), _ => (*inHigh.as_ptr().add(i - 2)) - (*inLow.as_ptr().add(i - 2)) - ((*inClose.as_ptr().add(i - 2)) - (*inOpen.as_ptr().add(i - 2))).abs() } }) / (if (ShadowVeryShort_rangeType) == 2 { 2.0 } else { 1.0 })) && (*inHigh.as_ptr().add(i - 2) - (if *inClose.as_ptr().add(i - 2) >= *inOpen.as_ptr().add(i - 2) { *inClose.as_ptr().add(i - 2) } else { *inOpen.as_ptr().add(i - 2) })) < ((ShadowVeryShort_factor) * (if (ShadowVeryShort_avgPeriod) != 0 { (*ShadowVeryShortPeriodTotal.as_ptr().add(2)) / (ShadowVeryShort_avgPeriod as f64) } else { match ShadowVeryShort_rangeType { 0 => (*inClose.as_ptr().add(i - 2) - *inOpen.as_ptr().add(i - 2)).abs(), 1 => (*inHigh.as_ptr().add(i - 2)) - (*inLow.as_ptr().add(i - 2)), _ => (*inHigh.as_ptr().add(i - 2)) - (*inLow.as_ptr().add(i - 2)) - ((*inClose.as_ptr().add(i - 2)) - (*inOpen.as_ptr().add(i - 2))).abs() } }) / (if (ShadowVeryShort_rangeType) == 2 { 2.0 } else { 1.0 })) && ((if (*inOpen.as_ptr().add(i - 1)).max(*inClose.as_ptr().add(i - 1)) < (*inOpen.as_ptr().add(i - 2)).min(*inClose.as_ptr().add(i - 2)) { 1 } else { 0 }) != 0) && (*inHigh.as_ptr().add(i - 1) - (if *inClose.as_ptr().add(i - 1) >= *inOpen.as_ptr().add(i - 1) { *inClose.as_ptr().add(i - 1) } else { *inOpen.as_ptr().add(i - 1) })) > ((ShadowVeryShort_factor) * (if (ShadowVeryShort_avgPeriod) != 0 { (*ShadowVeryShortPeriodTotal.as_ptr().add(1)) / (ShadowVeryShort_avgPeriod as f64) } else { match ShadowVeryShort_rangeType { 0 => (*inClose.as_ptr().add(i - 1) - *inOpen.as_ptr().add(i - 1)).abs(), 1 => (*inHigh.as_ptr().add(i - 1)) - (*inLow.as_ptr().add(i - 1)), _ => (*inHigh.as_ptr().add(i - 1)) - (*inLow.as_ptr().add(i - 1)) - ((*inClose.as_ptr().add(i - 1)) - (*inOpen.as_ptr().add(i - 1))).abs() } }) / (if (ShadowVeryShort_rangeType) == 2 { 2.0 } else { 1.0 })) && *inHigh.as_ptr().add(i - 1) > *inClose.as_ptr().add(i - 2) && *inHigh.as_ptr().add(i) > *inHigh.as_ptr().add(i - 1) && *inLow.as_ptr().add(i) < *inLow.as_ptr().add(i - 1) {
                *outInteger.as_mut_ptr().add(outIdx) = 100;
                outIdx += 1;
            } else {
                *outInteger.as_mut_ptr().add(outIdx) = 0;
                outIdx += 1;
            }
            // for( totIdx = 3; totIdx >= 1; totIdx -= 1 )
            totIdx = 3;
            loop {
                let mut _candlerange_3: f64;
                match ShadowVeryShort_rangeType {
                    0 => {
                        _candlerange_3 = (*inClose.as_ptr().add(i - totIdx) - *inOpen.as_ptr().add(i - totIdx)).abs();
                    }
                    1 => {
                        _candlerange_3 = *inHigh.as_ptr().add(i - totIdx) - *inLow.as_ptr().add(i - totIdx);
                    }
                    2 => {
                        _candlerange_3 = *inHigh.as_ptr().add(i - totIdx) - *inLow.as_ptr().add(i - totIdx) - (*inClose.as_ptr().add(i - totIdx) - *inOpen.as_ptr().add(i - totIdx)).abs();
                    }
                    _ => {
                        _candlerange_3 = 0.0;
                    }
                }
                let mut _candlerange_4: f64;
                match ShadowVeryShort_rangeType {
                    0 => {
                        _candlerange_4 = (*inClose.as_ptr().add(ShadowVeryShortTrailingIdx - totIdx) - *inOpen.as_ptr().add(ShadowVeryShortTrailingIdx - totIdx)).abs();
                    }
                    1 => {
                        _candlerange_4 = *inHigh.as_ptr().add(ShadowVeryShortTrailingIdx - totIdx) - *inLow.as_ptr().add(ShadowVeryShortTrailingIdx - totIdx);
                    }
                    2 => {
                        _candlerange_4 = *inHigh.as_ptr().add(ShadowVeryShortTrailingIdx - totIdx) - *inLow.as_ptr().add(ShadowVeryShortTrailingIdx - totIdx) - (*inClose.as_ptr().add(ShadowVeryShortTrailingIdx - totIdx) - *inOpen.as_ptr().add(ShadowVeryShortTrailingIdx - totIdx)).abs();
                    }
                    _ => {
                        _candlerange_4 = 0.0;
                    }
                }
                *ShadowVeryShortPeriodTotal.as_mut_ptr().add(totIdx) = *ShadowVeryShortPeriodTotal.as_ptr().add(totIdx) + (_candlerange_3 - _candlerange_4);
                if totIdx == 1 { break; }
                totIdx -= 1;
            }
            i += 1;
            ShadowVeryShortTrailingIdx += 1;
            if !(i <= endIdx) { break; }
        }
        (*outNBElement) = outIdx;
        (*outBegIdx) = startIdx;
        return RetCode::Success;
        } // unsafe
    }
}
/***************/
/* End of File */
/***************/
