diff --git a/Documents/BKP/1.mq5 b/Documents/BKP/1.mq5 new file mode 100644 index 00000000..678c768e --- /dev/null +++ b/Documents/BKP/1.mq5 @@ -0,0 +1,160 @@ + // + // HTF Proves ... + + // // + // double scoreMultiplier = 1.5; + + // // + // bool isConsolidationScoreBullish = + // provider.consolidationBullishScore > (provider.consolidationBearishScore * scoreMultiplier); + + // // + // bool isConsolidationScoreBearish = + // provider.consolidationBearishScore > (provider.consolidationBullishScore * scoreMultiplier); + + // + // + // + + // // + // // Detect Kumo Trend ... + // bool isKumoBullish = provider.decisionXConditions.isSenkouSpanAOverB; + // bool isKumoBearish = provider.decisionXConditions.isSenkouSpanAUnderB; + + // // + // // Detect Nearest Cross ... + // XOHCL tkCrossedBar; + // ENUM_X_DIRECTION tkCrossDir; + // bool hasNearestTenkanSenKijunSenCross = + // provider + // .decisionCycleHelper + // .DetectNearestTenKijCross( + // tkCrossedBar, + // tkCrossDir, + // zIndex // + // ); + + // // + // bool isNearestTenkensSenCrossedOverKijunSen = + // hasNearestTenkanSenKijunSenCross && + // IsBullish(tkCrossDir); + + // // + // bool isNearestTenkensSenCrossedUnderKijunSen = + // hasNearestTenkanSenKijunSenCross && + // IsBearish(tkCrossDir); + + // // + // // Detect Nearest Volume ... + // XOHCL vSwitchedBar; + // ENUM_X_DIRECTION vSwitchedDir; + // bool isVolumeSwitched = + // provider + // .decisionCycleHelper + // .DetectNearestVolumeSwitched( + // vSwitchedBar, + // vSwitchedDir, + // zIndex // + // ); + // bool isVolumeBullish = + // isVolumeSwitched && + // IsBullish(vSwitchedDir); + // bool isVolumeBearish = + // isVolumeSwitched && + // IsBearish(vSwitchedDir); + + // // + // // Detect Nearest Delta Crossed ... + // XOHCL deltaCrossedBar; + // ENUM_X_DIRECTION deltaCrossedDir; + // bool isDeltaCrossed = + // provider + // .decisionCycleHelper + // .DetectNearestDeltaSwitched( + // deltaCrossedBar, + // deltaCrossedDir, + // zIndex // + // ); + // bool isDeltaBullish = + // isDeltaCrossed && + // IsBullish(deltaCrossedDir); + // bool isDeltaBearish = + // isDeltaCrossed && + // IsBearish(deltaCrossedDir); + + // // + // // Detect Nearest Str Switched ... + // XOHCL strSwitchedBar; + // ENUM_X_DIRECTION strSwitchedDir; + // bool isStrSwitched = + // provider + // .decisionCycleHelper + // .DetectNearestStrSwitched( + // strSwitchedBar, + // strSwitchedDir, + // zIndex // + // ); + // bool isStrBullish = + // isStrSwitched && + // IsBullish(deltaCrossedDir); + // bool isStrBearish = + // isStrSwitched && + // IsBearish(deltaCrossedDir); + + // // + // // Detect Price in TK Zone ... + // bool isBarInsideTKZone = + // isNearestTenkensSenCrossedOverKijunSen + // ? cBar.low < provider.decisionXConditions.tenkanSenBuffer[cIndex] + // : isNearestTenkensSenCrossedUnderKijunSen + // ? cBar.high > provider.decisionXConditions.tenkanSenBuffer[cIndex] + // : false; + + // // + // // Checking Bar Based on Positions State ... + // ENUM_X_DIRECTION iBarPosDir; + // bool isBarValidForDir = provider.decisionCycleHelper + // .mBarAnalyser + // .IsValidForPosition( + // cBar, + // iBarPosDir // + // ); + // bool isBarValidForBullish = + // isBarValidForDir && + // IsBullish(iBarPosDir); + // bool isBarValidForBearish = + // isBarValidForDir && + // IsBearish(iBarPosDir); + + // + // Summarize Conditions ... + + // + isBullish = + // + false + // isStrBullish && + // isKumoBullish && + // isDeltaBullish && + // isVolumeBullish && + // isBarInsideTKZone && + // isBarValidForBullish && + // isConsolidationScoreBullish && + // isNearestTenkensSenCrossedOverKijunSen + // + ; + + // + isBearish = + // + false + // isStrBearish && + // isKumoBearish && + // isDeltaBearish && + // isVolumeBearish && + // isBarInsideTKZone && + // isBarValidForBearish && + // isConsolidationScoreBearish && + // isNearestTenkensSenCrossedUnderKijunSen + // + ; diff --git a/Documents/BKP/autofibgage.pine b/Documents/BKP/autofibgage.pine new file mode 100644 index 00000000..adbdf088 --- /dev/null +++ b/Documents/BKP/autofibgage.pine @@ -0,0 +1,411 @@ +// This indicator is created under TechnoBlooms - Innovating Trading Indicators and Strategies. +// All rights reserved. Unauthorized copying or distribution is prohibited. +// © TechnoBlooms + +//@version=6 +indicator("AutoFibGauge (TechnoBlooms) ", overlay=true) + +//---------------------------------------------------------------------------- +// Initialize with a default value that's not NaN +//---------------------------------------------------------------------------- +var float highestHigh = 0.0 +var float lowestLow = 0.0 +var float level0 = na +var float level100 = na +var float level236 = na +var float level382 = na +var float level500 = na +var float level618 = na +var float level786 = na + +// Variables for labels +var label label0 = na +var label label100 = na +var label label236 = na +var label label382 = na +var label label500 = na +var label label618 = na +var label label786 = na + +var int positionState = 0 // 0 = neutral, 1 = buy, -1 = sell +Thermometer_position = input.string("Middle right", title="Position", options=["Middle left", "Middle right"], group='Thermometer Settings') + + + +//------------------------------------------------------------------------------- +//input how many candles to consider for drawing fibonacci +//------------------------------------------------------------------------------- +num_of_cand = input(25,"No of Candles to find fib") + +//------------------------------------------------------------------------------- +// Calculate the highest high and lowest low of the last n candles +//------------------------------------------------------------------------------- +highestHigh := ta.highest(high, num_of_cand) +lowestLow := ta.lowest(low, num_of_cand) + +hhBar = ta.highestbars(high, num_of_cand) +llBar = ta.lowestbars(low, num_of_cand) + +// Calculate actual bar indices (negative offsets need to be converted) +currentBar = bar_index +highBarIndex = currentBar + hhBar +lowBarIndex = currentBar + llBar + + +//------------------------------------------------------------------------------- +// Calculate Simple Moving Average (SMA) +//------------------------------------------------------------------------------- +SLength = input(20,"Short Length") +LLength = input(55,"Long Length") // You can adjust this to change the SMA period +Strend = ta.sma(close,SLength) +LTrend = ta.sma(close, LLength) + +//------------------------------------------------------------------------------------------- +// Determine if we're in an uptrend or downtrend based on the current close relative to SMA +//------------------------------------------------------------------------------------------- +isUptrend = Strend > LTrend +barColor = isUptrend ?#26a6c6 : #9c1f98 +barcolor(barColor, title="Trend-Based Bar Color") + + + +//---------------------------------------- +//Choose Visibility of MA lines +//---------------------------------------- +showSMAShort = input.bool(false,"Short SMA") +showSMALong = input.bool(false,"Long SMA") + +//--------------------------------------------------- +//Choose which all fib lines to display +//--------------------------------------------------- +showFib0 = input.bool(true, "Fib 0",group = "Show Fib Lines") +showFib236 = input.bool(true,"Fib 23.6",group = "Show Fib Lines") +showFib382 = input.bool(true,"Fib 38.2",group = "Show Fib Lines") +showFib500 = input.bool(true,"Fib 50",group = "Show Fib Lines") +showFib618 = input.bool(true,"Fib 61.8",group = "Show Fib Lines") +showFib786 = input.bool(true,"Fib 78.6",group = "Show Fib Lines") +showFib100 = input.bool(true,"Fib 100",group = "Show Fib Lines") + +//---------------------------------------------------------------- +// Choose background color of thermometer +//---------------------------------------------------------------- +color0 = color.from_gradient(0, 0, 7, color.aqua, color.purple) +color1 = color.from_gradient(1, 0, 7, color.aqua, color.purple) +color2 = color.from_gradient(2, 0, 7, color.aqua, color.purple) +color3 = color.from_gradient(3, 0, 7, color.aqua, color.purple) +color4 = color.from_gradient(4, 0, 7, color.aqua, color.purple) +color5 = color.from_gradient(5, 0, 7, color.aqua, color.purple) +color6 = color.from_gradient(6, 0, 7, color.aqua, color.purple) +color7 = color.from_gradient(7, 7, 14, color.purple, color.red) +color8 = color.from_gradient(8, 7, 14, color.purple, color.red) +color9 = color.from_gradient(9, 7, 14, color.purple, color.red) +color10 = color.from_gradient(10, 7, 14, color.purple, color.red) +color11 = color.from_gradient(11, 7, 14, color.purple, color.red) +color12 = color.from_gradient(12, 7, 14, color.purple, color.red) +color13 = color.from_gradient(13, 7, 14,color.purple, color.red) + + +//--------------------------------------------------------------------- +// Calculate Fibonacci levels based on trend +//--------------------------------------------------------------------- +if not na(highestHigh) and not na(lowestLow) and highestHigh != lowestLow + float diff = highestHigh - lowestLow + + if isUptrend + level0 := highestHigh + level100 := lowestLow + level236 := highestHigh - (diff * 0.236) + level382 := highestHigh - (diff * 0.382) + level500 := highestHigh - (diff * 0.500) + level618 := highestHigh - (diff * 0.618) + level786 := highestHigh - (diff * 0.786) + else + level0 := lowestLow + level100 := highestHigh + level236 := lowestLow + (diff * 0.236) + level382 := lowestLow + (diff * 0.382) + level500 := lowestLow + (diff * 0.500) + level618 := lowestLow + (diff * 0.618) + level786 := lowestLow + (diff * 0.786) + +//------------------------------------------------- +// Delete old labels +//------------------------------------------------- + label.delete(label0) + label.delete(label100) + label.delete(label236) + label.delete(label382) + label.delete(label500) + label.delete(label618) + label.delete(label786) + +//---------------------------------------------------- +// Draw new labels, considering trend +//---------------------------------------------------- + if showFib0 + label0 := label.new(bar_index+5, level0, text="0.0%", color=color0, textcolor=color.white, style=label.style_label_left) + if showFib100 + label100 := label.new(bar_index+5, level100, text="100.0%", color=color12, textcolor=color.white, style=label.style_label_left) + if showFib236 + label236 := label.new(bar_index+5, level236, text="23.6%", color=color2, textcolor=color.white, style=label.style_label_left) + if showFib382 + label382 := label.new(bar_index+5, level382, text="38.2%", color=color4, textcolor=color.white, style=label.style_label_left) + if showFib500 + label500 := label.new(bar_index+5, level500, text="50.0%", color=color6, textcolor=color.white, style=label.style_label_left) + if showFib618 + label618 := label.new(bar_index+5, level618, text="61.8%", color=color8, textcolor=color.white, style=label.style_label_left) + if showFib786 + label786 := label.new(bar_index+5, level786, text="78.6%", color=color10, textcolor=color.white, style=label.style_label_left) + +//--------------------------------------------------------------- +// Draw straight lines to 20 candles back +//--------------------------------------------------------------- + var line line0 = na + var line line100 = na + var line line236 = na + var line line382 = na + var line line500 = na + var line line618 = na + var line line786 = na + + line.delete(line0) + line.delete(line100) + line.delete(line236) + line.delete(line382) + line.delete(line500) + line.delete(line618) + line.delete(line786) + + if showFib0 + line0 := line.new(bar_index[num_of_cand], level0, bar_index+5, level0, color=color0, width=1) + if showFib100 + line100 := line.new(bar_index[num_of_cand], level100, bar_index+5, level100, color=color12, width=1) + if showFib236 + line236 := line.new(bar_index[num_of_cand], level236, bar_index+5, level236, color=color2, width=1) + if showFib382 + line382 := line.new(bar_index[num_of_cand], level382, bar_index+5, level382, color=color4, width=1) + if showFib500 + line500 := line.new(bar_index[num_of_cand], level500, bar_index+5, level500, color=color6,width = 1) + if showFib618 + line618 := line.new(bar_index[num_of_cand], level618, bar_index+5, level618, color=color8,width = 1) + if showFib786 + line786 := line.new(bar_index[num_of_cand], level786, bar_index+5, level786, color=color10,width = 1) + + // Draw dashed line for showing Fib range + var line fibline = na + + //------------------------------------------------------------------------- + //Highlight Golden Ration region + //------------------------------------------------------------------------- + var box box1 = na + var box box2 = na + var box box3 = na + var box box2_lower = na + var box box2_upper = na + var box box3_lower = na + var box box3_upper = na + // Draw gradient shading with darker areas above and below 61.8%, fading toward 38.2% and 78.6% + // Delete previous boxes + if not na(box1) + box.delete(box1) + if not na(box2_lower) + box.delete(box2_lower) + if not na(box2_upper) + box.delete(box2_upper) + if not na(box3_lower) + box.delete(box3_lower) + if not na(box3_upper) + box.delete(box3_upper) + + // Base layer: Full range (38.2% to 78.6%) - lightest shade + // box1 := box.new(left=bar_index[num_of_cand], top=level786, right=bar_index+5, bottom=level382, bgcolor=color.new(color.yellow, 100), border_width=0) + + // Middle layers: Split around 61.8%, fading outward + box2_lower := box.new(left=bar_index[num_of_cand], top=(level618 + level382)/2, right=bar_index+5, bottom=level382, bgcolor=color.new(color.yellow, 100), border_width=0) + box2_upper := box.new(left=bar_index[num_of_cand], top=level786, right=bar_index+5, bottom=(level786 + level618)/2, bgcolor=color.new(color.yellow, 100), border_width=0) + + // Core layers: Closest to 61.8%, darkest shade + box3_lower := box.new(left=bar_index[num_of_cand], top=level618, right=bar_index+5, bottom=(level618 + level382)/2, bgcolor=color.new(color.yellow, 85), border_width=0) + box3_upper := box.new(left=bar_index[num_of_cand], top=(level786 + level618)/2, right=bar_index+5, bottom=level618, bgcolor=color.new(color.yellow, 85), border_width=0) + if isUptrend + line.delete(fibline) + fibline := line.new(lowBarIndex, lowestLow, highBarIndex, highestHigh, color=color.gray, style=line.style_dashed) + else + line.delete(fibline) + fibline := line.new(highBarIndex, highestHigh, lowBarIndex, lowestLow, color=color.gray, style=line.style_dashed) + +//------------------------- +// Plot SMA +//------------------------- +plot(showSMAShort? Strend:na, title="SMA", color=color.blue, linewidth=1) +plot(showSMALong? LTrend:na, title="Strend", color=#f321b4, linewidth=1) + +//----------------------------------------------------------- +//create labels in Thermometer when trend = 1 (uptrend) +//----------------------------------------------------------- +var table_position = Thermometer_position == 'Top right' ? position.top_right : + Thermometer_position == 'Top left' ? position.top_left : + Thermometer_position == 'Top center' ? position.top_center : + Thermometer_position == 'Bottom right' ? position.bottom_right : + Thermometer_position == 'Bottom left' ? position.bottom_left : + Thermometer_position == 'Bottom center' ? position.bottom_center : + Thermometer_position == 'Middle right' ? position.middle_right : position.middle_right + + +tbl = table.new(position=table_position, columns = 100, rows=100) +closenum=math.round(close,0) + +if level0 < level100 + + table.cell(tbl,0,0,text = label100.get_text() , text_color = #f83f8c) + table.cell(tbl,0,11,text = label236.get_text() ,text_color = #f83f8c) + table.cell(tbl,0,8,text = label382.get_text() ,text_color = #f83f8c) + table.cell(tbl,0,5,text = label618.get_text() , text_color =#f83f8c) + table.cell(tbl,0,2,text = label786.get_text(),text_color = #f83f8c) + table.cell(tbl,0,13,text = label0.get_text(), text_color = #f83f8c) + + + table.cell(tbl,2,13,text = str.tostring(level0," #,###"), text_color = #f83f8c) + table.cell(tbl,2,11,text = str.tostring(level236, " #,###"),text_color = #f83f8c) + table.cell(tbl,2,8,text = str.tostring(level382, " #,###"),text_color = #f83f8c) + table.cell(tbl,2,5,text = str.tostring(level618, " #,###"), text_color =#f83f8c) + table.cell(tbl,2,2,text = str.tostring(level786, " #,###"),text_color = #f83f8c) + table.cell(tbl,2,0,text = str.tostring(level100," #,###"), text_color = #f83f8c) + + for i = 0 to 13 by 1 + table.cell(tbl, 1, i, "", bgcolor = i < 8 ? color.from_gradient(i, 0, 7, color.aqua, color.purple) : color.from_gradient(i, 7, 14, color.purple, color.red)) + + var reg = 0 + bkcolor = color.aqua + + if closenum > level0 and closenum < level236 + reg := 12 + if closenum > level236 and closenum < level382 + reg := 9 + if closenum > level382 and closenum < level618 + reg := 6 + if closenum > level618 and closenum < level786 + reg := 3 + if closenum > level786 and closenum < level100 + reg := 1 + if closenum == level0 + reg := 0 + if closenum == level236 + reg := 11 + if closenum == level382 + reg := 8 + if closenum == level618 + reg := 5 + if closenum == level786 + reg := 2 + + + if reg == 12 + bkcolor := color12 + if reg == 9 + bkcolor := color9 + if reg == 6 + bkcolor := color6 + if reg == 3 + bkcolor := color3 + if reg == 1 + bkcolor := color1 + if reg == 2 + bkcolor := color2 + + if reg == 4 + bkcolor := color4 + if reg == 5 + bkcolor := color5 + if reg == 7 + bkcolor := color7 + if reg == 8 + bkcolor := color8 + if reg == 10 + bkcolor := color10 + if reg == 11 + bkcolor := color11 + if reg == 13 + bkcolor := color13 + + + table.cell(tbl,1,reg,"🌕", text_size = size.small,bgcolor = bkcolor) +//----------------------------------------------------------- +//create labels in Thermometer +//----------------------------------------------------------- +else + table.cell(tbl,0,13,text = label100.get_text() , text_color = #f83f8c) + table.cell(tbl,0,2,text = label236.get_text() ,text_color = #f83f8c) + table.cell(tbl,0,5,text = label382.get_text() ,text_color = #f83f8c) + table.cell(tbl,0,8,text = label618.get_text() , text_color =#f83f8c) + table.cell(tbl,0,11,text = label786.get_text(),text_color = #f83f8c) + table.cell(tbl,0,0,text = label0.get_text(), text_color = #f83f8c) + + + table.cell(tbl,2,0,text = str.tostring(level0," #,###"), text_color = #f83f8c) + table.cell(tbl,2,2,text = str.tostring(level236, " #,###"),text_color = #f83f8c) + table.cell(tbl,2,5,text = str.tostring(level382, " #,###"),text_color = #f83f8c) + table.cell(tbl,2,8,text = str.tostring(level618, " #,###"), text_color =#f83f8c) + table.cell(tbl,2,11,text = str.tostring(level786, " #,###"),text_color = #f83f8c) + table.cell(tbl,2,13,text = str.tostring(level100," #,###"), text_color = #f83f8c) + + for i = 0 to 13 by 1 + table.cell(tbl, 1, i, "", bgcolor = i < 8 ? color.from_gradient(i, 0, 7, color.aqua, color.purple) : color.from_gradient(i, 7, 14, color.purple, color.red)) + + var reg = 0 + bkcolor = color.aqua + + if closenum > level100 and closenum < level786 + reg := 12 + if closenum > level786 and closenum < level618 + reg := 9 + if closenum > level618 and closenum < level382 + reg := 6 + if closenum > level382 and closenum < level236 + reg := 3 + if closenum > level236 and closenum < level0 + reg := 1 + if closenum == level0 + reg := 0 + if closenum == level236 + reg := 11 + if closenum == level382 + reg := 8 + if closenum == level618 + reg := 5 + if closenum == level786 + reg := 2 + + + if reg == 12 + bkcolor := color12 + if reg == 9 + bkcolor := color9 + if reg == 6 + bkcolor := color6 + if reg == 3 + bkcolor := color3 + if reg == 1 + bkcolor := color1 + if reg == 2 + bkcolor := color2 + + if reg == 4 + bkcolor := color4 + if reg == 5 + bkcolor := color5 + if reg == 7 + bkcolor := color7 + if reg == 8 + bkcolor := color8 + if reg == 10 + bkcolor := color10 + if reg == 11 + bkcolor := color11 + if reg == 13 + bkcolor := color13 + + + table.cell(tbl,1,reg,"🌕", text_size = size.small,bgcolor = bkcolor) + + diff --git a/Documents/BKP/percentile.supertrend.pine b/Documents/BKP/percentile.supertrend.pine new file mode 100644 index 00000000..9859bf95 --- /dev/null +++ b/Documents/BKP/percentile.supertrend.pine @@ -0,0 +1,66 @@ +// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ +// © Mattes00 + +//@version=6 +indicator("25-75 Percentile SuperTrend | Mattes", shorttitle = "25-75 ST | Mattes", overlay = true) + +subject = input.int (14,"Supertrend length", minval = 2 , group="25-75 Percentile SuperTrend") +mult = input.float (1, "Multiplier", step=0.05,group="25-75 Percentile SuperTrend") +slen = input.int (27, "Percentile length", group="25-75 Percentile SuperTrend") +src_2575 = input.source(high, "Median smoothing source", group="25-75 Percentile SuperTrend") + +smooth_lower = ta.percentile_nearest_rank(src_2575, slen, 25) +smooth_upper = ta.percentile_nearest_rank(src_2575, slen, 75) + + +Percentile_SuperTrend_func(mult, atrPeriod) => + src_long = smooth_upper + src_short = smooth_lower + + atr = ta.atr(atrPeriod) + upper = src_long + mult * atr + lower = src_short - mult * atr + pl = nz(lower[1]) + pu = nz(upper[1]) + + lower := lower > pl or close[1] < pl ? lower : pl + upper := upper < pu or close[1] > pu ? upper : pu + + int dist = na + float st = na + pt = st[1] + if na(atr[1]) + dist := 1 + else if pt == pu + dist := close > upper ? -1 : 1 + else + dist := close < lower ? 1 : -1 + st := dist == -1 ? lower : upper + [st, dist] + + +[x, dist] = Percentile_SuperTrend_func(mult, subject) + +ST_L = ta.crossunder(dist, 0) +ST_S = ta.crossover(dist, 0) + +Long = ST_L +Short = ST_S + +var Mattes = 0 +if (Long and not Short) + Mattes := 1 +if Short + Mattes := -1 + +syscol = Mattes == 1 ? color.rgb(45, 162, 252) : Mattes == -1 ? color.rgb(113, 59, 249) : color.gray +BlueTransParent = color.new(color.rgb(45, 162, 252), 50) +PurpleTransParent = color.new(color.rgb(113, 59, 249), 50) + +plotcandle(open, high, low, close, 'BarColor', color = syscol, bordercolor = syscol, wickcolor = syscol,force_overlay = true) +upTrend = plot(dist < 0 ? x : na, "Up Trend", color = color.rgb(45, 162, 252), style = plot.style_linebr, linewidth = 2) +downTrend = plot(dist < 0 ? na : x, "Down Trend", color = color.rgb(113, 59, 249), style = plot.style_linebr, linewidth = 2) +s = plot((smooth_lower + smooth_upper) / 2, color = syscol) +fill(s, upTrend, BlueTransParent, fillgaps = false) +fill(s, downTrend, PurpleTransParent, fillgaps = false) + diff --git a/Helpers/x-saherelm.x121.helper.mq5 b/Helpers/x-saherelm.x121.helper.mq5 index 05b42a93..5dbfce6d 100644 --- a/Helpers/x-saherelm.x121.helper.mq5 +++ b/Helpers/x-saherelm.x121.helper.mq5 @@ -451,6 +451,63 @@ struct X121Conditions bool isTenkanSenCrossedOverKijunSen; bool isTenkanSenCrossedUnderKijunSen; + // + // XDELTA ... + + // + bool isDeltaBullish; + bool isDeltaBearish; + bool isDeltaSwitchedToBullish; + bool isDeltaSwitchedToBearish; + + // + bool isDeltaOverMa; + bool isDeltaUnderMa; + bool isDeltaCrossedOverMa; + bool isDeltaCrossedUnderMa; + + // + // XVOLUME ... + + bool isBullishVolumeOverMa; + bool isBullishVolumeCrossedOverMa; + + // + bool isBullishVolumeUnderMa; + bool isBullishVolumeCrossedUnderMa; + + // + bool isBullishVolumeIncreased; + bool isBullishVolumeSwitchedToIncreased; + + // + bool isBullishVolumeDecreased; + bool isBullishVolumeSwitchedToDecreased; + + // + bool isBearishVolumeOverMa; + bool isBearishVolumeCrossedOverMa; + + // + bool isBearishVolumeUnderMa; + bool isBearishVolumeCrossedUnderMa; + + // + bool isBearishVolumeIncreased; + bool isBearishVolumeSwitchedToIncreased; + + // + bool isBearishVolumeDecreased; + bool isBearishVolumeSwitchedToDecreased; + + // + bool isVolumeSwitchedToBullish; + bool isVolumeSwitchedToBearish; + + // + bool isBullishVolumeMaOverBearishVolumeMa; + bool isBullishVolumeMaUnderBearishVolumeMa; + // // Complex Conditions ... @@ -956,6 +1013,64 @@ struct X121Conditions isTenkanSenCrossedOverKijunSen = false; isTenkanSenCrossedUnderKijunSen = false; + // + // XDELTA ... + + // + isDeltaBullish = false; + isDeltaBearish = false; + isDeltaSwitchedToBullish = false; + isDeltaSwitchedToBearish = false; + + // + isDeltaOverMa = false; + isDeltaUnderMa = false; + isDeltaCrossedOverMa = false; + isDeltaCrossedUnderMa = false; + + // + // XVOLUME ... + + // + isBullishVolumeOverMa = false; + isBullishVolumeCrossedOverMa = false; + + // + isBullishVolumeUnderMa = false; + isBullishVolumeCrossedUnderMa = false; + + // + isBullishVolumeIncreased = false; + isBullishVolumeSwitchedToIncreased = false; + + // + isBullishVolumeDecreased = false; + isBullishVolumeSwitchedToDecreased = false; + + // + isBearishVolumeOverMa = false; + isBearishVolumeCrossedOverMa = false; + + // + isBearishVolumeUnderMa = false; + isBearishVolumeCrossedUnderMa = false; + + // + isBearishVolumeIncreased = false; + isBearishVolumeSwitchedToIncreased = false; + + // + isBearishVolumeDecreased = false; + isBearishVolumeSwitchedToDecreased = false; + + // + isVolumeSwitchedToBullish = false; + isVolumeSwitchedToBearish = false; + + // + isBullishVolumeMaOverBearishVolumeMa = false; + isBullishVolumeMaUnderBearishVolumeMa = false; + // // Complex Conditions ... @@ -1667,6 +1782,135 @@ struct X121Conditions bullishScore += minScore; } + // + // XDELTA ... + + // + if (isDeltaOverMa) + { + bullishScore += minScore; + } + if (isDeltaBullish) + { + bullishScore += minScore; + } + if (isDeltaCrossedOverMa) + { + bullishScore += score; + } + if (isDeltaSwitchedToBullish) + { + bullishScore += score; + } + + if (isDeltaBearish) + { + bearishScore += minScore; + } + if (isDeltaUnderMa) + { + bearishScore += minScore; + } + if (isDeltaCrossedUnderMa) + { + bearishScore += score; + } + if (isDeltaSwitchedToBearish) + { + bearishScore += score; + } + + // + // XVOLUME ... + + // + if (isBullishVolumeOverMa) + { + bullishScore += minScore; + } + if (isBearishVolumeUnderMa) + { + bullishScore += minScore; + } + if (isBullishVolumeIncreased) + { + bullishScore += minScore; + } + if (isBearishVolumeDecreased) + { + bullishScore += minScore; + } + if (isBullishVolumeMaOverBearishVolumeMa) + { + bullishScore += minScore; + } + + // + if (isVolumeSwitchedToBullish) + { + bullishScore += score; + } + if (isBullishVolumeCrossedOverMa) + { + bullishScore += score; + } + if (isBearishVolumeCrossedUnderMa) + { + bullishScore += score; + } + if (isBullishVolumeSwitchedToIncreased) + { + bullishScore += score; + } + if (isBearishVolumeSwitchedToDecreased) + { + bullishScore += score; + } + + // + if (isBearishVolumeOverMa) + { + bearishScore += minScore; + } + if (isBullishVolumeUnderMa) + { + bearishScore += minScore; + } + if (isBullishVolumeDecreased) + { + bearishScore += minScore; + } + if (isBearishVolumeIncreased) + { + bearishScore += minScore; + } + if (isBullishVolumeMaUnderBearishVolumeMa) + { + bearishScore += minScore; + } + + // + if (isVolumeSwitchedToBearish) + { + bearishScore += score; + } + if (isBearishVolumeCrossedOverMa) + { + bearishScore += score; + } + if (isBullishVolumeCrossedUnderMa) + { + bearishScore += score; + } + if (isBullishVolumeSwitchedToDecreased) + { + bearishScore += score; + } + if (isBearishVolumeSwitchedToIncreased) + { + bearishScore += score; + } + // // // @@ -2032,6 +2276,42 @@ struct X121Conditions ToString("isSenkouSpanACrossedUnderB", isSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) + // "-----------------------" + separator + + "XDELTA ..." + separator + + "-----------------------" + separator + + ToString("isDeltaBullish", isDeltaBullish, ignoreFalseConditions, separator) + + ToString("isDeltaBearish", isDeltaBearish, ignoreFalseConditions, separator) + + ToString("isDeltaSwitchedToBullish", isDeltaSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isDeltaSwitchedToBearish", isDeltaSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isDeltaOverMa", isDeltaOverMa, ignoreFalseConditions, separator) + + ToString("isDeltaUnderMa", isDeltaUnderMa, ignoreFalseConditions, separator) + + ToString("isDeltaCrossedOverMa", isDeltaCrossedOverMa, ignoreFalseConditions, separator) + + ToString("isDeltaCrossedUnderMa", isDeltaCrossedUnderMa, ignoreFalseConditions, separator) + + // + "-----------------------" + separator + + "XVOLUME ..." + separator + + "-----------------------" + separator + + ToString("isBullishVolumeOverMa", isBullishVolumeOverMa, ignoreFalseConditions, separator) + + ToString("isBullishVolumeCrossedOverMa", isBullishVolumeCrossedOverMa, ignoreFalseConditions, separator) + + ToString("isBullishVolumeUnderMa", isBullishVolumeUnderMa, ignoreFalseConditions, separator) + + ToString("isBullishVolumeCrossedUnderMa", isBullishVolumeCrossedUnderMa, ignoreFalseConditions, separator) + + ToString("isBullishVolumeIncreased", isBullishVolumeIncreased, ignoreFalseConditions, separator) + + ToString("isBullishVolumeSwitchedToIncreased", isBullishVolumeSwitchedToIncreased, ignoreFalseConditions, separator) + + ToString("isBullishVolumeDecreased", isBullishVolumeDecreased, ignoreFalseConditions, separator) + + ToString("isBullishVolumeSwitchedToDecreased", isBullishVolumeSwitchedToDecreased, ignoreFalseConditions, separator) + + ToString("isBearishVolumeOverMa", isBearishVolumeOverMa, ignoreFalseConditions, separator) + + ToString("isBearishVolumeCrossedOverMa", isBearishVolumeCrossedOverMa, ignoreFalseConditions, separator) + + ToString("isBearishVolumeUnderMa", isBearishVolumeUnderMa, ignoreFalseConditions, separator) + + ToString("isBearishVolumeCrossedUnderMa", isBearishVolumeCrossedUnderMa, ignoreFalseConditions, separator) + + ToString("isBearishVolumeIncreased", isBearishVolumeIncreased, ignoreFalseConditions, separator) + + ToString("isBearishVolumeSwitchedToIncreased", isBearishVolumeSwitchedToIncreased, ignoreFalseConditions, separator) + + ToString("isBearishVolumeDecreased", isBearishVolumeDecreased, ignoreFalseConditions, separator) + + ToString("isBearishVolumeSwitchedToDecreased", isBearishVolumeSwitchedToDecreased, ignoreFalseConditions, separator) + + ToString("isVolumeSwitchedToBullish", isVolumeSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isVolumeSwitchedToBearish", isVolumeSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isBullishVolumeMaOverBearishVolumeMa", isBullishVolumeMaOverBearishVolumeMa, ignoreFalseConditions, separator) + + ToString("isBullishVolumeMaUnderBearishVolumeMa", isBullishVolumeMaUnderBearishVolumeMa, ignoreFalseConditions, separator) + + // + "-----------------------" + separator + "Slopes ..." + separator + "-----------------------" + separator + ToString("isRsiSlopeBullish", isRsiSlopeBullish, ignoreFalseConditions, separator) + @@ -4061,6 +4341,18 @@ class XCX121Helper : public XCBase // // Conditions ... + // + conditions.isDeltaBullish = xdeltaConditions.isDeltaBullish; + conditions.isDeltaBearish = xdeltaConditions.isDeltaBearish; + conditions.isDeltaSwitchedToBullish = xdeltaConditions.isDeltaSwitchedToBullish; + conditions.isDeltaSwitchedToBearish = xdeltaConditions.isDeltaSwitchedToBearish; + + // + conditions.isDeltaOverMa = xdeltaConditions.isDeltaOverMa; + conditions.isDeltaUnderMa = xdeltaConditions.isDeltaUnderMa; + conditions.isDeltaCrossedOverMa = xdeltaConditions.isDeltaCrossedOverMa; + conditions.isDeltaCrossedUnderMa = xdeltaConditions.isDeltaCrossedUnderMa; + // // XVOLUME ... @@ -4094,6 +4386,46 @@ class XCX121Helper : public XCBase // // Conditions ... + // + conditions.isBullishVolumeOverMa = xvolumeConditions.isBullishVolumeOverMa; + conditions.isBullishVolumeCrossedOverMa = xvolumeConditions.isBullishVolumeCrossedOverMa; + + // + conditions.isBullishVolumeUnderMa = xvolumeConditions.isBullishVolumeUnderMa; + conditions.isBullishVolumeCrossedUnderMa = xvolumeConditions.isBullishVolumeCrossedUnderMa; + + // + conditions.isBullishVolumeIncreased = xvolumeConditions.isBullishVolumeIncreased; + conditions.isBullishVolumeSwitchedToIncreased = xvolumeConditions.isBullishVolumeSwitchedToIncreased; + + // + conditions.isBullishVolumeDecreased = xvolumeConditions.isBullishVolumeDecreased; + conditions.isBullishVolumeSwitchedToDecreased = xvolumeConditions.isBullishVolumeSwitchedToDecreased; + + // + conditions.isBearishVolumeOverMa = xvolumeConditions.isBearishVolumeOverMa; + conditions.isBearishVolumeCrossedOverMa = xvolumeConditions.isBearishVolumeCrossedOverMa; + + // + conditions.isBearishVolumeUnderMa = xvolumeConditions.isBearishVolumeUnderMa; + conditions.isBearishVolumeCrossedUnderMa = xvolumeConditions.isBearishVolumeCrossedUnderMa; + + // + conditions.isBearishVolumeIncreased = xvolumeConditions.isBearishVolumeIncreased; + conditions.isBearishVolumeSwitchedToIncreased = xvolumeConditions.isBearishVolumeSwitchedToIncreased; + + // + conditions.isBearishVolumeDecreased = xvolumeConditions.isBearishVolumeDecreased; + conditions.isBearishVolumeSwitchedToDecreased = xvolumeConditions.isBearishVolumeSwitchedToDecreased; + + // + conditions.isVolumeSwitchedToBullish = xvolumeConditions.isVolumeSwitchedToBullish; + conditions.isVolumeSwitchedToBearish = xvolumeConditions.isVolumeSwitchedToBearish; + + // + conditions.isBullishVolumeMaOverBearishVolumeMa = xvolumeConditions.isBullishVolumeMaOverBearishVolumeMa; + conditions.isBullishVolumeMaUnderBearishVolumeMa = xvolumeConditions.isBullishVolumeMaUnderBearishVolumeMa; + // // Slopes ... diff --git a/Helpers/x-saherelm.x121.xdelta.helper.mq5 b/Helpers/x-saherelm.x121.xdelta.helper.mq5 index be52df88..051e5008 100644 --- a/Helpers/x-saherelm.x121.xdelta.helper.mq5 +++ b/Helpers/x-saherelm.x121.xdelta.helper.mq5 @@ -164,6 +164,18 @@ struct X121XDELTAConditions // // Conditions ... + // + bool isDeltaBullish; + bool isDeltaBearish; + bool isDeltaSwitchedToBullish; + bool isDeltaSwitchedToBearish; + + // + bool isDeltaOverMa; + bool isDeltaUnderMa; + bool isDeltaCrossedOverMa; + bool isDeltaCrossedUnderMa; + // // Constructor ... X121XDELTAConditions() @@ -201,6 +213,18 @@ struct X121XDELTAConditions // // Conditions ... + // + isDeltaBullish = false; + isDeltaBearish = false; + isDeltaSwitchedToBullish = false; + isDeltaSwitchedToBearish = false; + + // + isDeltaOverMa = false; + isDeltaUnderMa = false; + isDeltaCrossedOverMa = false; + isDeltaCrossedUnderMa = false; + // ZeroMemory(this); } @@ -679,9 +703,43 @@ class XCX121XDELTAHelper : public XCBaseHelper // int cIDX = 1; int pIDX = cIDX + 1; + int pPIDX = pIDX + 1; // - // SAR ... + bool isDeltaBullish = conditions.deltaBuffer[cIDX] > conditions.deltaBuffer[pIDX]; + bool isDeltaBullishP = conditions.deltaBuffer[pIDX] > conditions.deltaBuffer[pPIDX]; + bool isDeltaSwitchedToBullish = isDeltaBullish && + !isDeltaBullishP; + + // + bool isDeltaBearish = conditions.deltaBuffer[cIDX] < conditions.deltaBuffer[pIDX]; + bool isDeltaBearishP = conditions.deltaBuffer[pIDX] < conditions.deltaBuffer[pPIDX]; + bool isDeltaSwitchedToBearish = isDeltaBearish && + !isDeltaBearishP; + + // + bool isDeltaOverMa = conditions.deltaBuffer[cIDX] > conditions.deltaMaBuffer[cIDX]; + bool isDeltaOverMaP = conditions.deltaBuffer[pIDX] > conditions.deltaMaBuffer[pIDX]; + bool isDeltaCrossedOverMa = isDeltaOverMa && + !isDeltaOverMaP; + + // + bool isDeltaUnderMa = conditions.deltaBuffer[cIDX] < conditions.deltaMaBuffer[cIDX]; + bool isDeltaUnderMaP = conditions.deltaBuffer[pIDX] < conditions.deltaMaBuffer[pIDX]; + bool isDeltaCrossedUnderMa = isDeltaUnderMa && + !isDeltaUnderMaP; + + // + conditions.isDeltaBullish = isDeltaBullish; + conditions.isDeltaBearish = isDeltaBearish; + conditions.isDeltaSwitchedToBullish = isDeltaSwitchedToBullish; + conditions.isDeltaSwitchedToBearish = isDeltaSwitchedToBearish; + + // + conditions.isDeltaOverMa = isDeltaOverMa; + conditions.isDeltaUnderMa = isDeltaUnderMa; + conditions.isDeltaCrossedOverMa = isDeltaCrossedOverMa; + conditions.isDeltaCrossedUnderMa = isDeltaCrossedUnderMa; // Cleanup(); diff --git a/Helpers/x-saherelm.x121.xvolume.helper.mq5 b/Helpers/x-saherelm.x121.xvolume.helper.mq5 index cef02d52..9aeafd39 100644 --- a/Helpers/x-saherelm.x121.xvolume.helper.mq5 +++ b/Helpers/x-saherelm.x121.xvolume.helper.mq5 @@ -168,6 +168,44 @@ struct X121XVOLUMEConditions // // Conditions ... + // + bool isBullishVolumeOverMa; + bool isBullishVolumeCrossedOverMa; + + // + bool isBullishVolumeUnderMa; + bool isBullishVolumeCrossedUnderMa; + + // + bool isBullishVolumeIncreased; + bool isBullishVolumeSwitchedToIncreased; + + // + bool isBullishVolumeDecreased; + bool isBullishVolumeSwitchedToDecreased; + + // + bool isBearishVolumeOverMa; + bool isBearishVolumeCrossedOverMa; + + // + bool isBearishVolumeUnderMa; + bool isBearishVolumeCrossedUnderMa; + + // + bool isBearishVolumeIncreased; + bool isBearishVolumeSwitchedToIncreased; + + // + bool isBearishVolumeDecreased; + bool isBearishVolumeSwitchedToDecreased; + + // + bool isVolumeSwitchedToBullish; + bool isVolumeSwitchedToBearish; + bool isBullishVolumeMaOverBearishVolumeMa; + bool isBullishVolumeMaUnderBearishVolumeMa; + // // Constructor ... X121XVOLUMEConditions() @@ -207,6 +245,44 @@ struct X121XVOLUMEConditions // // Conditions ... + // + isBullishVolumeOverMa = false; + isBullishVolumeCrossedOverMa = false; + + // + isBullishVolumeUnderMa = false; + isBullishVolumeCrossedUnderMa = false; + + // + isBullishVolumeIncreased = false; + isBullishVolumeSwitchedToIncreased = false; + + // + isBullishVolumeDecreased = false; + isBullishVolumeSwitchedToDecreased = false; + + // + isBearishVolumeOverMa = false; + isBearishVolumeCrossedOverMa = false; + + // + isBearishVolumeUnderMa = false; + isBearishVolumeCrossedUnderMa = false; + + // + isBearishVolumeIncreased = false; + isBearishVolumeSwitchedToIncreased = false; + + // + isBearishVolumeDecreased = false; + isBearishVolumeSwitchedToDecreased = false; + + // + isVolumeSwitchedToBullish = false; + isVolumeSwitchedToBearish = false; + isBullishVolumeMaOverBearishVolumeMa = false; + isBullishVolumeMaUnderBearishVolumeMa = false; + // ZeroMemory(this); } @@ -747,9 +823,109 @@ class XCX121XVOLUMEHelper : public XCBaseHelper // int cIDX = 1; int pIDX = cIDX + 1; + int pPIDX = pIDX + 1; // - // SAR ... + bool isBullishVolumeOverMa = conditions.bullishVolumeBuffer[cIDX] > conditions.bullishVolumeMaBuffer[cIDX]; + bool isBullishVolumeOverMaP = conditions.bullishVolumeBuffer[pIDX] > conditions.bullishVolumeMaBuffer[pIDX]; + bool isBullishVolumeCrossedOverMa = isBullishVolumeOverMa && + !isBullishVolumeOverMaP; + + // + bool isBullishVolumeUnderMa = conditions.bullishVolumeBuffer[cIDX] < conditions.bullishVolumeMaBuffer[cIDX]; + bool isBullishVolumeUnderMaP = conditions.bullishVolumeBuffer[pIDX] < conditions.bullishVolumeMaBuffer[pIDX]; + bool isBullishVolumeCrossedUnderMa = isBullishVolumeUnderMa && + !isBullishVolumeUnderMaP; + + // + bool isBullishVolumeIncreased = conditions.bullishVolumeBuffer[cIDX] > conditions.bullishVolumeBuffer[pIDX]; + bool isBullishVolumeIncreasedP = conditions.bullishVolumeBuffer[pIDX] > conditions.bullishVolumeBuffer[pPIDX]; + bool isBullishVolumeSwitchedToIncreased = isBullishVolumeIncreased && + !isBullishVolumeIncreasedP; + + // + bool isBullishVolumeDecreased = conditions.bullishVolumeBuffer[cIDX] < conditions.bullishVolumeBuffer[pIDX]; + bool isBullishVolumeDecreasedP = conditions.bullishVolumeBuffer[pIDX] < conditions.bullishVolumeBuffer[pPIDX]; + bool isBullishVolumeSwitchedToDecreased = isBullishVolumeDecreased && + !isBullishVolumeDecreasedP; + + // + bool isBearishVolumeOverMa = conditions.bearishVolumeBuffer[cIDX] > conditions.bearishVolumeMaBuffer[cIDX]; + bool isBearishVolumeOverMaP = conditions.bearishVolumeBuffer[pIDX] > conditions.bearishVolumeMaBuffer[pIDX]; + bool isBearishVolumeCrossedOverMa = isBearishVolumeOverMa && + !isBearishVolumeOverMaP; + + // + bool isBearishVolumeUnderMa = conditions.bearishVolumeBuffer[cIDX] < conditions.bearishVolumeMaBuffer[cIDX]; + bool isBearishVolumeUnderMaP = conditions.bearishVolumeBuffer[pIDX] < conditions.bearishVolumeMaBuffer[pIDX]; + bool isBearishVolumeCrossedUnderMa = isBearishVolumeUnderMa && + !isBearishVolumeUnderMaP; + + // + bool isBearishVolumeIncreased = conditions.bearishVolumeBuffer[cIDX] > conditions.bearishVolumeBuffer[pIDX]; + bool isBearishVolumeIncreasedP = conditions.bearishVolumeBuffer[pIDX] > conditions.bearishVolumeBuffer[pPIDX]; + bool isBearishVolumeSwitchedToIncreased = isBearishVolumeIncreased && + !isBearishVolumeIncreasedP; + + // + bool isBearishVolumeDecreased = conditions.bearishVolumeBuffer[cIDX] < conditions.bearishVolumeBuffer[pIDX]; + bool isBearishVolumeDecreasedP = conditions.bearishVolumeBuffer[pIDX] < conditions.bearishVolumeBuffer[pPIDX]; + bool isBearishVolumeSwitchedToDecreased = isBearishVolumeDecreased && + !isBearishVolumeDecreasedP; + + // + bool isBullishVolumeMaOverBearishVolumeMa = conditions.bullishVolumeMaBuffer[cIDX] > conditions.bearishVolumeMaBuffer[cIDX]; + bool isBullishVolumeMaOverBearishVolumeMaP = conditions.bullishVolumeMaBuffer[pIDX] > conditions.bearishVolumeMaBuffer[pIDX]; + bool isVolumeSwitchedToBullish = isBullishVolumeMaOverBearishVolumeMa && + !isBullishVolumeMaOverBearishVolumeMaP; + + // + bool isBullishVolumeMaUnderBearishVolumeMa = conditions.bullishVolumeMaBuffer[cIDX] < conditions.bearishVolumeMaBuffer[cIDX]; + bool isBullishVolumeMaUnderBearishVolumeMaP = conditions.bullishVolumeMaBuffer[pIDX] < conditions.bearishVolumeMaBuffer[pIDX]; + bool isVolumeSwitchedToBearish = isBullishVolumeMaUnderBearishVolumeMa && + !isBullishVolumeMaUnderBearishVolumeMaP; + + // + // + // + + // + conditions.isBullishVolumeOverMa = isBullishVolumeOverMa; + conditions.isBullishVolumeCrossedOverMa = isBullishVolumeCrossedOverMa; + + // + conditions.isBullishVolumeUnderMa = isBullishVolumeUnderMa; + conditions.isBullishVolumeCrossedUnderMa = isBullishVolumeCrossedUnderMa; + + // + conditions.isBullishVolumeIncreased = isBullishVolumeIncreased; + conditions.isBullishVolumeSwitchedToIncreased = isBullishVolumeSwitchedToIncreased; + + // + conditions.isBullishVolumeDecreased = isBullishVolumeDecreased; + conditions.isBullishVolumeSwitchedToDecreased = isBullishVolumeSwitchedToDecreased; + + // + conditions.isBearishVolumeOverMa = isBearishVolumeOverMa; + conditions.isBearishVolumeCrossedOverMa = isBearishVolumeCrossedOverMa; + + // + conditions.isBearishVolumeUnderMa = isBearishVolumeUnderMa; + conditions.isBearishVolumeCrossedUnderMa = isBearishVolumeCrossedUnderMa; + + // + conditions.isBearishVolumeIncreased = isBearishVolumeIncreased; + conditions.isBearishVolumeSwitchedToIncreased = isBearishVolumeSwitchedToIncreased; + + // + conditions.isBearishVolumeDecreased = isBearishVolumeDecreased; + conditions.isBearishVolumeSwitchedToDecreased = isBearishVolumeSwitchedToDecreased; + + // + conditions.isVolumeSwitchedToBullish = isVolumeSwitchedToBullish; + conditions.isVolumeSwitchedToBearish = isVolumeSwitchedToBearish; + conditions.isBullishVolumeMaOverBearishVolumeMa = isBullishVolumeMaOverBearishVolumeMa; + conditions.isBullishVolumeMaUnderBearishVolumeMa = isBullishVolumeMaUnderBearishVolumeMa; // Cleanup(); diff --git a/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 b/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 index f5786d97..649a6747 100644 --- a/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 +++ b/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 @@ -1047,6 +1047,256 @@ class XC121SMCCycleHelper : public XCBase return result; } + // + bool DetectNearestVolumeSwitched( + XOHCL &bar, + ENUM_X_DIRECTION &dir, + int barIndex = 0, + int maxAllowedBars = 20 // + ) + { + // + bool result = false; + + // + bar.Clean(); + dir = X_DIRECTION_NONE; + barIndex = NormalizeInt(barIndex, 0); + maxAllowedBars = NormalizeInt(maxAllowedBars, 20); + + // + // Looping Through LoopBack Period ... + // for Detecting Result ... + for (int i = barIndex; i < barIndex + maxAllowedBars; i++) + { + // + XOHCL iBar; + result = iBar.Init( + GetSymbol(), + GetPeriod(), + i // + ); + if (!result) + { + // + iBar.Clean(); + break; + } + + // + double iBullVMa = mX121Helper.xvolumeHelper.GetBullishVolumeMa(i); + double iBullVMaP = mX121Helper.xvolumeHelper.GetBullishVolumeMa(i + 1); + + // + double iBearVMa = mX121Helper.xvolumeHelper.GetBearishVolumeMa(i); + double iBearVMaP = mX121Helper.xvolumeHelper.GetBearishVolumeMa(i + 1); + + // + bool isBullVMaOverBearVMa = iBullVMa > iBearVMa; + bool isBullVMaOverBearVMaP = iBullVMaP > iBearVMaP; + bool isCrossOver = isBullVMaOverBearVMa && + !isBullVMaOverBearVMaP; + + // + bool isBullVMaUnderBearVMa = iBullVMa < iBearVMa; + bool isBullVMaUnderBearVMaP = iBullVMaP < iBearVMaP; + bool isCrossUnder = isBullVMaUnderBearVMa && + !isBullVMaUnderBearVMaP; + + // + result = isCrossOver || + isCrossUnder; + if (result) + { + // + bar = iBar; + + // + dir = isCrossOver + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + iBar.Clean(); + break; + } + + // + iBar.Clean(); + } + + // + return result; + } + + // + bool DetectNearestDeltaSwitched( + XOHCL &bar, + ENUM_X_DIRECTION &dir, + int barIndex = 0, + int maxAllowedBars = 20 // + ) + { + // + bool result = false; + + // + bar.Clean(); + dir = X_DIRECTION_NONE; + barIndex = NormalizeInt(barIndex, 0); + maxAllowedBars = NormalizeInt(maxAllowedBars, 20); + + // + // Looping Through LoopBack Period ... + // for Detecting Result ... + for (int i = barIndex; i < barIndex + maxAllowedBars; i++) + { + // + XOHCL iBar; + result = iBar.Init( + GetSymbol(), + GetPeriod(), + i // + ); + if (!result) + { + // + iBar.Clean(); + break; + } + + // + double iDelta = mX121Helper.xdeltaHelper.GetDelta(i); + double iDeltaP = mX121Helper.xdeltaHelper.GetDelta(i + 1); + + // + double iDeltaMa = mX121Helper.xdeltaHelper.GetDeltaMa(i); + double iDeltaMaP = mX121Helper.xdeltaHelper.GetDeltaMa(i + 1); + + // + bool isDeltaOverMa = iDelta > iDeltaMa; + bool isDeltaOverMaP = iDeltaP > iDeltaMaP; + + // + bool isDeltaUnderMa = iDelta < iDeltaMa; + bool isDeltaUnderMaP = iDeltaP < iDeltaMaP; + + // + bool isCrossOver = isDeltaOverMa && + !isDeltaOverMaP; + + // + bool isCrossUnder = isDeltaUnderMa && + !isDeltaUnderMaP; + + // + result = isCrossOver || + isCrossUnder; + if (result) + { + // + bar = iBar; + + // + dir = isCrossOver + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + iBar.Clean(); + break; + } + + // + iBar.Clean(); + } + + // + return result; + } + + // + bool DetectNearestStrSwitched( + XOHCL &bar, + ENUM_X_DIRECTION &dir, + int barIndex = 0, + int maxAllowedBars = 20 // + ) + { + // + bool result = false; + + // + bar.Clean(); + dir = X_DIRECTION_NONE; + barIndex = NormalizeInt(barIndex, 0); + maxAllowedBars = NormalizeInt(maxAllowedBars, 20); + + // + // Looping Through LoopBack Period ... + // for Detecting Result ... + for (int i = barIndex; i < barIndex + maxAllowedBars; i++) + { + // + XOHCL iBar; + result = iBar.Init( + GetSymbol(), + GetPeriod(), + i // + ); + if (!result) + { + // + iBar.Clean(); + break; + } + + // + double iStrState = mX121Helper.xstrHelper.GetSTRState(i); + double iStrStateP = mX121Helper.xstrHelper.GetSTRState(i + 1); + + // + bool isStrBullish = iStrState > 0; + bool isStrBullishP = iStrStateP > 0; + + // + bool isStrBearish = iStrState < 0; + bool isStrBearishP = iStrStateP < 0; + + // + bool isBullish = isStrBullish && + !isStrBullishP; + + // + bool isBearish = isStrBearish && + !isStrBearishP; + + // + result = isBullish || + isBearish; + if (result) + { + // + bar = iBar; + + // + dir = isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + iBar.Clean(); + break; + } + + // + iBar.Clean(); + } + + // + return result; + } + // // Virtuals ... @@ -2411,7 +2661,7 @@ struct X121SMCStrategyConditionParser // // Rejected Boxes ... - bool HasRejectedBoxConditions( + bool HasRejectedBocXConditions( ENUM_X_CYCLES cycle, XSignalBox &box, ENUM_X_DIRECTION &dir, @@ -2702,7 +2952,7 @@ struct X121SMCStrategyConditionParser // // Activated Boxes ... - bool HasActivatedBoxConditions( + bool HasActivatedBocXConditions( ENUM_X_CYCLES cycle, XSignalBox &box, ENUM_X_DIRECTION &dir, @@ -3017,7 +3267,7 @@ struct X121SMCStrategyConditionParser // // Breaked Boxes ... - bool HasBreakedBoxConditions( + bool HasBreakedBocXConditions( ENUM_X_CYCLES cycle, XSignalBox &box, ENUM_X_DIRECTION &dir, @@ -4069,5 +4319,310 @@ struct X121SMCStrategyConditionParser return result; } + // + bool HasXICHConditions( + ENUM_X_CYCLES cycle, + XBoxZone &box, + ENUM_X_DIRECTION &dir, + X121SMCStrategySignalProviderData &provider, + int barIndex = 0 // + ) + { + // + bool result = false; + + // + box.Clean(); + dir = X_DIRECTION_NONE; + + // + // Fil Selected Data ... + XPOIState cState; + X121Conditions cXConditions; + XPOIStateEvents cStateEvents; + XC121SMCCycleHelper *cHelper; + X121SMCCycleConditions cConditions; + result = provider.SelectCycle( + cycle, + cState, + cStateEvents, + cXConditions, + cHelper, + cConditions // + ); + if (!result) + { + // + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + cStateEvents.Clean(); + + // + return result; + } + Parse(cXConditions); + + // + // Normalize Args ... + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + int idx = -1; + int count = 0; + bool has = false; + + // + int zIDX = barIndex; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int ppIDX = pIDX + 1; + + // + bool isBullish = false; + bool isBearish = false; + + // + XOHCL zBar; + XOHCL cBar; + XOHCL pBar; + XOHCL pPBar; + + // + // Initial Bars ... + result = zBar.Init( + cState.symbol, + cState.period, + barIndex // + ); + result = + result && + zBar.GetPreviousBar(cBar); + result = + result && + cBar.GetPreviousBar(pBar); + result = + result && + pBar.GetPreviousBar(pPBar); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + // Checking Conditions ... + // + // XDELTA ... + + // + bool isDeltaSwitchedToBullish = + (cXConditions.isDeltaCrossedOverMa && + cXConditions.isDeltaSwitchedToBullish); + bool isDeltaBullish = + (cXConditions.isDeltaOverMa && + cXConditions.isDeltaBullish); + bool isDeltaIsBullish = + isDeltaBullish || + isDeltaSwitchedToBullish; + + // + bool isDeltaSwitchedToBearish = + (cXConditions.isDeltaCrossedUnderMa && + cXConditions.isDeltaSwitchedToBearish); + bool isDeltaBearish = + (cXConditions.isDeltaUnderMa && + cXConditions.isDeltaBearish); + bool isDeltaIsBearish = + isDeltaBearish || + isDeltaSwitchedToBearish; + + // + // XVOLUME ... + + // + bool isVolumeSwitchedToBullish = + (cXConditions.isVolumeSwitchedToBullish && + cXConditions.isBullishVolumeSwitchedToIncreased); + bool isVolumeBullish = + (cXConditions.isBullishVolumeIncreased && + cXConditions.isBullishVolumeMaOverBearishVolumeMa); + bool isVolumeIsBullish = + isVolumeBullish || + isVolumeSwitchedToBullish; + + // + bool isVolumeSwitchedToBearish = + (cXConditions.isVolumeSwitchedToBearish && + cXConditions.isBearishVolumeSwitchedToIncreased); + bool isVolumeBearish = + (cXConditions.isBullishVolumeMaUnderBearishVolumeMa && + cXConditions.isBearishVolumeIncreased); + bool isVolumeIsBearish = + isVolumeBearish || + isVolumeSwitchedToBearish; + + // + // XSTR ... + bool isStrIsBullish = + (cXConditions.isStrBullish || + cXConditions.isStrSwitchedToBullish); + bool isStrIsBearish = + (cXConditions.isStrBearish || + cXConditions.isStrSwitchedToBearish); + + // + // XICH ... + bool isIchIsBullish = + (cXConditions.isTenkanSenOverKijunSen || + cXConditions.isTenkanSenCrossedOverKijunSen); + bool isIchIsBearish = + (cXConditions.isTenkanSenUnderKijunSen || + cXConditions.isTenkanSenCrossedUnderKijunSen); + + // + // Checking TK Zone ... + + // + bool isBullishTKZone = + isIchIsBullish && + cBar.low < cXConditions.tenkanSenBuffer[cIndex] && + cBar.low > cXConditions.kijunSenBuffer[cIndex] && + cBar.low < pBar.low && + zBar.open > cBar.low; + + // + bool isBearishTKZone = + isIchIsBearish && + cBar.high > cXConditions.tenkanSenBuffer[cIndex] && + cBar.high < cXConditions.kijunSenBuffer[cIndex] && + cBar.high > pBar.high && + zBar.open < cBar.high; + + // + // Summarize Conditions ... + + // + isBullish = + // + // false + isStrIsBullish && + isIchIsBullish && + isBullishTKZone && + isDeltaIsBullish && + isVolumeIsBullish + // + // + ; + + // + isBearish = + // + // false + isStrIsBearish && + isIchIsBearish && + isBearishTKZone && + isDeltaIsBearish && + isVolumeIsBearish + // + ; + + // + // Filling Requirements ... + result = + isBullish || + isBearish; + if (result) + { + // + dir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + box.dir = dir; + box.from = pPBar.time; + box.to = TimeCurrent(); + box.symbol = cBar.symbol; + box.period = cBar.period; + + // + pivot = isBullish + ? cBar.low - (points * 5) + : cBar.high + (points * 5); + + // + point = GetEntry( + cBar.symbol, + signalBoxDir // + ); + + // + box.upper = + isBullish + ? point + : pivot; + + // + box.lower = + isBullish + ? pivot + : point; + + // + bool drawBoxes = true; + if (drawBoxes) + { + // + } + + // + Print("Signal ..."); + result = false; + isBearish = false; + isBullish = false; + } + + // + // Check All Conditions ... + result = + box.IsValid() && + HasDirection(dir) && + (isBullish || + isBearish); + + // + // Cleanup Resources ... + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + pPBar.Clean(); + cState.Clean(); + cConditions.Clean(); + cConditions.Clean(); + ZeroMemory(cHelper); + cStateEvents.Clean(); + cXConditions.Clean(); + + // + return result; + } + // }; diff --git a/X121SMCEA/Signals/x-121.smc.xich.signal.class.mq5 b/X121SMCEA/Signals/x-121.smc.xich.signal.class.mq5 index da38ac73..55ea9973 100644 --- a/X121SMCEA/Signals/x-121.smc.xich.signal.class.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xich.signal.class.mq5 @@ -206,157 +206,23 @@ class XCX121SMCXICHSignalDetector : public XCBase // // - // Update Models To Time ... - UpdateTo(cTime); + // Provider XTkKumo ... + X121SMCStrategyConditionParser cParser; + hasSignalBox = cParser.HasXICHConditions( + X_CYCLE_ANALYSE, + signalBox, + signalBoxDir, + provider, + zIndex // + ); + if (hasSignalBox) + { + signalProvider = X121SMC_XICH_PROVIDER_XTKKUMO; + } // - // Here we Detect Signal Box ... - if (!hasSignalBox) - { - // - // HTF Proves ... - - // - double scoreMultiplier = 1.5; - - // - bool isConsolidationScoreBullish = - provider.consolidationBullishScore > (provider.consolidationBearishScore * scoreMultiplier); - - // - bool isConsolidationScoreBearish = - provider.consolidationBearishScore > (provider.consolidationBullishScore * scoreMultiplier); - - // - // Detect Kumo Trend ... - bool isKumoBullish = provider.decisionXConditions.isSenkouSpanAOverB; - bool isKumoBearish = provider.decisionXConditions.isSenkouSpanAUnderB; - - // - // Detect Nearest Cross ... - XOHCL tkCrossedBar; - ENUM_X_DIRECTION tkCrossDir; - bool hasNearestTenkanSenKijunSenCross = - provider - .decisionCycleHelper - .DetectNearestTenKijCross( - tkCrossedBar, - tkCrossDir, - zIndex // - ); - - // - bool isNearestTenkensSenCrossedOverKijunSen = - hasNearestTenkanSenKijunSenCross && - IsBullish(tkCrossDir); - - // - bool isNearestTenkensSenCrossedUnderKijunSen = - hasNearestTenkanSenKijunSenCross && - IsBearish(tkCrossDir); - - // - // Detect Price in TK Zone ... - bool isBarInsideTKZone = - isNearestTenkensSenCrossedOverKijunSen - ? cBar.low < provider.decisionXConditions.tenkanSenBuffer[cIndex] - : isNearestTenkensSenCrossedUnderKijunSen - ? cBar.high > provider.decisionXConditions.tenkanSenBuffer[cIndex] - : false; - - // - // Checking Bar Based on Positions State ... - ENUM_X_DIRECTION iBarPosDir; - bool isBarValidForDir = provider.decisionCycleHelper - .mBarAnalyser - .IsValidForPosition( - cBar, - iBarPosDir // - ); - bool isBarValidForBullish = - isBarValidForDir && - IsBullish(iBarPosDir); - bool isBarValidForBearish = - isBarValidForDir && - IsBearish(iBarPosDir); - - // - // Summarize Conditions ... - - // - isBullish = - // - isKumoBullish && - isBarInsideTKZone && - isBarValidForBullish && - isConsolidationScoreBullish && - isNearestTenkensSenCrossedOverKijunSen - // - ; - - // - isBearish = - // - isKumoBearish && - isBarInsideTKZone && - isBarValidForBearish && - isConsolidationScoreBearish && - isNearestTenkensSenCrossedUnderKijunSen - // - ; - - // - result = - isBullish || - isBearish; - if (result) - { - // - signalProvider = X121SMC_XICH_PROVIDER_XTKKUMO; - - // - signalBoxDir = - isBullish - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - - // - signalBox.from = pPBar.time; - signalBox.to = TimeCurrent(); - signalBox.dir = signalBoxDir; - signalBox.symbol = cBar.symbol; - signalBox.period = cBar.period; - - // - pivot = isBullish - ? cBar.low - (points * 5) - : cBar.high + (points * 5); - - // - point = GetEntry( - cBar.symbol, - signalBoxDir // - ); - - // - signalBox.upper = - isBullish - ? point - : pivot; - - // - signalBox.lower = - isBullish - ? pivot - : point; - } - - // - hasSignalBox = signalBox.IsValid(); - - // - tkCrossedBar.Clean(); - } + // Update Models To Time ... + UpdateTo(cTime); // // Cleanup Signal if UnApproved ... @@ -370,8 +236,11 @@ class XCX121SMCXICHSignalDetector : public XCBase } // - // Check Signal Conditions ... - if (hasSignalBox) + // Summarize Results ... + result = hasSignalBox; + + // + if (result) { // int idx = -1; @@ -437,7 +306,7 @@ class XCX121SMCXICHSignalDetector : public XCBase // // Fix rf Reward ... - rfRewar = 2; + rfRewar = 1.5; } // @@ -488,18 +357,7 @@ class XCX121SMCXICHSignalDetector : public XCBase targets // ); } - } - // - // Summarize Results ... - // result = hasPriority && - // hasSignalBox && - // hasRewardAmount; - result = hasSignalBox; - - // - if (result) - { // Copy( sls, @@ -531,6 +389,9 @@ class XCX121SMCXICHSignalDetector : public XCBase Clean(sls); Clean(targets); + // + cParser.Clean(); + // provider.Clean(); diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 index 72a78154..b4e877cc 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 @@ -2184,6 +2184,9 @@ struct X121SMCStrategyXWZWorkingZone box.Clean(); } + // + cPraser.Clean(); + // return result; } diff --git a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 index 9328cf9c..cdd3d7bb 100644 --- a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 +++ b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 @@ -999,7 +999,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy x121Inputs.xichInputs.shiftKumo = true; // - x121Inputs.showRSI = showAll || false; + x121Inputs.showRSI = showAll || true; // // x121Inputs.xcheInputs.cheLength = 14; @@ -1058,7 +1058,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // XSTR ... - x121Inputs.xstrInputs.showStr = showAll || false; + x121Inputs.xstrInputs.showStr = showAll || true; x121Inputs.xstrInputs.showStrUpper = showAll || false; x121Inputs.xstrInputs.showStrLower = showAll || false; @@ -1092,10 +1092,12 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // XICH ... x121Inputs.xichInputs.showTenkanSen = showAll || true; x121Inputs.xichInputs.showKijunSen = showAll || true; - x121Inputs.xichInputs.showChikouSpan = showAll || true; - x121Inputs.xichInputs.showSenkouSpanA = showAll || true; - x121Inputs.xichInputs.showSenkouSpanB = showAll || true; - x121Inputs.xichInputs.showKumo = showAll || true; + x121Inputs.xichInputs.showChikouSpan = showAll || false; + x121Inputs.xichInputs.showSenkouSpanA = showAll || false; + x121Inputs.xichInputs.showSenkouSpanB = showAll || false; + x121Inputs.xichInputs.showKumo = showAll || false; + + // // // Initialize Cycle Helpers ...