RecentSwingHighLowX by Naya
592 downloads / 353 views / Created: 06.06.2025 Average Rating: 0
Indicator Description
Recent Swing High Low X is a custom technical indicator that identifies recent swing highs and lows in price action. It helps traders spot potential reversal points or trend continuation signals.
Key Features:
- Detects swing highs and lows based on a specified number of surrounding bars
- Allows vertical price adjustment (shift in points) above/below the swings
- Includes bar shifting capability to project swings forward
- Offers multiple trading logics for entries, exits, and filters
- Works in all trading slots (open, close, and their filters)
Parameters:
1. Vertical shift - adjusts the swing levels up/down by points
2. Bars - determines how many adjacent bars to consider when identifying swings
3. Bar shift - projects the swing levels forward in time
The indicator can generate trading signals based on price interaction with these levels or their directional movement.
Created by NAYA, this enhanced version includes unified bars handling, bar shifting, and additional swing rise/fall logics not found in existing RecentSwingHighLow indicators.
Key Features:
- Detects swing highs and lows based on a specified number of surrounding bars
- Allows vertical price adjustment (shift in points) above/below the swings
- Includes bar shifting capability to project swings forward
- Offers multiple trading logics for entries, exits, and filters
- Works in all trading slots (open, close, and their filters)
Parameters:
1. Vertical shift - adjusts the swing levels up/down by points
2. Bars - determines how many adjacent bars to consider when identifying swings
3. Bar shift - projects the swing levels forward in time
The indicator can generate trading signals based on price interaction with these levels or their directional movement.
Created by NAYA, this enhanced version includes unified bars handling, bar shifting, and additional swing rise/fall logics not found in existing RecentSwingHighLow indicators.
Comments
//==============================================================
// Forex Strategy Builder
// Copyright © Miroslav Popov. All rights reserved.
//==============================================================
// THIS CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
//==============================================================
using System;
using System.Drawing;
using ForexStrategyBuilder.Infrastructure.Entities;
using ForexStrategyBuilder.Infrastructure.Enums;
using ForexStrategyBuilder.Infrastructure.Interfaces;
namespace ForexStrategyBuilder.Indicators.Store
{
public class RecentSwingHighLowX : Indicator
{
public RecentSwingHighLowX()
{
IndicatorName = "Recent Swing High Low X";
PossibleSlots = SlotTypes.Open | SlotTypes.OpenFilter | SlotTypes.Close | SlotTypes.CloseFilter;
IndicatorAuthor = "NAYA,+237674724684";
IndicatorVersion = "1.0";
IndicatorDescription = "Custom with unified bars, bar shift, and new swing rise/fall logics";
}
public override void Initialize(SlotTypes slotType)
{
SlotType = slotType;
// The ComboBox parameters
IndParam.ListParam[0].Caption = "Logic";
if (slotType == SlotTypes.Open)
IndParam.ListParam[0].ItemList = new[]
{
"Enter long at swing high",
"Enter long at swing low"
};
else if (slotType == SlotTypes.OpenFilter)
IndParam.ListParam[0].ItemList = new[]
{
"The bar opens below swing high",
"The bar opens above swing high",
"The bar opens below swing low",
"The bar opens above swing low",
"The bar opens below swing high after opening above it",
"The bar opens above swing high after opening below it",
"The bar opens below swing low after opening above it",
"The bar opens above swing low after opening below it",
"Swing high rises",
"Swing high falls",
"Swing low rises",
"Swing low falls"
};
else if (slotType == SlotTypes.Close)
IndParam.ListParam[0].ItemList = new[]
{
"Exit long at swing high",
"Exit long at swing low"
};
else if (slotType == SlotTypes.CloseFilter)
IndParam.ListParam[0].ItemList = new[]
{
"The bar closes below swing high",
"The bar closes above swing high",
"The bar closes below swing low",
"The bar closes above swing low",
"Swing high rises",
"Swing high falls",
"Swing low rises",
"Swing low falls"
};
else
IndParam.ListParam[0].ItemList = new[]
{
"Not Defined"
};
IndParam.ListParam[0].Index = 0;
IndParam.ListParam[0].Text = IndParam.ListParam[0].ItemList[0];
IndParam.ListParam[0].Enabled = true;
IndParam.ListParam[0].ToolTip = "Logic of application of the indicator";
// NumericUpDown parameters
IndParam.NumParam[0].Caption = "Vertical shift (in points)";
IndParam.NumParam[0].Value = 0;
IndParam.NumParam[0].Min = -2000;
IndParam.NumParam[0].Max = 2000;
IndParam.NumParam[0].Enabled = true;
IndParam.NumParam[0].ToolTip = "Vertical shift above swing high and below swing low price.";
IndParam.NumParam[1].Caption = "Bars";
IndParam.NumParam[1].Value = 2;
IndParam.NumParam[1].Min = 1;
IndParam.NumParam[1].Max = 50;
IndParam.NumParam[1].Enabled = true;
IndParam.NumParam[1].ToolTip = "Number of bars to the left and right to confirm a swing.";
IndParam.NumParam[2].Caption = "Bar shift";
IndParam.NumParam[2].Value = 0;
IndParam.NumParam[2].Min = 0;
IndParam.NumParam[2].Max = 100;
IndParam.NumParam[2].Enabled = true;
IndParam.NumParam[2].ToolTip = "How many bars to shift the swing levels forward.";
}
public override void Calculate(IDataSet dataSet)
{
DataSet = dataSet;
int previous = 0;
double shiftPrice = IndParam.NumParam[0].Value * Point;
int bars = (int)IndParam.NumParam[1].Value;
int barShift = (int)IndParam.NumParam[2].Value;
// Compute raw swing arrays
double[] upperRaw = new double[Bars];
double[] lowerRaw = new double[Bars];
int firstRaw = 2 * bars + 1;
for (int bar = firstRaw; bar < Bars; bar++)
{
int candidate = bar - (bars + 1);
bool isHigh = true;
bool isLow = true;
// Left side check
for (int i = 1; i <= bars; i++)
{
if (High[candidate] < High[candidate - i]) isHigh = false;
if (Low[candidate] > Low[candidate - i]) isLow = false;
}
// Right side check
for (int i = 1; i <= bars; i++)
{
if (High[candidate] <= High[candidate + i]) isHigh = false;
if (Low[candidate] >= Low[candidate + i]) isLow = false;
}
if (isHigh)
upperRaw[bar] = High[candidate] + shiftPrice;
else
upperRaw[bar] = upperRaw[bar - 1];
if (isLow)
lowerRaw[bar] = Low[candidate] + shiftPrice;
else
lowerRaw[bar] = lowerRaw[bar - 1];
}
// Build shifted arrays
double[] upperShifted = new double[Bars];
double[] lowerShifted = new double[Bars];
// Initialize by carrying forward prior values
for (int i = 0; i < Bars; i++)
{
if (i == 0)
{
upperShifted[i] = 0.0;
lowerShifted[i] = 0.0;
}
else
{
upperShifted[i] = upperShifted[i - 1];
lowerShifted[i] = lowerShifted[i - 1];
}
}
int firstShifted = firstRaw + barShift;
for (int bar = firstRaw; bar < Bars; bar++)
{
int target = bar + barShift;
if (target < Bars)
{
upperShifted[target] = upperRaw[bar];
lowerShifted[target] = lowerRaw[bar];
}
}
// Propagate over any gaps after shift
for (int i = 1; i < Bars; i++)
{
if (upperShifted[i] == 0.0 && i > firstShifted)
upperShifted[i] = upperShifted[i - 1];
if (lowerShifted[i] == 0.0 && i > firstShifted)
lowerShifted[i] = lowerShifted[i - 1];
}
// Create components array
Component = new IndicatorComp[4];
// Component[0]: Swing high
Component[0] = new IndicatorComp
{
CompName = "Swing high",
DataType = IndComponentType.IndicatorValue,
ChartType = IndChartType.Level,
ChartColor = Color.Blue,
FirstBar = firstShifted,
Value = upperShifted
};
// Component[1]: Swing low
Component[1] = new IndicatorComp
{
CompName = "Swing low",
DataType = IndComponentType.IndicatorValue,
ChartType = IndChartType.Level,
ChartColor = Color.Red,
FirstBar = firstShifted,
Value = lowerShifted
};
// Component[2] & [3] placeholders
Component[2] = new IndicatorComp
{
ChartType = IndChartType.NoChart,
FirstBar = firstShifted,
Value = new double[Bars]
};
Component[3] = new IndicatorComp
{
ChartType = IndChartType.NoChart,
FirstBar = firstShifted,
Value = new double[Bars]
};
// Assign data types based on slot
switch (SlotType)
{
case SlotTypes.Open:
Component[2].DataType = IndComponentType.OpenLongPrice;
Component[2].CompName = "Long position entry price";
Component[3].DataType = IndComponentType.OpenShortPrice;
Component[3].CompName = "Short position entry price";
break;
case SlotTypes.OpenFilter:
Component[2].DataType = IndComponentType.AllowOpenLong;
Component[2].CompName = "Is long entry allowed";
Component[3].DataType = IndComponentType.AllowOpenShort;
Component[3].CompName = "Is short entry allowed";
break;
case SlotTypes.Close:
Component[2].DataType = IndComponentType.CloseLongPrice;
Component[2].CompName = "Long position closing price";
Component[3].DataType = IndComponentType.CloseShortPrice;
Component[3].CompName = "Short position closing price";
break;
case SlotTypes.CloseFilter:
Component[2].DataType = IndComponentType.ForceCloseLong;
Component[2].CompName = "Close out long position";
Component[3].DataType = IndComponentType.ForceCloseShort;
Component[3].CompName = "Close out short position";
break;
}
// Fill entry/exit or filter logic
if (SlotType == SlotTypes.Open || SlotType == SlotTypes.Close)
{
for (int bar = firstShifted; bar < Bars; bar++)
{
if (IndParam.ListParam[0].Text == "Enter long at swing high" ||
IndParam.ListParam[0].Text == "Exit long at swing high")
{
Component[2].Value[bar] = upperShifted[bar - previous];
Component[3].Value[bar] = lowerShifted[bar - previous];
}
else
{
Component[2].Value[bar] = lowerShifted[bar - previous];
Component[3].Value[bar] = upperShifted[bar - previous];
}
}
}
else
{
// OpenFilter or CloseFilter
string logic = IndParam.ListParam[0].Text;
switch (logic)
{
case "The bar opens below swing high":
BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted,
ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_below_the_Upper_Band);
break;
case "The bar opens above swing high":
BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted,
ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_above_the_Upper_Band);
break;
case "The bar opens below swing low":
BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted,
ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_below_the_Lower_Band);
break;
case "The bar opens above swing low":
BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted,
ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_above_the_Lower_Band);
break;
case "The bar opens below swing high after opening above it":
BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted,
ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_below_the_Upper_Band_after_opening_above_it);
break;
case "The bar opens above swing high after opening below it":
BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted,
ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_above_the_Upper_Band_after_opening_below_it);
break;
case "The bar opens below swing low after opening above it":
BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted,
ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_below_the_Lower_Band_after_opening_above_it);
break;
case "The bar opens above swing low after opening below it":
BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted,
ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_above_the_Lower_Band_after_opening_below_it);
break;
case "The bar closes below swing high":
BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted,
ref Component[2], ref Component[3],
BandIndLogic.The_bar_closes_below_the_Upper_Band);
break;
case "The bar closes above swing high":
BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted,
ref Component[2], ref Component[3],
BandIndLogic.The_bar_closes_above_the_Upper_Band);
break;
case "The bar closes below swing low":
BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted,
ref Component[2], ref Component[3],
BandIndLogic.The_bar_closes_below_the_Lower_Band);
break;
case "The bar closes above swing low":
BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted,
ref Component[2], ref Component[3],
BandIndLogic.The_bar_closes_above_the_Lower_Band);
break;
case "Swing high rises":
IndicatorRisesLogic(firstShifted, previous, upperShifted,
ref Component[2], ref Component[3]);
break;
case "Swing high falls":
IndicatorFallsLogic(firstShifted, previous, upperShifted,
ref Component[2], ref Component[3]);
break;
case "Swing low rises":
IndicatorRisesLogic(firstShifted, previous, lowerShifted,
ref Component[2], ref Component[3]);
break;
case "Swing low falls":
IndicatorFallsLogic(firstShifted, previous, lowerShifted,
ref Component[2], ref Component[3]);
break;
}
}
}
public override void SetDescription()
{
string paramDescr = string.Format("{0} bars, shift {1}, vertShift {2} pts",
IndParam.NumParam[1].ValueToString,
IndParam.NumParam[2].ValueToString,
IndParam.NumParam[0].ValueToString);
switch (IndParam.ListParam[0].Text)
{
case "Enter long at swing high":
EntryPointLongDescription = "at swing high (" + paramDescr + ")";
EntryPointShortDescription = "at swing low (" + paramDescr + ")";
break;
case "Enter long at swing low":
EntryPointLongDescription = "at swing low (" + paramDescr + ")";
EntryPointShortDescription = "at swing high (" + paramDescr + ")";
break;
case "Exit long at swing high":
ExitPointLongDescription = "at swing high (" + paramDescr + ")";
ExitPointShortDescription = "at swing low (" + paramDescr + ")";
break;
case "Exit long at swing low":
ExitPointLongDescription = "at swing low (" + paramDescr + ")";
ExitPointShortDescription = "at swing high (" + paramDescr + ")";
break;
case "The bar opens below swing high":
EntryFilterLongDescription = "the bar opens below swing high (" + paramDescr + ")";
EntryFilterShortDescription = "the bar opens above swing low (" + paramDescr + ")";
break;
case "The bar opens above swing high":
EntryFilterLongDescription = "the bar opens above swing high (" + paramDescr + ")";
EntryFilterShortDescription = "the bar opens below swing low (" + paramDescr + ")";
break;
case "The bar opens below swing low":
EntryFilterLongDescription = "the bar opens below swing low (" + paramDescr + ")";
EntryFilterShortDescription = "the bar opens above swing high (" + paramDescr + ")";
break;
case "The bar opens above swing low":
EntryFilterLongDescription = "the bar opens above swing low (" + paramDescr + ")";
EntryFilterShortDescription = "the bar opens below swing high (" + paramDescr + ")";
break;
case "The bar opens below swing high after opening above it":
EntryFilterLongDescription = "the bar opens below swing high (" + paramDescr + ") after the previous bar opened above it";
EntryFilterShortDescription = "the bar opens above swing low (" + paramDescr + ") after the previous bar opened below it";
break;
case "The bar opens above swing high after opening below it":
EntryFilterLongDescription = "the bar opens above swing high (" + paramDescr + ") after the previous bar opened below it";
EntryFilterShortDescription = "the bar opens below swing low (" + paramDescr + ") after the previous bar opened above it";
break;
case "The bar opens below swing low after opening above it":
EntryFilterLongDescription = "the bar opens below swing low (" + paramDescr + ") after the previous bar opened above it";
EntryFilterShortDescription = "the bar opens above swing high (" + paramDescr + ") after the previous bar opened below it";
break;
case "The bar opens above swing low after opening below it":
EntryFilterLongDescription = "the bar opens above swing low (" + paramDescr + ") after the previous bar opened below it";
EntryFilterShortDescription = "the bar opens below swing high (" + paramDescr + ") after the previous bar opened above it";
break;
case "The bar closes below swing high":
ExitFilterLongDescription = "the bar closes below swing high (" + paramDescr + ")";
ExitFilterShortDescription = "the bar closes above swing low (" + paramDescr + ")";
break;
case "The bar closes above swing high":
ExitFilterLongDescription = "the bar closes above swing high (" + paramDescr + ")";
ExitFilterShortDescription = "the bar closes below swing low (" + paramDescr + ")";
break;
case "The bar closes below swing low":
ExitFilterLongDescription = "the bar closes below swing low (" + paramDescr + ")";
ExitFilterShortDescription = "the bar closes above swing high (" + paramDescr + ")";
break;
case "The bar closes above swing low":
ExitFilterLongDescription = "the bar closes above swing low (" + paramDescr + ")";
ExitFilterShortDescription = "the bar closes below swing high (" + paramDescr + ")";
break;
case "Swing high rises":
EntryFilterLongDescription = "swing high rises (" + paramDescr + ")";
EntryFilterShortDescription = "swing low falls (" + paramDescr + ")";
ExitFilterLongDescription = "swing high rises (" + paramDescr + ")";
ExitFilterShortDescription = "swing low falls (" + paramDescr + ")";
break;
case "Swing high falls":
EntryFilterLongDescription = "swing high falls (" + paramDescr + ")";
EntryFilterShortDescription = "swing low rises (" + paramDescr + ")";
ExitFilterLongDescription = "swing high falls (" + paramDescr + ")";
ExitFilterShortDescription = "swing low rises (" + paramDescr + ")";
break;
case "Swing low rises":
EntryFilterLongDescription = "swing low rises (" + paramDescr + ")";
EntryFilterShortDescription = "swing high falls (" + paramDescr + ")";
ExitFilterLongDescription = "swing low rises (" + paramDescr + ")";
ExitFilterShortDescription = "swing high falls (" + paramDescr + ")";
break;
case "Swing low falls":
EntryFilterLongDescription = "swing low falls (" + paramDescr + ")";
EntryFilterShortDescription = "swing high rises (" + paramDescr + ")";
ExitFilterLongDescription = "swing low falls (" + paramDescr + ")";
ExitFilterShortDescription = "swing high rises (" + paramDescr + ")";
break;
}
}
public override string ToString()
{
return string.Format("{0}({1} bars, shift {2}, vertShift {3} pts)",
IndicatorName,
IndParam.NumParam[1].ValueToString,
IndParam.NumParam[2].ValueToString,
IndParam.NumParam[0].ValueToString);
}
}
}
//+--------------------------------------------------------------------+ //| RecentSwingHighLowX.mqh | //| Copyright © 2025, Generated by ChatGPT | //| Website: http://forexsb.com/ | //| Support: http://forexsb.com/forum/ | //| License: Proprietary under the following circumstances: | //| | //| This code is a part of Forex Strategy Builder. It is free for | //| use as an integral part of Forex Strategy Builder. | //| One can modify it in order to improve the code or to fit it for | //| personal use. This code or any part of it cannot be used in | //| other applications without a permission. | //| The contact information cannot be changed. | //| | //| NO LIABILITY FOR CONSEQUENTIAL DAMAGES | //| | //| In no event shall the author be liable for any damages whatsoever | //| (including, without limitation, incidental, direct, indirect and | //| consequential damages, damages for loss of business profits, | //| business interruption, loss of business information, or other | //| pecuniary loss) arising out of the use or inability to use this │ //| product, even if advised of the possibility of such damages. │ //+--------------------------------------------------------------------+ #property copyright "Copyright © 2025, ChatGPT" #property link "http://forexsb.com" #property version "1.00" #property strict #include <Forexsb.com/Indicator.mqh> #include <Forexsb.com/Enumerations.mqh> //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class RecentSwingHighLowX : public Indicator { public: RecentSwingHighLowX(SlotTypes slotType); virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| Constructor | //+------------------------------------------------------------------+ void RecentSwingHighLowX::RecentSwingHighLowX(SlotTypes slotType) { SlotType = slotType; IndicatorName = "Recent Swing High Low X"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDefaultGroupAll = false; } //+------------------------------------------------------------------+ //| Calculate method | //+------------------------------------------------------------------+ void RecentSwingHighLowX::Calculate(DataSet &dataSet) { Data = GetPointer(dataSet); // Read parameters int previous = 0; double shiftPrice = NumParam[0].Value * Data.Point; int bars = (int)NumParam[1].Value; int barShift = (int)NumParam[2].Value; int totalBars = Data.Bars; // Allocate raw swing arrays double upperRaw[]; ArrayResize(upperRaw, totalBars); ArrayInitialize(upperRaw, 0); double lowerRaw[]; ArrayResize(lowerRaw, totalBars); ArrayInitialize(lowerRaw, 0); int firstRaw = 2 * bars + 1; // Compute raw swings for(int bar = firstRaw; bar < totalBars; bar++) { int candidate = bar - (bars + 1); bool isHigh = true; bool isLow = true; // Check left side for(int i = 1; i <= bars; i++) { if(Data.High[candidate] < Data.High[candidate - i]) isHigh = false; if(Data.Low[candidate] > Data.Low[candidate - i]) isLow = false; } // Check right side for(int i = 1; i <= bars; i++) { if(Data.High[candidate] <= Data.High[candidate + i]) isHigh = false; if(Data.Low[candidate] >= Data.Low[candidate + i]) isLow = false; } if(isHigh) upperRaw[bar] = Data.High[candidate] + shiftPrice; else upperRaw[bar] = upperRaw[bar - 1]; if(isLow) lowerRaw[bar] = Data.Low[candidate] + shiftPrice; else lowerRaw[bar] = lowerRaw[bar - 1]; } // Allocate shifted arrays double upperShifted[]; ArrayResize(upperShifted, totalBars); ArrayInitialize(upperShifted, 0); double lowerShifted[]; ArrayResize(lowerShifted, totalBars); ArrayInitialize(lowerShifted, 0); // Initialize shifted arrays by carrying forward for(int i = 1; i < totalBars; i++) { upperShifted[i] = upperShifted[i - 1]; lowerShifted[i] = lowerShifted[i - 1]; } int firstShifted = firstRaw + barShift; // Shift raw into shifted arrays for(int bar = firstRaw; bar < totalBars; bar++) { int target = bar + barShift; if(target < totalBars) { upperShifted[target] = upperRaw[bar]; lowerShifted[target] = lowerRaw[bar]; } } // Propagate over gaps after shift for(int i = firstShifted + 1; i < totalBars; i++) { if(upperShifted[i] == 0.0) upperShifted[i] = upperShifted[i - 1]; if(lowerShifted[i] == 0.0) lowerShifted[i] = lowerShifted[i - 1]; } // Create components array ArrayResize(Component, 4); // Component[0]: Swing high ArrayResize(Component[0].Value, totalBars); Component[0].CompName = "Swing high"; Component[0].DataType = IndComponentType_IndicatorValue; Component[0].FirstBar = firstShifted; ArrayCopy(Component[0].Value, upperShifted); // Component[1]: Swing low ArrayResize(Component[1].Value, totalBars); Component[1].CompName = "Swing low"; Component[1].DataType = IndComponentType_IndicatorValue; Component[1].FirstBar = firstShifted; ArrayCopy(Component[1].Value, lowerShifted); // Component[2] & Component[3]: placeholders for entry/exit or filter logic ArrayResize(Component[2].Value, totalBars); ArrayInitialize(Component[2].Value, 0); Component[2].FirstBar = firstShifted; ArrayResize(Component[3].Value, totalBars); ArrayInitialize(Component[3].Value, 0); Component[3].FirstBar = firstShifted; // Assign data types based on slot if(SlotType == SlotTypes_Open) { Component[2].DataType = IndComponentType_OpenLongPrice; Component[2].CompName = "Long position entry price"; Component[3].DataType = IndComponentType_OpenShortPrice; Component[3].CompName = "Short position entry price"; } else if(SlotType == SlotTypes_OpenFilter) { Component[2].DataType = IndComponentType_AllowOpenLong; Component[2].CompName = "Is long entry allowed"; Component[3].DataType = IndComponentType_AllowOpenShort; Component[3].CompName = "Is short entry allowed"; } else if(SlotType == SlotTypes_Close) { Component[2].DataType = IndComponentType_CloseLongPrice; Component[2].CompName = "Long position closing price"; Component[3].DataType = IndComponentType_CloseShortPrice; Component[3].CompName = "Short position closing price"; } else if(SlotType == SlotTypes_CloseFilter) { Component[2].DataType = IndComponentType_ForceCloseLong; Component[2].CompName = "Close out long position"; Component[3].DataType = IndComponentType_ForceCloseShort; Component[3].CompName = "Close out short position"; } // Fill entry/exit or filter logic if(SlotType == SlotTypes_Open || SlotType == SlotTypes_Close) { for(int bar = firstShifted; bar < totalBars; bar++) { string logic = ListParam[0].Text; if(logic == "Enter long at swing high" || logic == "Exit long at swing high") { Component[2].Value[bar] = upperShifted[bar - previous]; Component[3].Value[bar] = lowerShifted[bar - previous]; } else { Component[2].Value[bar] = lowerShifted[bar - previous]; Component[3].Value[bar] = upperShifted[bar - previous]; } } } else { string logic = ListParam[0].Text; if(logic == "The bar opens below swing high") BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted, Component[2], Component[3], BandIndLogic_The_bar_opens_below_the_Upper_Band); else if(logic == "The bar opens above swing high") BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted, Component[2], Component[3], BandIndLogic_The_bar_opens_above_the_Upper_Band); else if(logic == "The bar opens below swing low") BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted, Component[2], Component[3], BandIndLogic_The_bar_opens_below_the_Lower_Band); else if(logic == "The bar opens above swing low") BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted, Component[2], Component[3], BandIndLogic_The_bar_opens_above_the_Lower_Band); else if(logic == "The bar opens below swing high after opening above it") BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted, Component[2], Component[3], BandIndLogic_The_bar_opens_below_Upper_Band_after_above); else if(logic == "The bar opens above swing high after opening below it") BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted, Component[2], Component[3], BandIndLogic_The_bar_opens_above_Upper_Band_after_below); else if(logic == "The bar opens below swing low after opening above it") BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted, Component[2], Component[3], BandIndLogic_The_bar_opens_below_Lower_Band_after_above); else if(logic == "The bar opens above swing low after opening below it") BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted, Component[2], Component[3], BandIndLogic_The_bar_opens_above_Lower_Band_after_below); else if(logic == "The bar closes below swing high") BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted, Component[2], Component[3], BandIndLogic_The_bar_closes_below_the_Upper_Band); else if(logic == "The bar closes above swing high") BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted, Component[2], Component[3], BandIndLogic_The_bar_closes_above_the_Upper_Band); else if(logic == "The bar closes below swing low") BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted, Component[2], Component[3], BandIndLogic_The_bar_closes_below_the_Lower_Band); else if(logic == "The bar closes above swing low") BandIndicatorLogic(firstShifted, previous, upperShifted, lowerShifted, Component[2], Component[3], BandIndLogic_The_bar_closes_above_the_Lower_Band); else if(logic == "Swing high rises") IndicatorRisesLogic(firstShifted, previous, upperShifted, Component[2], Component[3]); else if(logic == "Swing high falls") IndicatorFallsLogic(firstShifted, previous, upperShifted, Component[2], Component[3]); else if(logic == "Swing low rises") IndicatorRisesLogic(firstShifted, previous, lowerShifted, Component[2], Component[3]); else if(logic == "Swing low falls") IndicatorFallsLogic(firstShifted, previous, lowerShifted, Component[2], Component[3]); } } //+------------------------------------------------------------------+
Risk warning: Forex, spread bets and CFD are leveraged products. They may not be suitable for you as they carry a high degree of risk to your capital and you can lose more than your initial investment. You should ensure you understand all of the risks.
Copyright © 2006 - 2025, Forex Software Ltd.;
Copyright © 2006 - 2025, Forex Software Ltd.;