Time Price Channel by Popov
50764 downloads / 6045 views / Created: 04.08.2015




Average Rating: 5
Indicator Description
Time Price Channel indicator gets two parameters Time (hour and minutes) and price deviation in points.
The indicator monitors the market and when a bar Open price matches the specified time, it plots a channel of two lines, below and above the Open price. The lines are located at the specified deviation away of the reference Open price.
This indicator can be used as entry/exit point and also as entry and exit filter.

The indicator monitors the market and when a bar Open price matches the specified time, it plots a channel of two lines, below and above the Open price. The lines are located at the specified deviation away of the reference Open price.
This indicator can be used as entry/exit point and also as entry and exit filter.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481
//==============================================================
// Forex Strategy Builder
// Copyright © Forex Software Ltd. 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.Custom
{
public class TimePriceChannel : Indicator
{
public TimePriceChannel()
{
IndicatorName = "Time Price Channel";
PossibleSlots = SlotTypes.Open | SlotTypes.OpenFilter | SlotTypes.Close | SlotTypes.CloseFilter;
IndicatorAuthor = "Miroslav Popov";
IndicatorVersion = "1.0";
IndicatorDescription = "Sets a channel based on the price at a specified time.";
}
public override void Initialize(SlotTypes slotType)
{
SlotType = slotType;
// Setting up the indicator parameters
IndParam.IndicatorType = TypeOfIndicator.Additional;
// The ComboBox parameters
IndParam.ListParam[0].Caption = "Logic";
if (SlotType == SlotTypes.Open)
IndParam.ListParam[0].ItemList = new[]
{
"Enter long at Upper Band",
"Enter long at Lower Band"
};
else if (SlotType == SlotTypes.OpenFilter)
IndParam.ListParam[0].ItemList = new[]
{
"The bar opens below Upper Band",
"The bar opens above Upper Band",
"The bar opens below Lower Band",
"The bar opens above Lower Band",
"The position opens below Upper Band",
"The position opens above Upper Band",
"The position opens below Lower Band",
"The position opens above Lower Band",
"The bar opens below Upper Band after opening above it",
"The bar opens above Upper Band after opening below it",
"The bar opens below Lower Band after opening above it",
"The bar opens above Lower Band after opening below it"
};
else if (SlotType == SlotTypes.Close)
IndParam.ListParam[0].ItemList = new[]
{
"Exit long at Upper Band",
"Exit long at Lower Band"
};
else if (SlotType == SlotTypes.CloseFilter)
IndParam.ListParam[0].ItemList = new[]
{
"The bar closes below Upper Band",
"The bar closes above Upper Band",
"The bar closes below Lower Band",
"The bar closes above Lower Band"
};
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 = "Base price";
IndParam.ListParam[1].ItemList = new[] {"Open"};
IndParam.ListParam[1].Index = 0;
IndParam.ListParam[1].Text = "Open";
IndParam.ListParam[1].Enabled = true;
IndParam.ListParam[1].ToolTip = "The reference price is bar Open";
// The NumericUpDown parameters
IndParam.NumParam[0].Caption = "Hour";
IndParam.NumParam[0].Value = 8;
IndParam.NumParam[0].Min = 0;
IndParam.NumParam[0].Max = 23;
IndParam.NumParam[0].Point = 0;
IndParam.NumParam[0].Enabled = true;
IndParam.NumParam[0].ToolTip = "The hour of the reference time";
IndParam.NumParam[1].Caption = "Minutes";
IndParam.NumParam[1].Value = 0;
IndParam.NumParam[1].Min = 0;
IndParam.NumParam[1].Max = 59;
IndParam.NumParam[1].Point = 0;
IndParam.NumParam[1].Enabled = true;
IndParam.NumParam[1].ToolTip = "The minute of the reference time";
IndParam.NumParam[2].Caption = "Price deviation [point]";
IndParam.NumParam[2].Value = 200;
IndParam.NumParam[2].Min = 5;
IndParam.NumParam[2].Max = 2000;
IndParam.NumParam[2].Point = 0;
IndParam.NumParam[2].Enabled = true;
IndParam.NumParam[2].ToolTip = "Determines the channel width.";
// 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.";
}
public override void Calculate(IDataSet dataSet)
{
DataSet = dataSet;
// Reading the parameters
int hour = (int)IndParam.NumParam[0].Value;
int minute = (int)IndParam.NumParam[1].Value;
double margin = IndParam.NumParam[2].Value * Point;
int previous = IndParam.CheckParam[0].Checked ? 1 : 0;
// Calculation
double[] upperBand = new double[Bars];
double[] lowerBand = new double[Bars];
int firstBar = 1;
for (int bar = 1; bar < Bars; bar++)
{
if (Time[bar].Hour == hour && Time[bar].Minute == minute)
{
if (firstBar == 0)
firstBar = bar;
upperBand[bar] = Open[bar] + margin;
lowerBand[bar] = Open[bar] - margin;
}
else
{
upperBand[bar] = upperBand[bar-1];
lowerBand[bar] = lowerBand[bar-1];
}
}
// Saving the components
Component = new IndicatorComp[4];
Component[0] = new IndicatorComp
{
CompName = "Upper Band",
DataType = IndComponentType.IndicatorValue,
ChartType = IndChartType.Level,
ChartColor = Color.Chocolate,
FirstBar = firstBar,
Value = upperBand
};
Component[1] = new IndicatorComp
{
CompName = "Lower Band",
DataType = IndComponentType.IndicatorValue,
ChartType = IndChartType.Level,
ChartColor = Color.Chocolate,
FirstBar = firstBar,
Value = lowerBand
};
Component[2] = new IndicatorComp
{
ChartType = IndChartType.NoChart,
FirstBar = firstBar,
Value = new double[Bars]
};
Component[3] = new IndicatorComp
{
ChartType = IndChartType.NoChart,
FirstBar = firstBar,
Value = new double[Bars]
};
// Sets the Component's type
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";
}
if (SlotType == SlotTypes.Open || SlotType == SlotTypes.Close)
{
for (int bar = firstBar; bar < Bars; bar++)
{
double valueUp = upperBand[bar - previous];
double valueDown = lowerBand[bar - previous];
if (IndParam.ListParam[0].Text == "Enter long at Upper Band" ||
IndParam.ListParam[0].Text == "Exit long at Upper Band")
{
Component[2].Value[bar] = valueUp;
Component[3].Value[bar] = valueDown;
}
else
{
Component[2].Value[bar] = valueDown;
Component[3].Value[bar] = valueUp;
}
}
}
else
{
switch (IndParam.ListParam[0].Text)
{
case "The bar opens below Upper Band":
BandIndicatorLogic(firstBar, previous, upperBand, lowerBand, ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_below_the_Upper_Band);
break;
case "The bar opens above Upper Band":
BandIndicatorLogic(firstBar, previous, upperBand, lowerBand, ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_above_the_Upper_Band);
break;
case "The bar opens below Lower Band":
BandIndicatorLogic(firstBar, previous, upperBand, lowerBand, ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_below_the_Lower_Band);
break;
case "The bar opens above Lower Band":
BandIndicatorLogic(firstBar, previous, upperBand, lowerBand, ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_above_the_Lower_Band);
break;
case "The bar opens below Upper Band after opening above it":
BandIndicatorLogic(firstBar, previous, upperBand, lowerBand, ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_below_the_Upper_Band_after_opening_above_it);
break;
case "The bar opens above Upper Band after opening below it":
BandIndicatorLogic(firstBar, previous, upperBand, lowerBand, ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_above_the_Upper_Band_after_opening_below_it);
break;
case "The bar opens below Lower Band after opening above it":
BandIndicatorLogic(firstBar, previous, upperBand, lowerBand, ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_below_the_Lower_Band_after_opening_above_it);
break;
case "The bar opens above Lower Band after opening below it":
BandIndicatorLogic(firstBar, previous, upperBand, lowerBand, ref Component[2], ref Component[3],
BandIndLogic.The_bar_opens_above_the_Lower_Band_after_opening_below_it);
break;
case "The position opens above Upper Band":
Component[0].PosPriceDependence = PositionPriceDependence.PriceBuyHigher;
Component[1].PosPriceDependence = PositionPriceDependence.PriceSellLower;
Component[0].UsePreviousBar = previous;
Component[1].UsePreviousBar = previous;
Component[2].DataType = IndComponentType.Other;
Component[3].DataType = IndComponentType.Other;
Component[2].ShowInDynInfo = false;
Component[3].ShowInDynInfo = false;
break;
case "The position opens below Upper Band":
Component[0].PosPriceDependence = PositionPriceDependence.PriceBuyLower;
Component[1].PosPriceDependence = PositionPriceDependence.PriceSellHigher;
Component[0].UsePreviousBar = previous;
Component[1].UsePreviousBar = previous;
Component[2].DataType = IndComponentType.Other;
Component[3].DataType = IndComponentType.Other;
Component[2].ShowInDynInfo = false;
Component[3].ShowInDynInfo = false;
break;
case "The position opens above Lower Band":
Component[0].PosPriceDependence = PositionPriceDependence.PriceSellLower;
Component[1].PosPriceDependence = PositionPriceDependence.PriceBuyHigher;
Component[0].UsePreviousBar = previous;
Component[1].UsePreviousBar = previous;
Component[2].DataType = IndComponentType.Other;
Component[3].DataType = IndComponentType.Other;
Component[2].ShowInDynInfo = false;
Component[3].ShowInDynInfo = false;
break;
case "The position opens below Lower Band":
Component[0].PosPriceDependence = PositionPriceDependence.PriceSellHigher;
Component[1].PosPriceDependence = PositionPriceDependence.PriceBuyLower;
Component[0].UsePreviousBar = previous;
Component[1].UsePreviousBar = previous;
Component[2].DataType = IndComponentType.Other;
Component[3].DataType = IndComponentType.Other;
Component[2].ShowInDynInfo = false;
Component[3].ShowInDynInfo = false;
break;
case "The bar closes below Upper Band":
BandIndicatorLogic(firstBar, previous, upperBand, lowerBand, ref Component[2], ref Component[3],
BandIndLogic.The_bar_closes_below_the_Upper_Band);
break;
case "The bar closes above Upper Band":
BandIndicatorLogic(firstBar, previous, upperBand, lowerBand, ref Component[2], ref Component[3],
BandIndLogic.The_bar_closes_above_the_Upper_Band);
break;
case "The bar closes below Lower Band":
BandIndicatorLogic(firstBar, previous, upperBand, lowerBand, ref Component[2], ref Component[3],
BandIndLogic.The_bar_closes_below_the_Lower_Band);
break;
case "The bar closes above Lower Band":
BandIndicatorLogic(firstBar, previous, upperBand, lowerBand, ref Component[2], ref Component[3],
BandIndLogic.The_bar_closes_above_the_Lower_Band);
break;
}
}
}
public override void SetDescription()
{
switch (IndParam.ListParam[0].Text)
{
case "Enter long at Upper Band":
EntryPointLongDescription = "at Upper Band of " + ToString();
EntryPointShortDescription = "at Lower Band of " + ToString();
break;
case "Enter long at Lower Band":
EntryPointLongDescription = "at Lower Band of " + ToString();
EntryPointShortDescription = "at Upper Band of " + ToString();
break;
case "Exit long at Upper Band":
ExitPointLongDescription = "at Upper Band of " + ToString();
ExitPointShortDescription = "at Lower Band of " + ToString();
break;
case "Exit long at Lower Band":
ExitPointLongDescription = "at Lower Band of " + ToString();
ExitPointShortDescription = "at Upper Band of " + ToString();
break;
case "The bar opens below Upper Band":
EntryFilterLongDescription = "the bar opens below Upper Band of " + ToString();
EntryFilterShortDescription = "the bar opens above Lower Band of " + ToString();
break;
case "The bar opens above Upper Band":
EntryFilterLongDescription = "the bar opens above Upper Band of " + ToString();
EntryFilterShortDescription = "the bar opens below Lower Band of " + ToString();
break;
case "The bar opens below Lower Band":
EntryFilterLongDescription = "the bar opens below Lower Band of " + ToString();
EntryFilterShortDescription = "the bar opens above Upper Band of " + ToString();
break;
case "The bar opens above Lower Band":
EntryFilterLongDescription = "the bar opens above Lower Band of " + ToString();
EntryFilterShortDescription = "the bar opens below Upper Band of " + ToString();
break;
case "The position opens above Upper Band":
EntryFilterLongDescription = "the position opening price is higher than Upper Band of " + ToString();
EntryFilterShortDescription = "the position opening price is lower than Lower Band of " + ToString();
break;
case "The position opens below Upper Band":
EntryFilterLongDescription = "the position opening price is lower than Upper Band of " + ToString();
EntryFilterShortDescription = "the position opening price is higher than Lower Band of " +
ToString();
break;
case "The position opens above Lower Band":
EntryFilterLongDescription = "the position opening price is higher than Lower Band of " + ToString();
EntryFilterShortDescription = "the position opening price is lower than Upper Band of " + ToString();
break;
case "The position opens below Lower Band":
EntryFilterLongDescription = "the position opening price is lower than Lower Band of " + ToString();
EntryFilterShortDescription = "the position opening price is higher than Upper Band of " +
ToString();
break;
case "The bar opens below Upper Band after opening above it":
EntryFilterLongDescription = "the bar opens below Upper Band of " + ToString() +
" after the previous bar has opened above it";
EntryFilterShortDescription = "the bar opens above Lower Band of " + ToString() +
" after the previous bar has opened below it";
break;
case "The bar opens above Upper Band after opening below it":
EntryFilterLongDescription = "the bar opens above Upper Band of " + ToString() +
" after the previous bar has opened below it";
EntryFilterShortDescription = "the bar opens below Lower Band of " + ToString() +
" after the previous bar has opened above it";
break;
case "The bar opens below Lower Band after opening above it":
EntryFilterLongDescription = "the bar opens below Lower Band of " + ToString() +
" after the previous bar has opened above it";
EntryFilterShortDescription = "the bar opens above Upper Band of " + ToString() +
" after the previous bar has opened below it";
break;
case "The bar opens above Lower Band after opening below it":
EntryFilterLongDescription = "the bar opens above Lower Band of " + ToString() +
" after the previous bar has opened below it";
EntryFilterShortDescription = "the bar opens below Upper Band of " + ToString() +
" after the previous bar has opened above it";
break;
case "The bar closes below Upper Band":
ExitFilterLongDescription = "the bar closes below Upper Band of " + ToString();
ExitFilterShortDescription = "the bar closes above Lower Band of " + ToString();
break;
case "The bar closes above Upper Band":
ExitFilterLongDescription = "the bar closes above Upper Band of " + ToString();
ExitFilterShortDescription = "the bar closes below Lower Band of " + ToString();
break;
case "The bar closes below Lower Band":
ExitFilterLongDescription = "the bar closes below Lower Band of " + ToString();
ExitFilterShortDescription = "the bar closes above Upper Band of " + ToString();
break;
case "The bar closes above Lower Band":
ExitFilterLongDescription = "the bar closes above Lower Band of " + ToString();
ExitFilterShortDescription = "the bar closes below Upper Band of " + ToString();
break;
}
}
public override string ToString()
{
return IndicatorName +
(IndParam.CheckParam[0].Checked ? "* (" : " (") +
IndParam.NumParam[0].ValueToString + ", " +
IndParam.NumParam[1].ValueToString + ", " +
IndParam.NumParam[2].ValueToString + ")";
}
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226//+--------------------------------------------------------------------+ //| Copyright: (C) 2014 Forex Software Ltd. | //| 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 (C) 2014 Forex Software Ltd." #property link "http://forexsb.com" #property version "2.00" #property strict #include <Forexsb.com/Indicator.mqh> #include <Forexsb.com/Enumerations.mqh> //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class TimePriceChannel : public Indicator { public: TimePriceChannel(SlotTypes slotType) { SlotType=slotType; IndicatorName="Time Price Channel"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDeafultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void TimePriceChannel::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); int hour = (int)NumParam[0].Value; int minute = (int)NumParam[1].Value; double margin = NumParam[2].Value * Data.Point; int previous = CheckParam[0].Checked ? 1 : 0; double upperBand[]; ArrayResize(upperBand,Data.Bars); ArrayInitialize(upperBand,0); double lowerBand[]; ArrayResize(lowerBand,Data.Bars); ArrayInitialize(lowerBand,0); int firstBar=1; for(int bar=1; bar<Data.Bars; bar++) { datetime time=Data.Time[bar]; if(TimeHour(Data.Time[bar])==hour && TimeMinute(Data.Time[bar])==minute) { if(firstBar==0) firstBar=bar; upperBand[bar] = Data.Open[bar] + margin; lowerBand[bar] = Data.Open[bar] - margin; } else { upperBand[bar] = upperBand[bar-1]; lowerBand[bar] = lowerBand[bar-1]; } } ArrayResize(Component[0].Value,Data.Bars); Component[0].CompName = "Upper Band"; Component[0].DataType = IndComponentType_IndicatorValue; Component[0].FirstBar = firstBar; ArrayCopy(Component[0].Value,upperBand); ArrayResize(Component[1].Value,Data.Bars); Component[1].CompName = "Lower Band"; Component[1].DataType = IndComponentType_IndicatorValue; Component[1].FirstBar = firstBar; ArrayCopy(Component[1].Value,lowerBand); ArrayResize(Component[2].Value,Data.Bars); Component[2].FirstBar=firstBar; ArrayResize(Component[3].Value,Data.Bars); Component[3].FirstBar=firstBar; 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"; } if(SlotType==SlotTypes_Open || SlotType==SlotTypes_Close) { if(ListParam[0].Text=="Enter long at Upper Band" || ListParam[0].Text=="Exit long at Upper Band") { for(int bar=firstBar; bar<Data.Bars; bar++) { Component[2].Value[bar] = upperBand[bar - previous]; Component[3].Value[bar] = lowerBand[bar - previous]; } } else { for(int bar=firstBar; bar<Data.Bars; bar++) { Component[2].Value[bar] = lowerBand[bar - previous]; Component[3].Value[bar] = upperBand[bar - previous]; } } } else { if(ListParam[0].Text=="The bar opens below Upper Band") BandIndicatorLogic(firstBar,previous,upperBand,lowerBand,Component[2],Component[3],BandIndLogic_The_bar_opens_below_the_Upper_Band); else if(ListParam[0].Text=="The bar opens above Upper Band") BandIndicatorLogic(firstBar,previous,upperBand,lowerBand,Component[2],Component[3],BandIndLogic_The_bar_opens_above_the_Upper_Band); else if(ListParam[0].Text=="The bar opens below Lower Band") BandIndicatorLogic(firstBar,previous,upperBand,lowerBand,Component[2],Component[3],BandIndLogic_The_bar_opens_below_the_Lower_Band); else if(ListParam[0].Text=="The bar opens above Lower Band") BandIndicatorLogic(firstBar,previous,upperBand,lowerBand,Component[2],Component[3],BandIndLogic_The_bar_opens_above_the_Lower_Band); else if(ListParam[0].Text=="The bar opens below Upper Band after opening above it") BandIndicatorLogic(firstBar,previous,upperBand,lowerBand,Component[2],Component[3],BandIndLogic_The_bar_opens_below_Upper_Band_after_above); else if(ListParam[0].Text=="The bar opens above Upper Band after opening below it") BandIndicatorLogic(firstBar,previous,upperBand,lowerBand,Component[2],Component[3],BandIndLogic_The_bar_opens_above_Upper_Band_after_below); else if(ListParam[0].Text=="The bar opens below Lower Band after opening above it") BandIndicatorLogic(firstBar,previous,upperBand,lowerBand,Component[2],Component[3],BandIndLogic_The_bar_opens_below_Lower_Band_after_above); else if(ListParam[0].Text=="The bar opens above Lower Band after opening below it") BandIndicatorLogic(firstBar,previous,upperBand,lowerBand,Component[2],Component[3],BandIndLogic_The_bar_opens_above_Lower_Band_after_below); else if(ListParam[0].Text=="The position opens above Upper Band") { Component[0].PosPriceDependence = PositionPriceDependence_PriceBuyHigher; Component[1].PosPriceDependence = PositionPriceDependence_PriceSellLower; Component[0].UsePreviousBar = previous; Component[1].UsePreviousBar = previous; Component[2].DataType = IndComponentType_Other; Component[3].DataType = IndComponentType_Other; Component[2].ShowInDynInfo = false; Component[3].ShowInDynInfo = false; } else if(ListParam[0].Text=="The position opens below Upper Band") { Component[0].PosPriceDependence = PositionPriceDependence_PriceBuyLower; Component[1].PosPriceDependence = PositionPriceDependence_PriceSellHigher; Component[0].UsePreviousBar = previous; Component[1].UsePreviousBar = previous; Component[2].DataType = IndComponentType_Other; Component[3].DataType = IndComponentType_Other; Component[2].ShowInDynInfo = false; Component[3].ShowInDynInfo = false; } else if(ListParam[0].Text=="The position opens above Lower Band") { Component[0].PosPriceDependence = PositionPriceDependence_PriceSellLower; Component[1].PosPriceDependence = PositionPriceDependence_PriceBuyHigher; Component[0].UsePreviousBar = previous; Component[1].UsePreviousBar = previous; Component[2].DataType = IndComponentType_Other; Component[3].DataType = IndComponentType_Other; Component[2].ShowInDynInfo = false; Component[3].ShowInDynInfo = false; } else if(ListParam[0].Text=="The position opens below Lower Band") { Component[0].PosPriceDependence = PositionPriceDependence_PriceSellHigher; Component[1].PosPriceDependence = PositionPriceDependence_PriceBuyLower; Component[0].UsePreviousBar = previous; Component[1].UsePreviousBar = previous; Component[2].DataType = IndComponentType_Other; Component[3].DataType = IndComponentType_Other; Component[2].ShowInDynInfo = false; Component[3].ShowInDynInfo = false; } else if(ListParam[0].Text=="The bar closes below Upper Band") BandIndicatorLogic(firstBar,previous,upperBand,lowerBand,Component[2],Component[3],BandIndLogic_The_bar_closes_below_the_Upper_Band); else if(ListParam[0].Text=="The bar closes above Upper Band") BandIndicatorLogic(firstBar,previous,upperBand,lowerBand,Component[2],Component[3],BandIndLogic_The_bar_closes_above_the_Upper_Band); else if(ListParam[0].Text=="The bar closes below Lower Band") BandIndicatorLogic(firstBar,previous,upperBand,lowerBand,Component[2],Component[3],BandIndLogic_The_bar_closes_below_the_Lower_Band); else if(ListParam[0].Text=="The bar closes above Lower Band") BandIndicatorLogic(firstBar,previous,upperBand,lowerBand,Component[2],Component[3],BandIndLogic_The_bar_closes_above_the_Lower_Band); } } //+------------------------------------------------------------------+
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.;