PivotPointsXStepped by Naya
586 downloads / 276 views / Created: 14.06.2025 Average Rating: 0
Indicator Description
This enhanced pivot points indicator calculates support and resistance levels across all major calculation methods, now including R4 and S4 levels for every pivot type.
Key Features
- Supports all standard pivot point formulas: Traditional, Woodie, Classic, Camarilla, Fibonacci, Standard (Floor), and Demark
- Includes R4 and S4 levels for every calculation method
- Vertical shift parameter for adjusting all levels up or down in steps
- Multiple base period options: One bar, Previous day, Previous week, Previous month
- Works for entries, exits, and filters
- All trading logic options now include R4 and S4 levels
Calculation Methods Extended
- Traditional, Woodie, and Classic: R4 and S4 extend the pattern from R3 and S3
- Fibonacci: Uses 1.618 multiplier for R4 and S4
- Standard: Continues the (High-Low) increment pattern
- Demark: Extended with a consistent increment approach
Usage
The indicator can be used for:
- Entry and exit signals at any pivot level (R4-R1, PP, S1-S4)
- Filter conditions based on price crossing pivot levels
This provides traders with a more complete pivot point analysis across all calculation methods, with consistent four-level support and resistance zones.
Key Features
- Supports all standard pivot point formulas: Traditional, Woodie, Classic, Camarilla, Fibonacci, Standard (Floor), and Demark
- Includes R4 and S4 levels for every calculation method
- Vertical shift parameter for adjusting all levels up or down in steps
- Multiple base period options: One bar, Previous day, Previous week, Previous month
- Works for entries, exits, and filters
- All trading logic options now include R4 and S4 levels
Calculation Methods Extended
- Traditional, Woodie, and Classic: R4 and S4 extend the pattern from R3 and S3
- Fibonacci: Uses 1.618 multiplier for R4 and S4
- Standard: Continues the (High-Low) increment pattern
- Demark: Extended with a consistent increment approach
Usage
The indicator can be used for:
- Entry and exit signals at any pivot level (R4-R1, PP, S1-S4)
- Filter conditions based on price crossing pivot levels
This provides traders with a more complete pivot point analysis across all calculation methods, with consistent four-level support and resistance zones.
Comments
using System;
using System.Collections.Generic;
using System.Drawing;
using ForexStrategyBuilder.Infrastructure.Entities;
using ForexStrategyBuilder.Infrastructure.Enums;
using ForexStrategyBuilder.Infrastructure.Interfaces;
namespace ForexStrategyBuilder.Indicators.Store
{
public class PivotPointsXStepped : Indicator
{
public PivotPointsXStepped()
{
IndicatorName = "Pivot Points X Stepped";
PossibleSlots = SlotTypes.Open | SlotTypes.OpenFilter | SlotTypes.Close | SlotTypes.CloseFilter;
SeparatedChart = false;
IndicatorAuthor = "NAYA, +237674724684";
IndicatorVersion = "2.2";
IndicatorDescription = "Extended Pivot Points with R4/S4 for all types and stepped vertical shift parameter.";
}
public override void Initialize(SlotTypes slotType)
{
SlotType = slotType;
IndParam.IndicatorType = TypeOfIndicator.Additional;
// The ComboBox parameters
IndParam.ListParam[0].Caption = "Logic";
if (slotType == SlotTypes.Open)
IndParam.ListParam[0].ItemList = new[]
{
"Enter long at R4 (short at S4)",
"Enter long at R3 (short at S3)",
"Enter long at R2 (short at S2)",
"Enter long at R1 (short at S1)",
"Enter the market at the Pivot Point",
"Enter long at S1 (short at R1)",
"Enter long at S2 (short at R2)",
"Enter long at S3 (short at R3)",
"Enter long at S4 (short at R4)"
};
else if (slotType == SlotTypes.OpenFilter)
IndParam.ListParam[0].ItemList = new[]
{
"The bar opens below an R4",
"The bar opens above an R4",
"The bar opens below an S4",
"The bar opens above an S4",
"The bar opens below an R4 after opening above it",
"The bar opens above an R4 after opening below it",
"The bar opens below an S4 after opening above it",
"The bar opens above an S4 after opening below it",
"The bar opens below an R3",
"The bar opens above an R3",
"The bar opens below an S3",
"The bar opens above an S3",
"The bar opens below an R3 after opening above it",
"The bar opens above an R3 after opening below it",
"The bar opens below an S3 after opening above it",
"The bar opens above an S3 after opening below it",
"The bar opens below an R2",
"The bar opens above an R2",
"The bar opens below an S2",
"The bar opens above an S2",
"The bar opens below an R2 after opening above it",
"The bar opens above an R2 after opening below it",
"The bar opens below an S2 after opening above it",
"The bar opens above an S2 after opening below it",
"The bar opens below an R1",
"The bar opens above an R1",
"The bar opens below an S1",
"The bar opens above an S1",
"The bar opens below an R1 after opening above it",
"The bar opens above an R1 after opening below it",
"The bar opens below an S1 after opening above it",
"The bar opens above an S1 after opening below it",
"The bar opens above the Pivot Point",
"The bar opens below the Pivot Point",
"The bar opens above the Pivot Point after opening below it",
"The bar opens below the Pivot Point after opening above it"
};
else if (slotType == SlotTypes.Close)
IndParam.ListParam[0].ItemList = new[]
{
"Exit long at R4 (short at S4)",
"Exit long at R3 (short at S3)",
"Exit long at R2 (short at S2)",
"Exit long at R1 (short at S1)",
"Exit the market at the Pivot Point",
"Exit long at S1 (short at R1)",
"Exit long at S2 (short at R2)",
"Exit long at S3 (short at R3)",
"Exit long at S4 (short at R4)"
};
else if (slotType == SlotTypes.CloseFilter)
IndParam.ListParam[0].ItemList = new[]
{
"The bar closes below an R4",
"The bar closes above an R4",
"The bar closes below an S4",
"The bar closes above an S4",
"The bar closes below an R3",
"The bar closes above an R3",
"The bar closes below an S3",
"The bar closes above an S3",
"The bar closes below an R2",
"The bar closes above an R2",
"The bar closes below an S2",
"The bar closes above an S2",
"The bar closes below an R1",
"The bar closes above an R1",
"The bar closes below an S1",
"The bar closes above an S1",
"The bar closes below the Pivot Point",
"The bar closes above the Pivot Point"
};
else
IndParam.ListParam[0].ItemList = new[] { "Not Defined" };
IndParam.ListParam[0].Index = 0;
IndParam.ListParam[0].Text = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index];
IndParam.ListParam[0].Enabled = true;
IndParam.ListParam[0].ToolTip = "Logic of application of the indicator";
IndParam.ListParam[1].Caption = "Pivot Type";
IndParam.ListParam[1].ItemList = new[]
{
"Traditional",
"Woodie",
"Classic",
"Camarilla",
"Fibonacci",
"Standard (Floor)",
"Demark"
};
IndParam.ListParam[1].Index = 0;
IndParam.ListParam[1].Text = IndParam.ListParam[1].ItemList[IndParam.ListParam[1].Index];
IndParam.ListParam[1].Enabled = true;
IndParam.ListParam[1].ToolTip = "Type of pivot points calculation";
IndParam.ListParam[2].Caption = "Base period";
IndParam.ListParam[2].ItemList = new[] { "One bar", "Previous day", "Previous week", "Previous month" };
IndParam.ListParam[2].Index = 1;
IndParam.ListParam[2].Text = IndParam.ListParam[2].ItemList[IndParam.ListParam[2].Index];
IndParam.ListParam[2].Enabled = true;
IndParam.ListParam[2].ToolTip = "The period prices are based on";
// Vertical Shift as List Parameter
IndParam.ListParam[3].Caption = "Vertical Shift";
var verticalShift = new List();
for (int i = -2000; i <= 2000; i += 20)
verticalShift.Add(i.ToString());
IndParam.ListParam[3].ItemList = verticalShift.ToArray();
IndParam.ListParam[3].Index = 20; // Default to 0
IndParam.ListParam[3].Text = IndParam.ListParam[3].ItemList[IndParam.ListParam[3].Index];
IndParam.ListParam[3].Enabled = true;
IndParam.ListParam[3].ToolTip = "The vertical shift in steps of 100.";
// The CheckBox parameters
IndParam.CheckParam[0].Caption = "Use previous bar value";
IndParam.CheckParam[0].Enabled = true;
IndParam.CheckParam[0].ToolTip = "Use the indicator value from the previous bar";
}
private bool IsPeriodChanged(int bar)
{
bool isPeriodChanged = false;
switch (IndParam.ListParam[2].Index)
{
case 0: // One bar
isPeriodChanged = true;
break;
case 1: // Previous day
isPeriodChanged = Time[bar].Day != Time[bar - 1].Day;
break;
case 2: // Previous week
isPeriodChanged = Period == DataPeriod.W1 ||
Time[bar].DayOfWeek <= DayOfWeek.Wednesday &&
Time[bar - 1].DayOfWeek > DayOfWeek.Wednesday;
break;
case 3: // Previous month
isPeriodChanged = Time[bar].Month != Time[bar - 1].Month;
break;
}
return isPeriodChanged;
}
public override void Calculate(IDataSet dataSet)
{
DataSet = dataSet;
// Reading the parameters
double shift = int.Parse(IndParam.ListParam[3].Text) * Point;
int previous = IndParam.CheckParam[0].Checked ? 1 : 0;
string pivotType = IndParam.ListParam[1].Text;
// Calculation
int firstBar = previous + 2;
var pp = new double[Bars];
var r1 = new double[Bars];
var r2 = new double[Bars];
var r3 = new double[Bars];
var r4 = new double[Bars];
var s1 = new double[Bars];
var s2 = new double[Bars];
var s3 = new double[Bars];
var s4 = new double[Bars];
var high = new double[Bars];
var low = new double[Bars];
var close = new double[Bars];
var open = new double[Bars];
if (IndParam.ListParam[2].Text == "One bar" || Period == DataPeriod.D1 || Period == DataPeriod.W1)
{
Array.Copy(High, high, Bars);
Array.Copy(Low, low, Bars);
Array.Copy(Close, close, Bars);
Array.Copy(Open, open, Bars);
}
else
{
previous = 0;
high[0] = 0;
low[0] = 0;
close[0] = 0;
open[0] = 0;
double top = double.MinValue;
double bottom = double.MaxValue;
for (int bar = 1; bar < Bars; bar++)
{
if (High[bar - 1] > top)
top = High[bar - 1];
if (Low[bar - 1] < bottom)
bottom = Low[bar - 1];
if (IsPeriodChanged(bar))
{
high[bar] = top;
low[bar] = bottom;
close[bar] = Close[bar - 1];
open[bar] = Open[bar - 1];
top = double.MinValue;
bottom = double.MaxValue;
}
else
{
high[bar] = high[bar - 1];
low[bar] = low[bar - 1];
close[bar] = close[bar - 1];
open[bar] = open[bar - 1];
}
}
// Find firstBar
for (int bar = 1; bar < Bars; bar++)
{
if (IsPeriodChanged(bar))
firstBar = bar;
}
}
for (int bar = firstBar; bar < Bars; bar++)
{
// Calculate pivot points based on selected type
if (pivotType == "Traditional")
{
pp[bar] = (high[bar] + low[bar] + close[bar]) / 3 + shift;
r1[bar] = (2 * pp[bar] - low[bar]) + shift;
s1[bar] = (2 * pp[bar] - high[bar]) - shift;
r2[bar] = (pp[bar] + high[bar] - low[bar]) + shift;
s2[bar] = (pp[bar] - high[bar] + low[bar]) - shift;
r3[bar] = (high[bar] + 2 * (pp[bar] - low[bar])) + shift;
s3[bar] = (low[bar] - 2 * (high[bar] - pp[bar])) - shift;
// Extended R4/S4 for Traditional
r4[bar] = r3[bar] + (high[bar] - low[bar]) + shift;
s4[bar] = s3[bar] - (high[bar] - low[bar]) - shift;
}
else if (pivotType == "Woodie")
{
pp[bar] = (high[bar] + low[bar] + 2 * open[bar]) / 4 + shift;
r1[bar] = (2 * pp[bar] - low[bar]) + shift;
s1[bar] = (2 * pp[bar] - high[bar]) - shift;
r2[bar] = (pp[bar] + high[bar] - low[bar]) + shift;
s2[bar] = (pp[bar] - high[bar] + low[bar]) - shift;
r3[bar] = high[bar] + 2 * (pp[bar] - low[bar]) + shift;
s3[bar] = low[bar] - 2 * (high[bar] - pp[bar]) - shift;
// Extended R4/S4 for Woodie
r4[bar] = r3[bar] + (high[bar] - low[bar]) + shift;
s4[bar] = s3[bar] - (high[bar] - low[bar]) - shift;
}
else if (pivotType == "Classic")
{
pp[bar] = (high[bar] + low[bar] + close[bar]) / 3 + shift;
r1[bar] = (2 * pp[bar] - low[bar]) + shift;
s1[bar] = (2 * pp[bar] - high[bar]) - shift;
r2[bar] = (pp[bar] + high[bar] - low[bar]) + shift;
s2[bar] = (pp[bar] - high[bar] + low[bar]) - shift;
r3[bar] = (pp[bar] + 2 * (high[bar] - low[bar])) + shift;
s3[bar] = (pp[bar] - 2 * (high[bar] - low[bar])) - shift;
// Extended R4/S4 for Classic
r4[bar] = r3[bar] + (high[bar] - low[bar]) + shift;
s4[bar] = s3[bar] - (high[bar] - low[bar]) - shift;
}
else if (pivotType == "Camarilla")
{
pp[bar] = (high[bar] + low[bar] + close[bar]) / 3 + shift;
r1[bar] = close[bar] + (high[bar] - low[bar]) * 1.1 / 12 + shift;
s1[bar] = close[bar] - (high[bar] - low[bar]) * 1.1 / 12 - shift;
r2[bar] = close[bar] + (high[bar] - low[bar]) * 1.1 / 6 + shift;
s2[bar] = close[bar] - (high[bar] - low[bar]) * 1.1 / 6 - shift;
r3[bar] = close[bar] + (high[bar] - low[bar]) * 1.1 / 4 + shift;
s3[bar] = close[bar] - (high[bar] - low[bar]) * 1.1 / 4 - shift;
r4[bar] = close[bar] + (high[bar] - low[bar]) * 1.1 / 2 + shift;
s4[bar] = close[bar] - (high[bar] - low[bar]) * 1.1 / 2 - shift;
}
else if (pivotType == "Fibonacci")
{
pp[bar] = (high[bar] + low[bar] + close[bar]) / 3 + shift;
r1[bar] = pp[bar] + 0.382 * (high[bar] - low[bar]) + shift;
s1[bar] = pp[bar] - 0.382 * (high[bar] - low[bar]) - shift;
r2[bar] = pp[bar] + 0.618 * (high[bar] - low[bar]) + shift;
s2[bar] = pp[bar] - 0.618 * (high[bar] - low[bar]) - shift;
r3[bar] = pp[bar] + 1.0 * (high[bar] - low[bar]) + shift;
s3[bar] = pp[bar] - 1.0 * (high[bar] - low[bar]) - shift;
// Extended R4/S4 for Fibonacci
r4[bar] = pp[bar] + 1.618 * (high[bar] - low[bar]) + shift;
s4[bar] = pp[bar] - 1.618 * (high[bar] - low[bar]) - shift;
}
else if (pivotType == "Standard (Floor)")
{
pp[bar] = (high[bar] + low[bar] + close[bar]) / 3 + shift;
r1[bar] = (2 * pp[bar]) - low[bar] + shift;
s1[bar] = (2 * pp[bar]) - high[bar] - shift;
r2[bar] = pp[bar] + (high[bar] - low[bar]) + shift;
s2[bar] = pp[bar] - (high[bar] - low[bar]) - shift;
r3[bar] = r1[bar] + (high[bar] - low[bar]) + shift;
s3[bar] = s1[bar] - (high[bar] - low[bar]) - shift;
// Extended R4/S4 for Standard
r4[bar] = r2[bar] + (high[bar] - low[bar]) + shift;
s4[bar] = s2[bar] - (high[bar] - low[bar]) - shift;
}
else if (pivotType == "Demark")
{
double x = 0;
if (close[bar] < open[bar])
x = high[bar] + 2 * low[bar] + close[bar];
else if (close[bar] > open[bar])
x = 2 * high[bar] + low[bar] + close[bar];
else
x = high[bar] + low[bar] + 2 * close[bar];
pp[bar] = x / 4 + shift;
r1[bar] = x / 2 - low[bar] + shift;
s1[bar] = x / 2 - high[bar] - shift;
// Extended R4/S4 for Demark (using similar logic to R1/S1)
r2[bar] = r1[bar] + (high[bar] - low[bar]) + shift;
s2[bar] = s1[bar] - (high[bar] - low[bar]) - shift;
r3[bar] = r2[bar] + (high[bar] - low[bar]) + shift;
s3[bar] = s2[bar] - (high[bar] - low[bar]) - shift;
r4[bar] = r3[bar] + (high[bar] - low[bar]) + shift;
s4[bar] = s3[bar] - (high[bar] - low[bar]) - shift;
}
}
// Always use 9 components now (R4-R1, PP, S1-S4)
Component = new IndicatorComp[11]; // 9 levels + 2 trading components
for (int iComp = 0; iComp < 9; iComp++)
{
Component[iComp] = new IndicatorComp
{
ChartType = IndChartType.Level,
ChartColor = iComp == 3 ? Color.Blue : Color.Violet,
DataType = IndComponentType.IndicatorValue,
FirstBar = firstBar,
Value = new double[Bars]
};
}
// Assign all levels
Component[0].Value = r4;
Component[1].Value = r3;
Component[2].Value = r2;
Component[3].Value = r1;
Component[4].Value = pp;
Component[5].Value = s1;
Component[6].Value = s2;
Component[7].Value = s3;
Component[8].Value = s4;
Component[0].CompName = "Resistance 4";
Component[1].CompName = "Resistance 3";
Component[2].CompName = "Resistance 2";
Component[3].CompName = "Resistance 1";
Component[4].CompName = "Pivot Point";
Component[5].CompName = "Support 1";
Component[6].CompName = "Support 2";
Component[7].CompName = "Support 3";
Component[8].CompName = "Support 4";
// Trading components
Component[9] = new IndicatorComp
{
ChartType = IndChartType.NoChart,
FirstBar = firstBar,
Value = new double[Bars]
};
Component[10] = new IndicatorComp
{
ChartType = IndChartType.NoChart,
FirstBar = firstBar,
Value = new double[Bars]
};
if (SlotType == SlotTypes.Open)
{
Component[9].CompName = "Long position entry price";
Component[9].DataType = IndComponentType.OpenLongPrice;
Component[10].CompName = "Short position entry price";
Component[10].DataType = IndComponentType.OpenShortPrice;
}
else if (SlotType == SlotTypes.OpenFilter)
{
Component[9].CompName = "Is long entry allowed";
Component[9].DataType = IndComponentType.AllowOpenLong;
Component[10].CompName = "Is short entry allowed";
Component[10].DataType = IndComponentType.AllowOpenShort;
}
else if (SlotType == SlotTypes.Close)
{
Component[9].CompName = "Long position closing price";
Component[9].DataType = IndComponentType.CloseLongPrice;
Component[10].CompName = "Short position closing price";
Component[10].DataType = IndComponentType.CloseShortPrice;
}
else if (SlotType == SlotTypes.CloseFilter)
{
Component[9].CompName = "Close out long position";
Component[9].DataType = IndComponentType.ForceCloseLong;
Component[10].CompName = "Close out short position";
Component[10].DataType = IndComponentType.ForceCloseShort;
}
// Trading logic for all levels including R4/S4
switch (IndParam.ListParam[0].Text)
{
case "Enter long at R4 (short at S4)":
case "Exit long at R4 (short at S4)":
for (int iBar = firstBar; iBar < Bars; iBar++)
{
Component[9].Value[iBar] = r4[iBar - previous];
Component[10].Value[iBar] = s4[iBar - previous];
}
break;
case "Enter long at R3 (short at S3)":
case "Exit long at R3 (short at S3)":
for (int iBar = firstBar; iBar < Bars; iBar++)
{
Component[9].Value[iBar] = r3[iBar - previous];
Component[10].Value[iBar] = s3[iBar - previous];
}
break;
case "Enter long at R2 (short at S2)":
case "Exit long at R2 (short at S2)":
for (int iBar = firstBar; iBar < Bars; iBar++)
{
Component[9].Value[iBar] = r2[iBar - previous];
Component[10].Value[iBar] = s2[iBar - previous];
}
break;
case "Enter long at R1 (short at S1)":
case "Exit long at R1 (short at S1)":
for (int iBar = firstBar; iBar < Bars; iBar++)
{
Component[9].Value[iBar] = r1[iBar - previous];
Component[10].Value[iBar] = s1[iBar - previous];
}
break;
case "Enter the market at the Pivot Point":
case "Exit the market at the Pivot Point":
for (int iBar = firstBar; iBar < Bars; iBar++)
{
Component[9].Value[iBar] = pp[iBar - previous];
Component[10].Value[iBar] = pp[iBar - previous];
}
break;
case "Enter long at S1 (short at R1)":
case "Exit long at S1 (short at R1)":
for (int iBar = firstBar; iBar < Bars; iBar++)
{
Component[9].Value[iBar] = s1[iBar - previous];
Component[10].Value[iBar] = r1[iBar - previous];
}
break;
case "Enter long at S2 (short at R2)":
case "Exit long at S2 (short at R2)":
for (int iBar = firstBar; iBar < Bars; iBar++)
{
Component[9].Value[iBar] = s2[iBar - previous];
Component[10].Value[iBar] = r2[iBar - previous];
}
break;
case "Enter long at S3 (short at R3)":
case "Exit long at S3 (short at R3)":
for (int iBar = firstBar; iBar < Bars; iBar++)
{
Component[9].Value[iBar] = s3[iBar - previous];
Component[10].Value[iBar] = r3[iBar - previous];
}
break;
case "Enter long at S4 (short at R4)":
case "Exit long at S4 (short at R4)":
for (int iBar = firstBar; iBar < Bars; iBar++)
{
Component[9].Value[iBar] = s4[iBar - previous];
Component[10].Value[iBar] = r4[iBar - previous];
}
break;
case "The bar opens below an R4":
BandIndicatorLogic(firstBar, previous, r4, s4, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Upper_Band);
break;
case "The bar opens above an R4":
BandIndicatorLogic(firstBar, previous, r4, s4, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Upper_Band);
break;
case "The bar opens below an S4":
BandIndicatorLogic(firstBar, previous, r4, s4, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Lower_Band);
break;
case "The bar opens above an S4":
BandIndicatorLogic(firstBar, previous, r4, s4, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Lower_Band);
break;
case "The bar closes below an R4":
BandIndicatorLogic(firstBar, previous, r4, s4, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_below_the_Upper_Band);
break;
case "The bar closes above an R4":
BandIndicatorLogic(firstBar, previous, r4, s4, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_above_the_Upper_Band);
break;
case "The bar closes below an S4":
BandIndicatorLogic(firstBar, previous, r4, s4, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_below_the_Lower_Band);
break;
case "The bar closes above an S4":
BandIndicatorLogic(firstBar, previous, r4, s4, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_above_the_Lower_Band);
break;
case "The bar opens below an R4 after opening above it":
BandIndicatorLogic(firstBar, previous, r4, s4, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Upper_Band_after_opening_above_it);
break;
case "The bar opens above an R4 after opening below it":
BandIndicatorLogic(firstBar, previous, r4, s4, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Upper_Band_after_opening_below_it);
break;
case "The bar opens below an S4 after opening above it":
BandIndicatorLogic(firstBar, previous, r4, s4, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Lower_Band_after_opening_above_it);
break;
case "The bar opens above an S4 after opening below it":
BandIndicatorLogic(firstBar, previous, r4, s4, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Lower_Band_after_opening_below_it);
break;
case "The bar opens below an R3":
BandIndicatorLogic(firstBar, previous, r3, s3, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Upper_Band);
break;
case "The bar opens above an R3":
BandIndicatorLogic(firstBar, previous, r3, s3, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Upper_Band);
break;
case "The bar opens below an S3":
BandIndicatorLogic(firstBar, previous, r3, s3, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Lower_Band);
break;
case "The bar opens above an S3":
BandIndicatorLogic(firstBar, previous, r3, s3, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Lower_Band);
break;
case "The bar closes below an R3":
BandIndicatorLogic(firstBar, previous, r3, s3, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_below_the_Upper_Band);
break;
case "The bar closes above an R3":
BandIndicatorLogic(firstBar, previous, r3, s3, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_above_the_Upper_Band);
break;
case "The bar closes below an S3":
BandIndicatorLogic(firstBar, previous, r3, s3, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_below_the_Lower_Band);
break;
case "The bar closes above an S3":
BandIndicatorLogic(firstBar, previous, r3, s3, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_above_the_Lower_Band);
break;
case "The bar opens below an R3 after opening above it":
BandIndicatorLogic(firstBar, previous, r3, s3, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Upper_Band_after_opening_above_it);
break;
case "The bar opens above an R3 after opening below it":
BandIndicatorLogic(firstBar, previous, r3, s3, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Upper_Band_after_opening_below_it);
break;
case "The bar opens below an S3 after opening above it":
BandIndicatorLogic(firstBar, previous, r3, s3, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Lower_Band_after_opening_above_it);
break;
case "The bar opens above an S3 after opening below it":
BandIndicatorLogic(firstBar, previous, r3, s3, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Lower_Band_after_opening_below_it);
break;
case "The bar opens below an R2":
BandIndicatorLogic(firstBar, previous, r2, s2, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Upper_Band);
break;
case "The bar opens above an R2":
BandIndicatorLogic(firstBar, previous, r2, s2, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Upper_Band);
break;
case "The bar opens below an S2":
BandIndicatorLogic(firstBar, previous, r2, s2, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Lower_Band);
break;
case "The bar opens above an S2":
BandIndicatorLogic(firstBar, previous, r2, s2, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Lower_Band);
break;
case "The bar closes below an R2":
BandIndicatorLogic(firstBar, previous, r2, s2, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_below_the_Upper_Band);
break;
case "The bar closes above an R2":
BandIndicatorLogic(firstBar, previous, r2, s2, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_above_the_Upper_Band);
break;
case "The bar closes below an S2":
BandIndicatorLogic(firstBar, previous, r2, s2, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_below_the_Lower_Band);
break;
case "The bar closes above an S2":
BandIndicatorLogic(firstBar, previous, r2, s2, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_above_the_Lower_Band);
break;
case "The bar opens below an R2 after opening above it":
BandIndicatorLogic(firstBar, previous, r2, s2, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Upper_Band_after_opening_above_it);
break;
case "The bar opens above an R2 after opening below it":
BandIndicatorLogic(firstBar, previous, r2, s2, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Upper_Band_after_opening_below_it);
break;
case "The bar opens below an S2 after opening above it":
BandIndicatorLogic(firstBar, previous, r2, s2, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Lower_Band_after_opening_above_it);
break;
case "The bar opens above an S2 after opening below it":
BandIndicatorLogic(firstBar, previous, r2, s2, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Lower_Band_after_opening_below_it);
break;
case "The bar opens below an R1":
BandIndicatorLogic(firstBar, previous, r1, s1, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Upper_Band);
break;
case "The bar opens above an R1":
BandIndicatorLogic(firstBar, previous, r1, s1, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Upper_Band);
break;
case "The bar opens below an S1":
BandIndicatorLogic(firstBar, previous, r1, s1, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Lower_Band);
break;
case "The bar opens above an S1":
BandIndicatorLogic(firstBar, previous, r1, s1, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Lower_Band);
break;
case "The bar closes below an R1":
BandIndicatorLogic(firstBar, previous, r1, s1, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_below_the_Upper_Band);
break;
case "The bar closes above an R1":
BandIndicatorLogic(firstBar, previous, r1, s1, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_above_the_Upper_Band);
break;
case "The bar closes below an S1":
BandIndicatorLogic(firstBar, previous, r1, s1, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_below_the_Lower_Band);
break;
case "The bar closes above an S1":
BandIndicatorLogic(firstBar, previous, r1, s1, ref Component[9], ref Component[10], BandIndLogic.The_bar_closes_above_the_Lower_Band);
break;
case "The bar opens below an R1 after opening above it":
BandIndicatorLogic(firstBar, previous, r1, s1, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Upper_Band_after_opening_above_it);
break;
case "The bar opens above an R1 after opening below it":
BandIndicatorLogic(firstBar, previous, r1, s1, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Upper_Band_after_opening_below_it);
break;
case "The bar opens below an S1 after opening above it":
BandIndicatorLogic(firstBar, previous, r1, s1, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_below_the_Lower_Band_after_opening_above_it);
break;
case "The bar opens above an S1 after opening below it":
BandIndicatorLogic(firstBar, previous, r1, s1, ref Component[9], ref Component[10], BandIndLogic.The_bar_opens_above_the_Lower_Band_after_opening_below_it);
break;
case "The bar opens above the Pivot Point":
BarOpensAboveIndicatorLogic(firstBar, previous, pp, ref Component[9], ref Component[10]);
break;
case "The bar opens below the Pivot Point":
BarOpensBelowIndicatorLogic(firstBar, previous, pp, ref Component[9], ref Component[10]);
break;
case "The bar opens above the Pivot Point after opening below it":
BarOpensAboveIndicatorAfterOpeningBelowLogic(firstBar, previous, pp, ref Component[9], ref Component[10]);
break;
case "The bar opens below the Pivot Point after opening above it":
BarOpensBelowIndicatorAfterOpeningAboveLogic(firstBar, previous, pp, ref Component[9], ref Component[10]);
break;
case "The bar closes below the Pivot Point":
BarClosesBelowIndicatorLogic(firstBar, previous, pp, ref Component[9], ref Component[10]);
break;
case "The bar closes above the Pivot Point":
BarClosesAboveIndicatorLogic(firstBar, previous, pp, ref Component[9], ref Component[10]);
break;
}
}
public override void SetDescription()
{
var iShift = int.Parse(IndParam.ListParam[3].Text);
string sUpperTrade;
string sLowerTrade;
if (iShift > 0)
{
sUpperTrade = iShift + " points above the ";
sLowerTrade = iShift + " points below the ";
}
else if (iShift == 0)
{
sUpperTrade = "at the ";
sLowerTrade = "at the ";
}
else
{
sUpperTrade = -iShift + " points below the ";
sLowerTrade = -iShift + " points above the ";
}
switch (IndParam.ListParam[0].Text)
{
case "Enter long at R4 (short at S4)":
EntryPointLongDescription = sUpperTrade + "Pivot Point Resistance 4 level";
EntryPointShortDescription = sLowerTrade + "Pivot Point Support 4 level";
break;
case "Exit long at R4 (short at S4)":
ExitPointLongDescription = sUpperTrade + "Pivot Point Resistance 4 level";
ExitPointShortDescription = sLowerTrade + "Pivot Point Support 4 level";
break;
case "Enter long at R3 (short at S3)":
EntryPointLongDescription = sUpperTrade + "Pivot Point Resistance 3 level";
EntryPointShortDescription = sLowerTrade + "Pivot Point Support 3 level";
break;
case "Exit long at R3 (short at S3)":
ExitPointLongDescription = sUpperTrade + "Pivot Point Resistance 3 level";
ExitPointShortDescription = sLowerTrade + "Pivot Point Support 3 level";
break;
case "Enter long at R2 (short at S2)":
EntryPointLongDescription = sUpperTrade + "Pivot Point Resistance 2 level";
EntryPointShortDescription = sLowerTrade + "Pivot Point Support 2 level";
break;
case "Exit long at R2 (short at S2)":
ExitPointLongDescription = sUpperTrade + "Pivot Point Resistance 2 level";
ExitPointShortDescription = sLowerTrade + "Pivot Point Support 2 level";
break;
case "Enter long at R1 (short at S1)":
EntryPointLongDescription = sUpperTrade + "Pivot Point Resistance 1 level";
EntryPointShortDescription = sLowerTrade + "Pivot Point Support 1 level";
break;
case "Exit long at R1 (short at S1)":
ExitPointLongDescription = sUpperTrade + "Pivot Point Resistance 1 level";
ExitPointShortDescription = sLowerTrade + "Pivot Point Support 1 level";
break;
case "Enter the market at the Pivot Point":
EntryPointLongDescription = sUpperTrade + "Pivot Point";
EntryPointShortDescription = sLowerTrade + "Pivot Point";
break;
case "Exit the market at the Pivot Point":
ExitPointLongDescription = sUpperTrade + "Pivot Point";
ExitPointShortDescription = sLowerTrade + "Pivot Point";
break;
case "Enter long at S1 (short at R1)":
EntryPointLongDescription = sLowerTrade + "Pivot Point Support 1 level";
EntryPointShortDescription = sUpperTrade + "Pivot Point Resistance 1 level";
break;
case "Exit long at S1 (short at R1)":
ExitPointLongDescription = sLowerTrade + "Pivot Point Support 1 level";
ExitPointShortDescription = sUpperTrade + "Pivot Point Resistance 1 level";
break;
case "Enter long at S2 (short at R2)":
EntryPointLongDescription = sLowerTrade + "Pivot Point Support 2 level";
EntryPointShortDescription = sUpperTrade + "Pivot Point Resistance 2 level";
break;
case "Exit long at S2 (short at R2)":
ExitPointLongDescription = sLowerTrade + "Pivot Point Support 2 level";
ExitPointShortDescription = sUpperTrade + "Pivot Point Resistance 2 level";
break;
case "Enter long at S3 (short at R3)":
EntryPointLongDescription = sLowerTrade + "Pivot Point Support 3 level";
EntryPointShortDescription = sUpperTrade + "Pivot Point Resistance 3 level";
break;
case "Exit long at S3 (short at R3)":
ExitPointLongDescription = sLowerTrade + "Pivot Point Support 3 level";
ExitPointShortDescription = sUpperTrade + "Pivot Point Resistance 3 level";
break;
case "Enter long at S4 (short at R4)":
EntryPointLongDescription = sLowerTrade + "Pivot Point Support 4 level";
EntryPointShortDescription = sUpperTrade + "Pivot Point Resistance 4 level";
break;
case "Exit long at S4 (short at R4)":
ExitPointLongDescription = sLowerTrade + "Pivot Point Support 4 level";
ExitPointShortDescription = sUpperTrade + "Pivot Point Resistance 4 level";
break;
}
}
public override string ToString()
{
string text = IndicatorName +
(IndParam.CheckParam[0].Checked ? "*" : "") +
" (" + IndParam.ListParam[1].Text + ")";
return text;
}
}
}
//+------------------------------------------------------------------+ //| PivotPointsXStepped.mqh | //| Copyright (C) 2025 NAYA +237674724684 | //| NAYA +237674724684 | //+------------------------------------------------------------------+ #property copyright "Copyright (C) 2025 NAYA +237674724684" #property link "NAYA +237674724684" #property version "1.22" #property strict #include <Forexsb.com/Indicator.mqh> #include <Forexsb.com/Enumerations.mqh> //+------------------------------------------------------------------+ //| Class PivotPointsXStepped | //+------------------------------------------------------------------+ class PivotPointsXStepped : public Indicator { public: PivotPointsXStepped(SlotTypes slotType); virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| Constructor | //+------------------------------------------------------------------+ void PivotPointsXStepped::PivotPointsXStepped(SlotTypes slotType) { SlotType = slotType; IndicatorName = "Pivot Points X Stepped Extended"; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDefaultGroupAll = false; } //+------------------------------------------------------------------+ //| Calculate indicator values | //+------------------------------------------------------------------+ void PivotPointsXStepped::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); if(ArraySize(ListParam) < 4) { PrintFormat("%s Error: ListParam array size is %d, expected at least 4.", IndicatorName, ArraySize(ListParam)); return; } double dShift = (double)StringToInteger(ListParam[3].Text) * Data.Point; int previous=CheckParam[0].Checked ? 1 : 0; string pivotType=ListParam[1].Text; int firstBar=previous + 2; double adPp[]; ArrayResize(adPp,Data.Bars); ArrayInitialize(adPp,0); double adR1[]; ArrayResize(adR1,Data.Bars); ArrayInitialize(adR1,0); double adR2[]; ArrayResize(adR2,Data.Bars); ArrayInitialize(adR2,0); double adR3[]; ArrayResize(adR3,Data.Bars); ArrayInitialize(adR3,0); double adR4[]; ArrayResize(adR4,Data.Bars); ArrayInitialize(adR4,0); double adS1[]; ArrayResize(adS1,Data.Bars); ArrayInitialize(adS1,0); double adS2[]; ArrayResize(adS2,Data.Bars); ArrayInitialize(adS2,0); double adS3[]; ArrayResize(adS3,Data.Bars); ArrayInitialize(adS3,0); double adS4[]; ArrayResize(adS4,Data.Bars); ArrayInitialize(adS4,0); double adH[]; ArrayResize(adH,Data.Bars); ArrayInitialize(adH,0); double adL[]; ArrayResize(adL,Data.Bars); ArrayInitialize(adL,0); double adC[]; ArrayResize(adC,Data.Bars); ArrayInitialize(adC,0); double adO[]; ArrayResize(adO,Data.Bars); ArrayInitialize(adO,0); if(ListParam[2].Text=="One bar" || Data.Period==DataPeriod_D1 || Data.Period==DataPeriod_W1) { ArrayCopy(adH, Data.High); ArrayCopy(adL, Data.Low); ArrayCopy(adC, Data.Close); ArrayCopy(adO, Data.Open); } else { previous=0; adH[0] = 0; adL[0] = 0; adC[0] = 0; adO[0] = 0; double dTop=DBL_MIN; double dBottom=DBL_MAX; for(int bar=1; bar<Data.Bars; bar++) { if(Data.High[bar-1]>dTop) dTop=Data.High[bar-1]; if(Data.Low[bar-1]<dBottom) dBottom=Data.Low[bar-1]; MqlDateTime time0; TimeToStruct(Data.Time[bar+0], time0); MqlDateTime time1; TimeToStruct(Data.Time[bar-1], time1); if(time0.day!=time1.day) { adH[bar] = dTop; adL[bar] = dBottom; adC[bar] = Data.Close[bar - 1]; adO[bar] = Data.Open[bar - 1]; dTop=DBL_MIN; dBottom=DBL_MAX; } else { adH[bar] = adH[bar - 1]; adL[bar] = adL[bar - 1]; adC[bar] = adC[bar - 1]; adO[bar] = adO[bar - 1]; } } for(int bar=1; bar<Data.Bars; bar++) { MqlDateTime time0; TimeToStruct(Data.Time[bar+0], time0); MqlDateTime time1; TimeToStruct(Data.Time[bar-1], time1); if(time0.day!=time1.day) firstBar=bar; } } for(int bar=firstBar; bar<Data.Bars; bar++) { if(pivotType == "Traditional") { adPp[bar] = (adH[bar] + adL[bar] + adC[bar]) / 3 + dShift; adR1[bar] = (2 * adPp[bar] - adL[bar]) + dShift; adS1[bar] = (2 * adPp[bar] - adH[bar]) - dShift; adR2[bar] = (adPp[bar] + adH[bar] - adL[bar]) + dShift; adS2[bar] = (adPp[bar] - adH[bar] + adL[bar]) - dShift; adR3[bar] = (adH[bar] + 2 * (adPp[bar] - adL[bar])) + dShift; adS3[bar] = (adL[bar] - 2 * (adH[bar] - adPp[bar])) - dShift; // Extended R4/S4 for Traditional adR4[bar] = adR3[bar] + (adH[bar] - adL[bar]) + dShift; adS4[bar] = adS3[bar] - (adH[bar] - adL[bar]) - dShift; } else if(pivotType == "Woodie") { adPp[bar] = (adH[bar] + adL[bar] + 2 * adO[bar]) / 4 + dShift; adR1[bar] = (2 * adPp[bar] - adL[bar]) + dShift; adS1[bar] = (2 * adPp[bar] - adH[bar]) - dShift; adR2[bar] = (adPp[bar] + adH[bar] - adL[bar]) + dShift; adS2[bar] = (adPp[bar] - adH[bar] + adL[bar]) - dShift; adR3[bar] = adH[bar] + 2 * (adPp[bar] - adL[bar]) + dShift; adS3[bar] = adL[bar] - 2 * (adH[bar] - adPp[bar]) - dShift; // Extended R4/S4 for Woodie adR4[bar] = adR3[bar] + (adH[bar] - adL[bar]) + dShift; adS4[bar] = adS3[bar] - (adH[bar] - adL[bar]) - dShift; } else if(pivotType == "Classic") { adPp[bar] = (adH[bar] + adL[bar] + adC[bar]) / 3 + dShift; adR1[bar] = (2 * adPp[bar] - adL[bar]) + dShift; adS1[bar] = (2 * adPp[bar] - adH[bar]) - dShift; adR2[bar] = (adPp[bar] + adH[bar] - adL[bar]) + dShift; adS2[bar] = (adPp[bar] - adH[bar] + adL[bar]) - dShift; adR3[bar] = (adPp[bar] + 2 * (adH[bar] - adL[bar])) + dShift; adS3[bar] = (adPp[bar] - 2 * (adH[bar] - adL[bar])) - dShift; // Extended R4/S4 for Classic adR4[bar] = adR3[bar] + (adH[bar] - adL[bar]) + dShift; adS4[bar] = adS3[bar] - (adH[bar] - adL[bar]) - dShift; } else if(pivotType == "Camarilla") { adPp[bar] = (adH[bar] + adL[bar] + adC[bar]) / 3 + dShift; adR1[bar] = adC[bar] + (adH[bar] - adL[bar]) * 1.1 / 12 + dShift; adS1[bar] = adC[bar] - (adH[bar] - adL[bar]) * 1.1 / 12 - dShift; adR2[bar] = adC[bar] + (adH[bar] - adL[bar]) * 1.1 / 6 + dShift; adS2[bar] = adC[bar] - (adH[bar] - adL[bar]) * 1.1 / 6 - dShift; adR3[bar] = adC[bar] + (adH[bar] - adL[bar]) * 1.1 / 4 + dShift; adS3[bar] = adC[bar] - (adH[bar] - adL[bar]) * 1.1 / 4 - dShift; adR4[bar] = adC[bar] + (adH[bar] - adL[bar]) * 1.1 / 2 + dShift; adS4[bar] = adC[bar] - (adH[bar] - adL[bar]) * 1.1 / 2 - dShift; } else if(pivotType == "Fibonacci") { adPp[bar] = (adH[bar] + adL[bar] + adC[bar]) / 3 + dShift; adR1[bar] = adPp[bar] + 0.382 * (adH[bar] - adL[bar]) + dShift; adS1[bar] = adPp[bar] - 0.382 * (adH[bar] - adL[bar]) - dShift; adR2[bar] = adPp[bar] + 0.618 * (adH[bar] - adL[bar]) + dShift; adS2[bar] = adPp[bar] - 0.618 * (adH[bar] - adL[bar]) - dShift; adR3[bar] = adPp[bar] + 1.0 * (adH[bar] - adL[bar]) + dShift; adS3[bar] = adPp[bar] - 1.0 * (adH[bar] - adL[bar]) - dShift; // Extended R4/S4 for Fibonacci adR4[bar] = adPp[bar] + 1.618 * (adH[bar] - adL[bar]) + dShift; adS4[bar] = adPp[bar] - 1.618 * (adH[bar] - adL[bar]) - dShift; } else if(pivotType == "Standard (Floor)") { adPp[bar] = (adH[bar] + adL[bar] + adC[bar]) / 3 + dShift; adR1[bar] = (2 * adPp[bar]) - adL[bar] + dShift; adS1[bar] = (2 * adPp[bar]) - adH[bar] - dShift; adR2[bar] = adPp[bar] + (adH[bar] - adL[bar]) + dShift; adS2[bar] = adPp[bar] - (adH[bar] - adL[bar]) - dShift; adR3[bar] = adR1[bar] + (adH[bar] - adL[bar]) + dShift; adS3[bar] = adS1[bar] - (adH[bar] - adL[bar]) - dShift; // Extended R4/S4 for Standard adR4[bar] = adR2[bar] + (adH[bar] - adL[bar]) + dShift; adS4[bar] = adS2[bar] - (adH[bar] - adL[bar]) - dShift; } else if(pivotType == "Demark") { double x = 0; if(adC[bar] < adO[bar]) x = adH[bar] + 2 * adL[bar] + adC[bar]; else if(adC[bar] > adO[bar]) x = 2 * adH[bar] + adL[bar] + adC[bar]; else x = adH[bar] + adL[bar] + 2 * adC[bar]; adPp[bar] = x / 4 + dShift; adR1[bar] = x / 2 - adL[bar] + dShift; adS1[bar] = x / 2 - adH[bar] - dShift; // Extended R4/S4 for Demark (using similar logic to R1/S1) adR2[bar] = adR1[bar] + (adH[bar] - adL[bar]) + dShift; adS2[bar] = adS1[bar] - (adH[bar] - adL[bar]) - dShift; adR3[bar] = adR2[bar] + (adH[bar] - adL[bar]) + dShift; adS3[bar] = adS2[bar] - (adH[bar] - adL[bar]) - dShift; adR4[bar] = adR3[bar] + (adH[bar] - adL[bar]) + dShift; adS4[bar] = adS3[bar] - (adH[bar] - adL[bar]) - dShift; } } // Always use 9 components now (R4-R1, PP, S1-S4) for(int iComp=0; iComp<9; iComp++) { ArrayResize(Component[iComp].Value,Data.Bars); Component[iComp].DataType = IndComponentType_IndicatorValue; Component[iComp].FirstBar = firstBar; } // Assign all levels ArrayCopy(Component[0].Value, adR4); ArrayCopy(Component[1].Value, adR3); ArrayCopy(Component[2].Value, adR2); ArrayCopy(Component[3].Value, adR1); ArrayCopy(Component[4].Value, adPp); ArrayCopy(Component[5].Value, adS1); ArrayCopy(Component[6].Value, adS2); ArrayCopy(Component[7].Value, adS3); ArrayCopy(Component[8].Value, adS4); Component[0].CompName = "Resistance 4"; Component[1].CompName = "Resistance 3"; Component[2].CompName = "Resistance 2"; Component[3].CompName = "Resistance 1"; Component[4].CompName = "Pivot Point"; Component[5].CompName = "Support 1"; Component[6].CompName = "Support 2"; Component[7].CompName = "Support 3"; Component[8].CompName = "Support 4"; // Trading components ArrayResize(Component[9].Value,Data.Bars); Component[9].FirstBar=firstBar; ArrayResize(Component[10].Value,Data.Bars); Component[10].FirstBar=firstBar; if(SlotType==SlotTypes_Open) { Component[9].CompName = "Long position entry price"; Component[9].DataType = IndComponentType_OpenLongPrice; Component[10].CompName = "Short position entry price"; Component[10].DataType = IndComponentType_OpenShortPrice; } else if (SlotType == SlotTypes_OpenFilter) { Component[9].CompName = "Is long entry allowed"; Component[9].DataType = IndComponentType_AllowOpenLong; Component[10].CompName = "Is short entry allowed"; Component[10].DataType = IndComponentType_AllowOpenShort; } else if(SlotType==SlotTypes_Close) { Component[9].CompName = "Long position closing price"; Component[9].DataType = IndComponentType_CloseLongPrice; Component[10].CompName = "Short position closing price"; Component[10].DataType = IndComponentType_CloseShortPrice; } else if (SlotType == SlotTypes_CloseFilter) { Component[9].CompName = "Close out long position"; Component[9].DataType = IndComponentType_ForceCloseLong; Component[10].CompName = "Close out short position"; Component[10].DataType = IndComponentType_ForceCloseShort; } // Trading logic for all levels including R4/S4 if(ListParam[0].Text=="Enter long at R4 (short at S4)" || ListParam[0].Text=="Exit long at R4 (short at S4)") for(int bar=firstBar; bar<Data.Bars; bar++) { Component[9].Value[bar] = adR4[bar - previous]; Component[10].Value[bar] = adS4[bar - previous]; } else if(ListParam[0].Text=="Enter long at R3 (short at S3)" || ListParam[0].Text=="Exit long at R3 (short at S3)") for(int bar=firstBar; bar<Data.Bars; bar++) { Component[9].Value[bar] = adR3[bar - previous]; Component[10].Value[bar] = adS3[bar - previous]; } else if(ListParam[0].Text=="Enter long at R2 (short at S2)" || ListParam[0].Text=="Exit long at R2 (short at S2)") for(int bar=firstBar; bar<Data.Bars; bar++) { Component[9].Value[bar] = adR2[bar - previous]; Component[10].Value[bar] = adS2[bar - previous]; } else if(ListParam[0].Text=="Enter long at R1 (short at S1)" || ListParam[0].Text=="Exit long at R1 (short at S1)") for(int bar=firstBar; bar<Data.Bars; bar++) { Component[9].Value[bar] = adR1[bar - previous]; Component[10].Value[bar] = adS1[bar - previous]; } else if(ListParam[0].Text=="Enter the market at the Pivot Point" || ListParam[0].Text=="Exit the market at the Pivot Point") for(int bar=firstBar; bar<Data.Bars; bar++) { Component[9].Value[bar] = adPp[bar - previous]; Component[10].Value[bar] = adPp[bar - previous]; } else if(ListParam[0].Text=="Enter long at S1 (short at R1)" || ListParam[0].Text=="Exit long at S1 (short at R1)") for(int bar=firstBar; bar<Data.Bars; bar++) { Component[9].Value[bar] = adS1[bar - previous]; Component[10].Value[bar] = adR1[bar - previous]; } else if(ListParam[0].Text=="Enter long at S2 (short at R2)" || ListParam[0].Text=="Exit long at S2 (short at R2)") for(int bar=firstBar; bar<Data.Bars; bar++) { Component[9].Value[bar] = adS2[bar - previous]; Component[10].Value[bar] = adR2[bar - previous]; } else if(ListParam[0].Text=="Enter long at S3 (short at R3)" || ListParam[0].Text=="Exit long at S3 (short at R3)") for(int bar=firstBar; bar<Data.Bars; bar++) { Component[9].Value[bar] = adS3[bar - previous]; Component[10].Value[bar] = adR3[bar - previous]; } else if(ListParam[0].Text=="Enter long at S4 (short at R4)" || ListParam[0].Text=="Exit long at S4 (short at R4)") for(int bar=firstBar; bar<Data.Bars; bar++) { Component[9].Value[bar] = adS4[bar - previous]; Component[10].Value[bar] = adR4[bar - previous]; } else if(ListParam[0].Text=="The bar opens below an R4") BandIndicatorLogic(firstBar, previous, adR4, adS4, Component[9], Component[10], BandIndLogic_The_bar_opens_below_the_Upper_Band); else if(ListParam[0].Text=="The bar opens above an R4") BandIndicatorLogic(firstBar, previous, adR4, adS4, Component[9], Component[10], BandIndLogic_The_bar_opens_above_the_Upper_Band); else if(ListParam[0].Text=="The bar opens below an S4") BandIndicatorLogic(firstBar, previous, adR4, adS4, Component[9], Component[10], BandIndLogic_The_bar_opens_below_the_Lower_Band); else if(ListParam[0].Text=="The bar opens above an S4") BandIndicatorLogic(firstBar, previous, adR4, adS4, Component[9], Component[10], BandIndLogic_The_bar_opens_above_the_Lower_Band); else if(ListParam[0].Text=="The bar closes below an R4") BandIndicatorLogic(firstBar, previous, adR4, adS4, Component[9], Component[10], BandIndLogic_The_bar_closes_below_the_Upper_Band); else if(ListParam[0].Text=="The bar closes above an R4") BandIndicatorLogic(firstBar, previous, adR4, adS4, Component[9], Component[10], BandIndLogic_The_bar_closes_above_the_Upper_Band); else if(ListParam[0].Text=="The bar closes below an S4") BandIndicatorLogic(firstBar, previous, adR4, adS4, Component[9], Component[10], BandIndLogic_The_bar_closes_below_the_Lower_Band); else if(ListParam[0].Text=="The bar closes above an S4") BandIndicatorLogic(firstBar, previous, adR4, adS4, Component[9], Component[10], BandIndLogic_The_bar_closes_above_the_Lower_Band); else if(ListParam[0].Text=="The bar opens below an R4 after opening above it") BandIndicatorLogic(firstBar, previous, adR4, adS4, Component[9], Component[10], BandIndLogic_The_bar_opens_below_Upper_Band_after_above); else if(ListParam[0].Text=="The bar opens above an R4 after opening below it") BandIndicatorLogic(firstBar, previous, adR4, adS4, Component[9], Component[10], BandIndLogic_The_bar_opens_above_Upper_Band_after_below); else if(ListParam[0].Text=="The bar opens below an S4 after opening above it") BandIndicatorLogic(firstBar, previous, adR4, adS4, Component[9], Component[10], BandIndLogic_The_bar_opens_below_Lower_Band_after_above); else if(ListParam[0].Text=="The bar opens above an S4 after opening below it") BandIndicatorLogic(firstBar, previous, adR4, adS4, Component[9], Component[10], BandIndLogic_The_bar_opens_above_Lower_Band_after_below); else if(ListParam[0].Text=="The bar opens below an R3") BandIndicatorLogic(firstBar, previous, adR3, adS3, Component[9], Component[10], BandIndLogic_The_bar_opens_below_the_Upper_Band); else if(ListParam[0].Text=="The bar opens above an R3") BandIndicatorLogic(firstBar, previous, adR3, adS3, Component[9], Component[10], BandIndLogic_The_bar_opens_above_the_Upper_Band); else if(ListParam[0].Text=="The bar opens below an S3") BandIndicatorLogic(firstBar, previous, adR3, adS3, Component[9], Component[10], BandIndLogic_The_bar_opens_below_the_Lower_Band); else if(ListParam[0].Text=="The bar opens above an S3") BandIndicatorLogic(firstBar, previous, adR3, adS3, Component[9], Component[10], BandIndLogic_The_bar_opens_above_the_Lower_Band); else if(ListParam[0].Text=="The bar closes below an R3") BandIndicatorLogic(firstBar, previous, adR3, adS3, Component[9], Component[10], BandIndLogic_The_bar_closes_below_the_Upper_Band); else if(ListParam[0].Text=="The bar closes above an R3") BandIndicatorLogic(firstBar, previous, adR3, adS3, Component[9], Component[10], BandIndLogic_The_bar_closes_above_the_Upper_Band); else if(ListParam[0].Text=="The bar closes below an S3") BandIndicatorLogic(firstBar, previous, adR3, adS3, Component[9], Component[10], BandIndLogic_The_bar_closes_below_the_Lower_Band); else if(ListParam[0].Text=="The bar closes above an S3") BandIndicatorLogic(firstBar, previous, adR3, adS3, Component[9], Component[10], BandIndLogic_The_bar_closes_above_the_Lower_Band); else if(ListParam[0].Text=="The bar opens below an R3 after opening above it") BandIndicatorLogic(firstBar, previous, adR3, adS3, Component[9], Component[10], BandIndLogic_The_bar_opens_below_Upper_Band_after_above); else if(ListParam[0].Text=="The bar opens above an R3 after opening below it") BandIndicatorLogic(firstBar, previous, adR3, adS3, Component[9], Component[10], BandIndLogic_The_bar_opens_above_Upper_Band_after_below); else if(ListParam[0].Text=="The bar opens below an S3 after opening above it") BandIndicatorLogic(firstBar, previous, adR3, adS3, Component[9], Component[10], BandIndLogic_The_bar_opens_below_Lower_Band_after_above); else if(ListParam[0].Text=="The bar opens above an S3 after opening below it") BandIndicatorLogic(firstBar, previous, adR3, adS3, Component[9], Component[10], BandIndLogic_The_bar_opens_above_Lower_Band_after_below); else if(ListParam[0].Text=="The bar opens below an R2") BandIndicatorLogic(firstBar, previous, adR2, adS2, Component[9], Component[10], BandIndLogic_The_bar_opens_below_the_Upper_Band); else if(ListParam[0].Text=="The bar opens above an R2") BandIndicatorLogic(firstBar, previous, adR2, adS2, Component[9], Component[10], BandIndLogic_The_bar_opens_above_the_Upper_Band); else if(ListParam[0].Text=="The bar opens below an S2") BandIndicatorLogic(firstBar, previous, adR2, adS2, Component[9], Component[10], BandIndLogic_The_bar_opens_below_the_Lower_Band); else if(ListParam[0].Text=="The bar opens above an S2") BandIndicatorLogic(firstBar, previous, adR2, adS2, Component[9], Component[10], BandIndLogic_The_bar_opens_above_the_Lower_Band); else if(ListParam[0].Text=="The bar closes below an R2") BandIndicatorLogic(firstBar, previous, adR2, adS2, Component[9], Component[10], BandIndLogic_The_bar_closes_below_the_Upper_Band); else if(ListParam[0].Text=="The bar closes above an R2") BandIndicatorLogic(firstBar, previous, adR2, adS2, Component[9], Component[10], BandIndLogic_The_bar_closes_above_the_Upper_Band); else if(ListParam[0].Text=="The bar closes below an S2") BandIndicatorLogic(firstBar, previous, adR2, adS2, Component[9], Component[10], BandIndLogic_The_bar_closes_below_the_Lower_Band); else if(ListParam[0].Text=="The bar closes above an S2") BandIndicatorLogic(firstBar, previous, adR2, adS2, Component[9], Component[10], BandIndLogic_The_bar_closes_above_the_Lower_Band); else if(ListParam[0].Text=="The bar opens below an R2 after opening above it") BandIndicatorLogic(firstBar, previous, adR2, adS2, Component[9], Component[10], BandIndLogic_The_bar_opens_below_Upper_Band_after_above); else if(ListParam[0].Text=="The bar opens above an R2 after opening below it") BandIndicatorLogic(firstBar, previous, adR2, adS2, Component[9], Component[10], BandIndLogic_The_bar_opens_above_Upper_Band_after_below); else if(ListParam[0].Text=="The bar opens below an S2 after opening above it") BandIndicatorLogic(firstBar, previous, adR2, adS2, Component[9], Component[10], BandIndLogic_The_bar_opens_below_Lower_Band_after_above); else if(ListParam[0].Text=="The bar opens above an S2 after opening below it") BandIndicatorLogic(firstBar, previous, adR2, adS2, Component[9], Component[10], BandIndLogic_The_bar_opens_above_Lower_Band_after_below); else if(ListParam[0].Text=="The bar opens below an R1") BandIndicatorLogic(firstBar, previous, adR1, adS1, Component[9], Component[10], BandIndLogic_The_bar_opens_below_the_Upper_Band); else if(ListParam[0].Text=="The bar opens above an R1") BandIndicatorLogic(firstBar, previous, adR1, adS1, Component[9], Component[10], BandIndLogic_The_bar_opens_above_the_Upper_Band); else if(ListParam[0].Text=="The bar opens below an S1") BandIndicatorLogic(firstBar, previous, adR1, adS1, Component[9], Component[10], BandIndLogic_The_bar_opens_below_the_Lower_Band); else if(ListParam[0].Text=="The bar opens above an S1") BandIndicatorLogic(firstBar, previous, adR1, adS1, Component[9], Component[10], BandIndLogic_The_bar_opens_above_the_Lower_Band); else if(ListParam[0].Text=="The bar closes below an R1") BandIndicatorLogic(firstBar, previous, adR1, adS1, Component[9], Component[10], BandIndLogic_The_bar_closes_below_the_Upper_Band); else if(ListParam[0].Text=="The bar closes above an R1") BandIndicatorLogic(firstBar, previous, adR1, adS1, Component[9], Component[10], BandIndLogic_The_bar_closes_above_the_Upper_Band); else if(ListParam[0].Text=="The bar closes below an S1") BandIndicatorLogic(firstBar, previous, adR1, adS1, Component[9], Component[10], BandIndLogic_The_bar_closes_below_the_Lower_Band); else if(ListParam[0].Text=="The bar closes above an S1") BandIndicatorLogic(firstBar, previous, adR1, adS1, Component[9], Component[10], BandIndLogic_The_bar_closes_above_the_Lower_Band); else if(ListParam[0].Text=="The bar opens below an R1 after opening above it") BandIndicatorLogic(firstBar, previous, adR1, adS1, Component[9], Component[10], BandIndLogic_The_bar_opens_below_Upper_Band_after_above); else if(ListParam[0].Text=="The bar opens above an R1 after opening below it") BandIndicatorLogic(firstBar, previous, adR1, adS1, Component[9], Component[10], BandIndLogic_The_bar_opens_above_Upper_Band_after_below); else if(ListParam[0].Text=="The bar opens below an S1 after opening above it") BandIndicatorLogic(firstBar, previous, adR1, adS1, Component[9], Component[10], BandIndLogic_The_bar_opens_below_Lower_Band_after_above); else if(ListParam[0].Text=="The bar opens above an S1 after opening below it") BandIndicatorLogic(firstBar, previous, adR1, adS1, Component[9], Component[10], BandIndLogic_The_bar_opens_above_Lower_Band_after_below); else if(ListParam[0].Text=="The bar opens above the Pivot Point") BarOpensAboveIndicatorLogic(firstBar, previous, adPp, Component[9], Component[10]); else if(ListParam[0].Text=="The bar opens below the Pivot Point") BarOpensBelowIndicatorLogic(firstBar, previous, adPp, Component[9], Component[10]); else if(ListParam[0].Text=="The bar opens above the Pivot Point after opening below it") BarOpensAboveIndicatorAfterOpeningBelowLogic(firstBar, previous, adPp, Component[9], Component[10]); else if(ListParam[0].Text=="The bar opens below the Pivot Point after opening above it") BarOpensBelowIndicatorAfterOpeningAboveLogic(firstBar, previous, adPp, Component[9], Component[10]); else if(ListParam[0].Text=="The bar closes below the Pivot Point") BarClosesBelowIndicatorLogic(firstBar, previous, adPp, Component[9], Component[10]); else if(ListParam[0].Text=="The bar closes above the Pivot Point") BarClosesAboveIndicatorLogic(firstBar, previous, adPp, Component[9], Component[10]); } //+------------------------------------------------------------------+
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.;