GeneratorBeta
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Mutik159

//@version=5

// @description [SNG_BETA] Levels Generating Library
library("GeneratorBeta")

import Mutik159/TypesBeta/1
// ****************************************************** //
// ******************** FUNCTIONS ***********************
// ****************************************************** //

// @function Generating daily / weekly / monthly levels
export horizontals(array<TypesBeta.Level> levelsArray, float _open, float _close, float _extendLow, float _extendHigh, int _confluenceScore, string _name) =>
	// Candle two ticks away is red, next is green - bottom formed | candle two ticks away is green, next is red - top formed
	if (((_close[2] < _open[2]) and _close[1] > _open[1]) or ((_close[2] > _open[2]) and _close[1] < _open[1]))
		array.push(levelsArray, TypesBeta.Level.new(_open[1] - _extendLow, _open[1] + _extendHigh, _confluenceScore, _name))

// @function Generating previous low levels
export previous_low(array<TypesBeta.Level> levelsArray, series float _low, float _extendLow, float _extendHigh, int _confluenceScore, string _name, int _barIndex = 0, int _barExpiration = 0, string _timeframe = "") =>
	array.push(levelsArray, TypesBeta.Level.new(_low[0] - _extendLow, _low[0] + _extendHigh, _confluenceScore, _name, _barIndex, _barExpiration, _timeframe))

// @function Generating previous high levels
export previous_high(array<TypesBeta.Level> levelsArray, series float _high, float _extendLow, float _extendHigh, int _confluenceScore, string _name, int _barIndex = 0, int _barExpiration = 0, string _timeframe = "") =>
	array.push(levelsArray, TypesBeta.Level.new(_high[0] - _extendLow, _high[0] + _extendHigh, _confluenceScore, _name, _barIndex, _barExpiration, _timeframe))

// @function Generating previous open levels
export previous_open(array<TypesBeta.Level> levelsArray, series float _open, float _extendLow, float _extendHigh, int _confluenceScore, string _name, int _barIndex = 0, int _barExpiration = 0, string _timeframe = "") =>
	array.push(levelsArray, TypesBeta.Level.new(_open[0] - _extendLow, _open[0] + _extendHigh, _confluenceScore, _name, _barIndex, _barExpiration, _timeframe))

// @function Generating previous eq levels
export previous_eq(array<TypesBeta.Level> levelsArray, series float _low, float _high, float _extendLow, float _extendHigh, int _confluenceScore, string _name, int _barIndex = 0, int _barExpiration = 0, string _timeframe = "") =>
	array.push(levelsArray, TypesBeta.Level.new((_high[0] + _low[0]) / 2 - _extendLow, (_high[0] + _low[0]) / 2 + _extendHigh, _confluenceScore, _name, _barIndex, _barExpiration, _timeframe))

// @function Generating VWAP close levels
export vwap_close(array<TypesBeta.Level> levelsArray, float _vwapPrice, float _extendLow, float _extendHigh, int _confluenceScore, string _name) =>
	array.push(levelsArray, TypesBeta.Level.new(_vwapPrice - _extendLow, _vwapPrice + _extendHigh, _confluenceScore, _name))