769 lines
18 KiB
Plaintext
769 lines
18 KiB
Plaintext
//////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Indicator
|
|
// --------------------------------------
|
|
// Name: X121_XFBB
|
|
// Description: Fibonacci Band ...
|
|
//
|
|
//
|
|
// Maintainer:
|
|
// ------------
|
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
//
|
|
//////////////////////////////////////////////////////
|
|
//
|
|
// Global Properties ...
|
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
|
#property link "https://saherelm.ir"
|
|
#property version "1.00"
|
|
#property description "SaherElm X121_XFBB Indicator"
|
|
#property strict
|
|
|
|
//
|
|
// START Constants ...
|
|
//
|
|
|
|
//
|
|
// Indicator Short Name ...
|
|
#define ShortName "X121_XFBB"
|
|
|
|
//
|
|
// END Constants ...
|
|
//
|
|
|
|
//
|
|
// START Inputs ...
|
|
//
|
|
|
|
//
|
|
// Market ...
|
|
input group "Market";
|
|
input int length = 200; // Length
|
|
input double multiplier = 3.0; // Multiplier
|
|
input ENUM_APPLIED_PRICE appliedTo = PRICE_TYPICAL; // Applied To
|
|
|
|
//
|
|
// Presentation ...
|
|
input group "Presentation";
|
|
input bool showBase = true; // Show Base
|
|
input bool showBand = true; // Show Band
|
|
input bool showGoldenArea = true; // Show Golden Area
|
|
input bool showOthers = false; // Show Other Levels
|
|
|
|
//
|
|
// END Inputs ...
|
|
//
|
|
|
|
//
|
|
// START Includes and Imports ...
|
|
//
|
|
|
|
//
|
|
// Includes Common Library ...
|
|
#include "../Libraries/x-saherelm.common.lib.mq5"
|
|
|
|
//
|
|
// END Includes and Imports ...
|
|
//
|
|
|
|
//
|
|
// START Buffers ...
|
|
//
|
|
|
|
//
|
|
#property indicator_chart_window
|
|
|
|
//
|
|
#property indicator_buffers 28
|
|
#property indicator_plots 26
|
|
|
|
//
|
|
// PLOTTED Buffers ...
|
|
|
|
//
|
|
#define baseBufferIndex 0
|
|
#define basePlotBufferIndex 0
|
|
double baseBuffer[];
|
|
|
|
//
|
|
#property indicator_label1 "X121_XFBB Base"
|
|
#property indicator_type1 DRAW_COLOR_LINE
|
|
#property indicator_color1 CLR_NONE, clrDarkGray, clrDeepPink, clrMediumSeaGreen
|
|
#property indicator_style1 STYLE_DOT
|
|
|
|
#define baseColorBufferIndex 1
|
|
double baseColorBuffer[];
|
|
|
|
//
|
|
#define upL1BufferIndex 2
|
|
#define upL1PlotBufferIndex 1
|
|
double upL1Buffer[];
|
|
|
|
//
|
|
#property indicator_label2 "X121_XFBB UF 1"
|
|
#property indicator_type2 DRAW_COLOR_LINE
|
|
#property indicator_color2 CLR_NONE, clrDarkGray
|
|
#property indicator_style2 STYLE_DOT
|
|
|
|
#define upL1ColorBufferIndex 3
|
|
double upL1ColorBuffer[];
|
|
|
|
//
|
|
#define upL2BufferIndex 4
|
|
#define upL2PlotBufferIndex 2
|
|
double upL2Buffer[];
|
|
|
|
#define upL2ColorBufferIndex 5
|
|
double upL2ColorBuffer[];
|
|
|
|
//
|
|
#property indicator_label3 "X121_XFBB UF 2"
|
|
#property indicator_type3 DRAW_COLOR_LINE
|
|
#property indicator_color3 CLR_NONE, clrDarkGray
|
|
#property indicator_style3 STYLE_DOT
|
|
|
|
//
|
|
#define upL3BufferIndex 6
|
|
#define upL3PlotBufferIndex 3
|
|
double upL3Buffer[];
|
|
|
|
#define upL3ColorBufferIndex 7
|
|
double upL3ColorBuffer[];
|
|
|
|
//
|
|
#property indicator_label4 "X121_XFBB UF 3"
|
|
#property indicator_type4 DRAW_COLOR_LINE
|
|
#property indicator_color4 CLR_NONE, clrGold
|
|
#property indicator_style4 STYLE_DOT
|
|
|
|
//
|
|
#define upL4BufferIndex 8
|
|
#define upL4PlotBufferIndex 4
|
|
double upL4Buffer[];
|
|
|
|
#define upL4ColorBufferIndex 9
|
|
double upL4ColorBuffer[];
|
|
|
|
//
|
|
#property indicator_label5 "X121_XFBB UF 4"
|
|
#property indicator_type5 DRAW_COLOR_LINE
|
|
#property indicator_color5 CLR_NONE, clrGold
|
|
#property indicator_style5 STYLE_DOT
|
|
|
|
//
|
|
#define upL5BufferIndex 10
|
|
#define upL5PlotBufferIndex 5
|
|
double upL5Buffer[];
|
|
|
|
#define upL5ColorBufferIndex 11
|
|
double upL5ColorBuffer[];
|
|
|
|
//
|
|
#property indicator_label6 "X121_XFBB UF 5"
|
|
#property indicator_type6 DRAW_COLOR_LINE
|
|
#property indicator_color6 CLR_NONE, clrDarkGray
|
|
#property indicator_style6 STYLE_DOT
|
|
|
|
//
|
|
#define upL6BufferIndex 12
|
|
#define upL6PlotBufferIndex 6
|
|
double upL6Buffer[];
|
|
|
|
#define upL6ColorBufferIndex 13
|
|
double upL6ColorBuffer[];
|
|
|
|
//
|
|
#property indicator_label7 "X121_XFBB UF 6"
|
|
#property indicator_type7 DRAW_COLOR_LINE
|
|
#property indicator_color7 CLR_NONE, clrRed
|
|
#property indicator_style7 STYLE_DOT
|
|
|
|
//
|
|
// DOWN ...
|
|
|
|
//
|
|
#define downL1BufferIndex 14
|
|
#define downL1PlotBufferIndex 7
|
|
double downL1Buffer[];
|
|
|
|
#define downL1ColorBufferIndex 15
|
|
double downL1ColorBuffer[];
|
|
|
|
//
|
|
#property indicator_label8 "X121_XFBB UD 1"
|
|
#property indicator_type8 DRAW_COLOR_LINE
|
|
#property indicator_color8 CLR_NONE, clrDarkGray
|
|
#property indicator_style8 STYLE_DOT
|
|
|
|
//
|
|
#define downL2BufferIndex 16
|
|
#define downL2PlotBufferIndex 8
|
|
double downL2Buffer[];
|
|
|
|
#define downL2ColorBufferIndex 17
|
|
double downL2ColorBuffer[];
|
|
|
|
//
|
|
#property indicator_label9 "X121_XFBB UD 2"
|
|
#property indicator_type9 DRAW_COLOR_LINE
|
|
#property indicator_color9 CLR_NONE, clrDarkGray
|
|
#property indicator_style9 STYLE_DOT
|
|
|
|
//
|
|
#define downL3BufferIndex 18
|
|
#define downL3PlotBufferIndex 9
|
|
double downL3Buffer[];
|
|
|
|
#define downL3ColorBufferIndex 19
|
|
double downL3ColorBuffer[];
|
|
|
|
//
|
|
#property indicator_label10 "X121_XFBB UD 3"
|
|
#property indicator_type10 DRAW_COLOR_LINE
|
|
#property indicator_color10 CLR_NONE, clrGold
|
|
#property indicator_style10 STYLE_DOT
|
|
|
|
//
|
|
#define downL4BufferIndex 20
|
|
#define downL4PlotBufferIndex 10
|
|
double downL4Buffer[];
|
|
|
|
#define downL4ColorBufferIndex 21
|
|
double downL4ColorBuffer[];
|
|
|
|
//
|
|
#property indicator_label11 "X121_XFBB UD 4"
|
|
#property indicator_type11 DRAW_COLOR_LINE
|
|
#property indicator_color11 CLR_NONE, clrGold
|
|
#property indicator_style11 STYLE_DOT
|
|
|
|
//
|
|
#define downL5BufferIndex 22
|
|
#define downL5PlotBufferIndex 11
|
|
double downL5Buffer[];
|
|
|
|
#define downL5ColorBufferIndex 23
|
|
double downL5ColorBuffer[];
|
|
|
|
//
|
|
#property indicator_label12 "X121_XFBB UD 5"
|
|
#property indicator_type12 DRAW_COLOR_LINE
|
|
#property indicator_color12 CLR_NONE, clrDarkGray
|
|
#property indicator_style12 STYLE_DOT
|
|
|
|
//
|
|
#define downL6BufferIndex 24
|
|
#define downL6PlotBufferIndex 12
|
|
double downL6Buffer[];
|
|
|
|
#define downL6ColorBufferIndex 25
|
|
double downL6ColorBuffer[];
|
|
|
|
//
|
|
#property indicator_label13 "X121_XFBB UD 6"
|
|
#property indicator_type13 DRAW_COLOR_LINE
|
|
#property indicator_color13 CLR_NONE, clrRed
|
|
#property indicator_style13 STYLE_DOT
|
|
|
|
//
|
|
// DATA BUffers ...
|
|
|
|
//
|
|
#define stdDevBufferIndex 26
|
|
double stdDevBuffer[];
|
|
|
|
//
|
|
#define vwmaBufferIndex 27
|
|
double vwmaBuffer[];
|
|
|
|
//
|
|
// END Buffers ...
|
|
//
|
|
|
|
//
|
|
// START Global Definitions: Variables, Properties and etc ...
|
|
//
|
|
|
|
//
|
|
int maxLength;
|
|
|
|
//
|
|
int mSTDevHandler = INVALID_HANDLE;
|
|
|
|
//
|
|
// END Global Definitions: Variables, Properties and etc ...
|
|
//
|
|
|
|
//
|
|
// START Event Handlers ...
|
|
//
|
|
|
|
//
|
|
// Initialization ...
|
|
int OnInit()
|
|
{
|
|
//
|
|
// Validate Inputs ...
|
|
if (!ValidateInputs())
|
|
{
|
|
return INIT_PARAMETERS_INCORRECT;
|
|
}
|
|
|
|
//
|
|
// because in some cases we may have more than one input for
|
|
// calculation and we must prevent any calculation
|
|
// untill we pass the biggest input length, here we get max Input length
|
|
// and then wait until pass it ...
|
|
maxLength = ExtractMaxLengthOfInputs();
|
|
|
|
//
|
|
// Define Index Buffers ...
|
|
DefineBuffers();
|
|
|
|
//
|
|
// Set Indicator ShortName ...
|
|
SetIndicatorName();
|
|
|
|
//
|
|
// Initialize Handlers ...
|
|
mSTDevHandler = iStdDev(
|
|
_Symbol,
|
|
_Period,
|
|
length,
|
|
0,
|
|
MODE_SMA,
|
|
appliedTo);
|
|
if (mSTDevHandler == INVALID_HANDLE)
|
|
{
|
|
return INIT_FAILED;
|
|
}
|
|
|
|
//
|
|
// Init Succeed ...
|
|
return INIT_SUCCEEDED;
|
|
}
|
|
|
|
//
|
|
// DeInitialization ...
|
|
void OnDeinit(const int reason)
|
|
{
|
|
//
|
|
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
|
|
// REASON_REMOVE 1 Program removed from a chart
|
|
// REASON_RECOMPILE 2 Program recompiled
|
|
// REASON_CHARTCHANGE 3 A symbol or a chart period is changed
|
|
// REASON_CHARTCLOSE 4 Chart closed
|
|
// REASON_PARAMETERS 5 Inputs changed by a user
|
|
// REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings
|
|
// REASON_TEMPLATE 7 Another chart template applied
|
|
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
|
|
// REASON_CLOSE 9 Terminal closed
|
|
|
|
//
|
|
// Here we can handle De Initialization Reasons ...
|
|
|
|
//
|
|
IndicatorRelease(mSTDevHandler);
|
|
}
|
|
|
|
//
|
|
// Calculating what we want ...
|
|
int OnCalculate(
|
|
//
|
|
// total Candles on chart ...
|
|
const int rates_total,
|
|
//
|
|
// total calculated Candles on charts ...
|
|
const int prev_calculated,
|
|
//
|
|
// history of Candles Open Time ...
|
|
const datetime &time[],
|
|
//
|
|
// history of Candles Open Price ...
|
|
const double &open[],
|
|
//
|
|
// history of Candles High Price ...
|
|
const double &high[],
|
|
//
|
|
// history of Candles Low Price ...
|
|
const double &low[],
|
|
//
|
|
// history of Candles Close Price ...
|
|
const double &close[],
|
|
//
|
|
// history of Tick Volumes on Candle ...
|
|
const long &tick_volume[],
|
|
//
|
|
// history of Trade Volumes ...
|
|
const long &volume[],
|
|
//
|
|
// history of Candles Spread Price ...
|
|
const int &spread[])
|
|
{
|
|
//
|
|
int i = (prev_calculated > 0 ? prev_calculated - 1 : 0);
|
|
for (i; i < rates_total && !IsStopped(); i++)
|
|
{
|
|
//
|
|
double price = GetAppliedPrice(
|
|
appliedTo,
|
|
open,
|
|
high,
|
|
low,
|
|
close,
|
|
i);
|
|
|
|
//
|
|
double vwma = iVWMA(price, volume[i], length, i, rates_total);
|
|
vwmaBuffer[i] = vwma;
|
|
baseBuffer[i] = vwma;
|
|
|
|
//
|
|
double baseColorIDX = (i > 0)
|
|
? (vwmaBuffer[i] > vwmaBuffer[i - 1])
|
|
? 3
|
|
: (vwmaBuffer[i] < vwmaBuffer[i - 1])
|
|
? 2
|
|
: baseColorBuffer[i - 1]
|
|
: 1;
|
|
|
|
//
|
|
if (showBase)
|
|
{
|
|
baseColorBuffer[i] = baseColorIDX;
|
|
}
|
|
else
|
|
{
|
|
baseColorBuffer[i] = 0;
|
|
}
|
|
}
|
|
|
|
//
|
|
// this counts Available Bars ...
|
|
int limit;
|
|
|
|
//
|
|
// Check Calculated Bars ...
|
|
//
|
|
int stdDevCalculatedBars = BarsCalculated(mSTDevHandler);
|
|
if (stdDevCalculatedBars < maxLength)
|
|
{
|
|
return prev_calculated;
|
|
}
|
|
|
|
//
|
|
limit = (prev_calculated > rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1;
|
|
|
|
//
|
|
// Buffers Copy ...
|
|
//
|
|
int copiedSTDDevs = CopyBuffer(mSTDevHandler, 0, 0, limit, stdDevBuffer);
|
|
if (copiedSTDDevs <= 0)
|
|
{
|
|
return prev_calculated;
|
|
}
|
|
|
|
//
|
|
// Main Loop ...
|
|
for (int i = limit - 1; i > 0 && !IsStopped(); i--)
|
|
{
|
|
CalculateBuffers(i);
|
|
}
|
|
|
|
//
|
|
return rates_total;
|
|
}
|
|
|
|
//
|
|
// END Event Handlers ...
|
|
//
|
|
|
|
//
|
|
// START Functions ...
|
|
//
|
|
|
|
//
|
|
// Validate Input Args for Initialization ...
|
|
bool ValidateInputs()
|
|
{
|
|
//
|
|
bool result =
|
|
//
|
|
(length >= 2 &&
|
|
multiplier > 0)
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve all Exists Input Max Length ...
|
|
// use for Start Of Drawing ...
|
|
int ExtractMaxLengthOfInputs()
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
result = MathMax(result, length);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Define Indexes and Styles ...
|
|
void DefineBuffers()
|
|
{
|
|
//
|
|
// PLOTTED ...
|
|
|
|
//
|
|
// BASE ...
|
|
// ArraySetAsSeries(baseBuffer, true);
|
|
// ArraySetAsSeries(baseColorBuffer, true);
|
|
SetIndexBuffer(baseBufferIndex, baseBuffer, INDICATOR_DATA);
|
|
PlotIndexSetInteger(basePlotBufferIndex, PLOT_SHOW_DATA, showBase);
|
|
SetIndexBuffer(baseColorBufferIndex, baseColorBuffer, INDICATOR_COLOR_INDEX);
|
|
|
|
//
|
|
// UP 1 ...
|
|
// ArraySetAsSeries(upL1Buffer, true);
|
|
// ArraySetAsSeries(upL1ColorBuffer, true);
|
|
SetIndexBuffer(upL1BufferIndex, upL1Buffer, INDICATOR_DATA);
|
|
PlotIndexSetInteger(upL1PlotBufferIndex, PLOT_SHOW_DATA, showOthers);
|
|
SetIndexBuffer(upL1ColorBufferIndex, upL1ColorBuffer, INDICATOR_COLOR_INDEX);
|
|
|
|
//
|
|
// UP 2 ...
|
|
// ArraySetAsSeries(upL2Buffer, true);
|
|
// ArraySetAsSeries(upL2ColorBuffer, true);
|
|
SetIndexBuffer(upL2BufferIndex, upL2Buffer, INDICATOR_DATA);
|
|
PlotIndexSetInteger(upL2PlotBufferIndex, PLOT_SHOW_DATA, showOthers);
|
|
SetIndexBuffer(upL2ColorBufferIndex, upL2ColorBuffer, INDICATOR_COLOR_INDEX);
|
|
|
|
//
|
|
// UP 3 ...
|
|
// ArraySetAsSeries(upL3Buffer, true);
|
|
// ArraySetAsSeries(upL3ColorBuffer, true);
|
|
SetIndexBuffer(upL3BufferIndex, upL3Buffer, INDICATOR_DATA);
|
|
PlotIndexSetInteger(upL3PlotBufferIndex, PLOT_SHOW_DATA, showGoldenArea);
|
|
SetIndexBuffer(upL3ColorBufferIndex, upL3ColorBuffer, INDICATOR_COLOR_INDEX);
|
|
|
|
//
|
|
// UP 4 ...
|
|
// ArraySetAsSeries(upL4Buffer, true);
|
|
// ArraySetAsSeries(upL4ColorBuffer, true);
|
|
SetIndexBuffer(upL4BufferIndex, upL4Buffer, INDICATOR_DATA);
|
|
PlotIndexSetInteger(upL4PlotBufferIndex, PLOT_SHOW_DATA, showGoldenArea);
|
|
SetIndexBuffer(upL4ColorBufferIndex, upL4ColorBuffer, INDICATOR_COLOR_INDEX);
|
|
|
|
//
|
|
// UP 5 ...
|
|
// ArraySetAsSeries(upL5Buffer, true);
|
|
// ArraySetAsSeries(upL5ColorBuffer, true);
|
|
SetIndexBuffer(upL5BufferIndex, upL5Buffer, INDICATOR_DATA);
|
|
PlotIndexSetInteger(upL5PlotBufferIndex, PLOT_SHOW_DATA, showOthers);
|
|
SetIndexBuffer(upL5ColorBufferIndex, upL5ColorBuffer, INDICATOR_COLOR_INDEX);
|
|
|
|
//
|
|
// UP 6 ...
|
|
// ArraySetAsSeries(upL6Buffer, true);
|
|
// ArraySetAsSeries(upL6ColorBuffer, true);
|
|
SetIndexBuffer(upL6BufferIndex, upL6Buffer, INDICATOR_DATA);
|
|
PlotIndexSetInteger(upL6PlotBufferIndex, PLOT_SHOW_DATA, showBand);
|
|
SetIndexBuffer(upL6ColorBufferIndex, upL6ColorBuffer, INDICATOR_COLOR_INDEX);
|
|
|
|
//
|
|
// DOWN 1 ...
|
|
// ArraySetAsSeries(downL1Buffer, true);
|
|
// ArraySetAsSeries(downL1ColorBuffer, true);
|
|
SetIndexBuffer(downL1BufferIndex, downL1Buffer, INDICATOR_DATA);
|
|
PlotIndexSetInteger(downL1PlotBufferIndex, PLOT_SHOW_DATA, showOthers);
|
|
SetIndexBuffer(downL1ColorBufferIndex, downL1ColorBuffer, INDICATOR_COLOR_INDEX);
|
|
|
|
//
|
|
// DOWN 2 ...
|
|
// ArraySetAsSeries(downL2Buffer, true);
|
|
// ArraySetAsSeries(downL2ColorBuffer, true);
|
|
SetIndexBuffer(downL2BufferIndex, downL2Buffer, INDICATOR_DATA);
|
|
PlotIndexSetInteger(downL2PlotBufferIndex, PLOT_SHOW_DATA, showOthers);
|
|
SetIndexBuffer(downL2ColorBufferIndex, downL2ColorBuffer, INDICATOR_COLOR_INDEX);
|
|
|
|
//
|
|
// DOWN 3 ...
|
|
// ArraySetAsSeries(downL3Buffer, true);
|
|
// ArraySetAsSeries(downL3ColorBuffer, true);
|
|
SetIndexBuffer(downL3BufferIndex, downL3Buffer, INDICATOR_DATA);
|
|
PlotIndexSetInteger(downL3PlotBufferIndex, PLOT_SHOW_DATA, showGoldenArea);
|
|
SetIndexBuffer(downL3ColorBufferIndex, downL3ColorBuffer, INDICATOR_COLOR_INDEX);
|
|
|
|
//
|
|
// DOWN 4 ...
|
|
// ArraySetAsSeries(downL4Buffer, true);
|
|
// ArraySetAsSeries(downL4ColorBuffer, true);
|
|
SetIndexBuffer(downL4BufferIndex, downL4Buffer, INDICATOR_DATA);
|
|
PlotIndexSetInteger(downL4PlotBufferIndex, PLOT_SHOW_DATA, showGoldenArea);
|
|
SetIndexBuffer(downL4ColorBufferIndex, downL4ColorBuffer, INDICATOR_COLOR_INDEX);
|
|
|
|
//
|
|
// DOWN 5 ...
|
|
// ArraySetAsSeries(downL5Buffer, true);
|
|
// ArraySetAsSeries(downL5ColorBuffer, true);
|
|
SetIndexBuffer(downL5BufferIndex, downL5Buffer, INDICATOR_DATA);
|
|
PlotIndexSetInteger(downL5PlotBufferIndex, PLOT_SHOW_DATA, showOthers);
|
|
SetIndexBuffer(downL5ColorBufferIndex, downL5ColorBuffer, INDICATOR_COLOR_INDEX);
|
|
|
|
//
|
|
// DOWN 6 ...
|
|
// ArraySetAsSeries(downL6Buffer, true);
|
|
// ArraySetAsSeries(downL6ColorBuffer, true);
|
|
SetIndexBuffer(downL6BufferIndex, downL6Buffer, INDICATOR_DATA);
|
|
PlotIndexSetInteger(downL6PlotBufferIndex, PLOT_SHOW_DATA, showBand);
|
|
SetIndexBuffer(downL6ColorBufferIndex, downL6ColorBuffer, INDICATOR_COLOR_INDEX);
|
|
|
|
//
|
|
// DATA ...
|
|
|
|
//
|
|
// ArraySetAsSeries(stdDevBuffer, true);
|
|
SetIndexBuffer(stdDevBufferIndex, stdDevBuffer, INDICATOR_CALCULATIONS);
|
|
|
|
//
|
|
// ArraySetAsSeries(vwmaBuffer, true);
|
|
SetIndexBuffer(vwmaBufferIndex, vwmaBuffer, INDICATOR_CALCULATIONS);
|
|
}
|
|
|
|
//
|
|
// Set Indicator Short Name and also we can define Buffers Labels ...
|
|
void SetIndicatorName()
|
|
{
|
|
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
|
|
}
|
|
|
|
//
|
|
// Calculate Buffers ...
|
|
void CalculateBuffers(
|
|
int bar_index // Selected Bar Index
|
|
)
|
|
{
|
|
//
|
|
double stdDev = stdDevBuffer[bar_index];
|
|
double dev = stdDev * multiplier;
|
|
|
|
//
|
|
double base = baseBuffer[bar_index];
|
|
|
|
//
|
|
double fib1 = 0.236;
|
|
double fib2 = 0.382;
|
|
double fib3 = 0.5;
|
|
double fib4 = 0.618;
|
|
double fib5 = 0.764;
|
|
double fib6 = 1;
|
|
|
|
//
|
|
double u1 = base + (fib1 * dev);
|
|
double u2 = base + (fib2 * dev);
|
|
double u3 = base + (fib3 * dev);
|
|
double u4 = base + (fib4 * dev);
|
|
double u5 = base + (fib5 * dev);
|
|
double u6 = base + (fib6 * dev);
|
|
|
|
//
|
|
upL1Buffer[bar_index] = u1;
|
|
upL2Buffer[bar_index] = u2;
|
|
upL3Buffer[bar_index] = u3;
|
|
upL4Buffer[bar_index] = u4;
|
|
upL5Buffer[bar_index] = u5;
|
|
upL6Buffer[bar_index] = u6;
|
|
|
|
//
|
|
double d1 = base - (fib1 * dev);
|
|
double d2 = base - (fib2 * dev);
|
|
double d3 = base - (fib3 * dev);
|
|
double d4 = base - (fib4 * dev);
|
|
double d5 = base - (fib5 * dev);
|
|
double d6 = base - (fib6 * dev);
|
|
|
|
//
|
|
downL1Buffer[bar_index] = d1;
|
|
downL2Buffer[bar_index] = d2;
|
|
downL3Buffer[bar_index] = d3;
|
|
downL4Buffer[bar_index] = d4;
|
|
downL5Buffer[bar_index] = d5;
|
|
downL6Buffer[bar_index] = d6;
|
|
|
|
//
|
|
// Setup Color IDX ...
|
|
|
|
//
|
|
double hideColorIDX = 0;
|
|
double showColorIDX = 1;
|
|
|
|
//
|
|
// SET Default Colors ...
|
|
|
|
//
|
|
upL1ColorBuffer[bar_index] = hideColorIDX;
|
|
upL2ColorBuffer[bar_index] = hideColorIDX;
|
|
upL3ColorBuffer[bar_index] = hideColorIDX;
|
|
upL4ColorBuffer[bar_index] = hideColorIDX;
|
|
upL5ColorBuffer[bar_index] = hideColorIDX;
|
|
upL6ColorBuffer[bar_index] = hideColorIDX;
|
|
|
|
//
|
|
downL1ColorBuffer[bar_index] = hideColorIDX;
|
|
downL2ColorBuffer[bar_index] = hideColorIDX;
|
|
downL3ColorBuffer[bar_index] = hideColorIDX;
|
|
downL4ColorBuffer[bar_index] = hideColorIDX;
|
|
downL5ColorBuffer[bar_index] = hideColorIDX;
|
|
downL6ColorBuffer[bar_index] = hideColorIDX;
|
|
|
|
//
|
|
if (!showBase)
|
|
{
|
|
baseColorBuffer[bar_index] = hideColorIDX;
|
|
}
|
|
|
|
//
|
|
if (showBand)
|
|
{
|
|
//
|
|
upL6ColorBuffer[bar_index] = showColorIDX;
|
|
downL6ColorBuffer[bar_index] = showColorIDX;
|
|
}
|
|
|
|
//
|
|
if (showGoldenArea)
|
|
{
|
|
//
|
|
upL3ColorBuffer[bar_index] = showColorIDX;
|
|
upL4ColorBuffer[bar_index] = showColorIDX;
|
|
|
|
//
|
|
downL3ColorBuffer[bar_index] = showColorIDX;
|
|
downL4ColorBuffer[bar_index] = showColorIDX;
|
|
}
|
|
|
|
//
|
|
if (showOthers)
|
|
{
|
|
//
|
|
upL1ColorBuffer[bar_index] = showColorIDX;
|
|
upL2ColorBuffer[bar_index] = showColorIDX;
|
|
upL5ColorBuffer[bar_index] = showColorIDX;
|
|
|
|
//
|
|
downL1ColorBuffer[bar_index] = showColorIDX;
|
|
downL2ColorBuffer[bar_index] = showColorIDX;
|
|
downL5ColorBuffer[bar_index] = showColorIDX;
|
|
}
|
|
}
|
|
|
|
//
|
|
// END Functions ...
|
|
//
|