FRAMA by footon
46659 downloads / 6236 views / Created: 24.05.2013




Average Rating: 0
Comments
One thing you can do to optimize it is to precompute the higuer highs and lower lows and then in the main loop simply use this code:
for (int iBar = iFirstBar; iBar < Bars; ++iBar)
{
double Hi1 = HH[iBar];
double Lo1 = LL[iBar];
double Hi2 = HH[iBar - PeriodFRAMA];
double Lo2 = LL[iBar - PeriodFRAMA];
double Hi3 = Math.Max(Hi1, Hi2);
double Lo3 = Math.Min(Lo1, Lo2);
double N1 = (Hi1 - Lo1) / PeriodFRAMA;
double N2 = (Hi2 - Lo2) / PeriodFRAMA;
double N3 = (Hi3 - Lo3) / PeriodFRAMA2;
double D = (Math.Log(N1 + N2) - Math.Log(N3)) / log2;
double ALFA = Math.Exp(-4.6 * (D - 1.0));
ExtMapBuffer1[iBar] = ALFA * adBasePrice[iBar] + (1 - ALFA) * ExtMapBuffer1[iBar - 1];
}
for (int iBar = iFirstBar; iBar < Bars; ++iBar)
{
double Hi1 = HH[iBar];
double Lo1 = LL[iBar];
double Hi2 = HH[iBar - PeriodFRAMA];
double Lo2 = LL[iBar - PeriodFRAMA];
double Hi3 = Math.Max(Hi1, Hi2);
double Lo3 = Math.Min(Lo1, Lo2);
double N1 = (Hi1 - Lo1) / PeriodFRAMA;
double N2 = (Hi2 - Lo2) / PeriodFRAMA;
double N3 = (Hi3 - Lo3) / PeriodFRAMA2;
double D = (Math.Log(N1 + N2) - Math.Log(N3)) / log2;
double ALFA = Math.Exp(-4.6 * (D - 1.0));
ExtMapBuffer1[iBar] = ALFA * adBasePrice[iBar] + (1 - ALFA) * ExtMapBuffer1[iBar - 1];
}
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
//==============================================================
// Forex Strategy Builder
// Copyright (c) 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 FRAMA : Indicator
{
public FRAMA()
{
IndicatorName = "FRAMA";
PossibleSlots = SlotTypes.Open | SlotTypes.OpenFilter | SlotTypes.Close | SlotTypes.CloseFilter;
IndicatorAuthor = "Footon";
IndicatorVersion = "2.0";
IndicatorDescription = "Footon's indi corner: custom indicators for FSB and FST.";
}
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 string[]
{
"Enter the market at the Moving Average"
};
else if (SlotType == SlotTypes.OpenFilter)
IndParam.ListParam[0].ItemList = new string[]
{
"The Moving Average rises",
"The Moving Average falls",
"The bar opens above the Moving Average",
"The bar opens below the Moving Average",
"The bar opens above the Moving Average after opening below it",
"The bar opens below the Moving Average after opening above it",
"The position opens above the Moving Average",
"The position opens below the Moving Average",
};
else if (SlotType == SlotTypes.Close)
IndParam.ListParam[0].ItemList = new string[]
{
"Exit the market at the Moving Average"
};
else if (SlotType == SlotTypes.CloseFilter)
IndParam.ListParam[0].ItemList = new string[]
{
"The Moving Average rises",
"The Moving Average falls",
"The bar closes below the Moving Average",
"The bar closes above the Moving Average",
};
else
IndParam.ListParam[0].ItemList = new string[]
{
"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 Moving Average.";
IndParam.ListParam[2].Caption = "Base price";
IndParam.ListParam[2].ItemList = Enum.GetNames(typeof(BasePrice));
IndParam.ListParam[2].Index = (int)BasePrice.Close;
IndParam.ListParam[2].Text = IndParam.ListParam[2].ItemList[IndParam.ListParam[2].Index];
IndParam.ListParam[2].Enabled = true;
IndParam.ListParam[2].ToolTip = "The price the Moving Average is based on.";
// The NumericUpDown parameters
IndParam.NumParam[0].Caption = "PeriodFRAMA";
IndParam.NumParam[0].Value = 10;
IndParam.NumParam[0].Min = 2;
IndParam.NumParam[0].Max = 200;
IndParam.NumParam[0].Enabled = true;
IndParam.NumParam[0].ToolTip = "The Moving Average period.";
// 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.";
return;
}
public override void Calculate(IDataSet dataSet)
{
DataSet = dataSet;
// Reading the parameters
BasePrice basePrice = (BasePrice)IndParam.ListParam[2].Index;
int PeriodFRAMA = (int)IndParam.NumParam[0].Value;
int iPrvs = IndParam.CheckParam[0].Checked ? 1 : 0;
int iFirstBar = PeriodFRAMA + PeriodFRAMA + 3;
double[] ExtMapBuffer1 = new double[Bars];
double[] adBasePrice = Price(basePrice);
double N1 = 0;
double N2 = 0;
double N3 = 0;
double D = 0;
double ALFA = 0;
for (int iBar = iFirstBar; iBar < Bars; iBar++)
{
double Hi1 = 0;
double Lo1 = 1000;
double Hi2 = 0;
double Lo2 = 1000;
double Hi3 = 0;
double Lo3 = 1000;
for (int k=0; k < PeriodFRAMA; k++)
{
Hi1 = Math.Max(Hi1, High[iBar-k]);
Lo1 = Math.Min(Lo1, Low[iBar-k]);
}
for (int k=PeriodFRAMA; k < PeriodFRAMA+PeriodFRAMA; k++)
{
Hi2 = Math.Max(Hi2, High[iBar-k]);
Lo2 = Math.Min(Low[iBar-k], Lo2);
}
for (int k=0; k < PeriodFRAMA+PeriodFRAMA; k++)
{
Hi3 = Math.Max(Hi3, High[iBar-k]);
Lo3 = Math.Min(Low[iBar-k], Lo3);
}
N1=(Hi1-Lo1)/PeriodFRAMA;
N2=(Hi2-Lo2)/PeriodFRAMA;
N3=(Hi3-Lo3)/(2*PeriodFRAMA);
D=(Math.Log(N1+N2)-Math.Log(N3))/Math.Log(2.0);
ALFA=Math.Exp(-4.6*(D-1.0));
ExtMapBuffer1[iBar]=ALFA*adBasePrice[iBar]+(1-ALFA)*ExtMapBuffer1[iBar-1];
}
// Saving the components
if (SlotType == SlotTypes.Open || SlotType == SlotTypes.Close)
{
Component = new IndicatorComp[2];
Component[1] = new IndicatorComp();
Component[1].Value = new double[Bars];
for (int iBar = iFirstBar; iBar < Bars; iBar++)
{ // Covers the cases when the price can pass through the MA without a signal
double dValue = ExtMapBuffer1[iBar - iPrvs]; // Current value
double dValue1 = ExtMapBuffer1[iBar - iPrvs - 1]; // Previous value
double dTempVal = dValue;
if ((dValue1 > High[iBar - 1] && dValue < Open[iBar]) || // The Open price jumps above the indicator
(dValue1 < Low[iBar - 1] && dValue > Open[iBar]) || // The Open price jumps below the indicator
(Close[iBar - 1] < dValue && dValue < Open[iBar]) || // The Open price is in a positive gap
(Close[iBar - 1] > dValue && dValue > Open[iBar])) // The Open price is in a negative gap
dTempVal = Open[iBar];
Component[1].Value[iBar] = dTempVal; // Entry or exit value
}
}
else
{
Component = new IndicatorComp[3];
Component[1] = new IndicatorComp();
Component[1].ChartType = IndChartType.NoChart;
Component[1].FirstBar = iFirstBar;
Component[1].Value = new double[Bars];
Component[2] = new IndicatorComp();
Component[2].ChartType = IndChartType.NoChart;
Component[2].FirstBar = iFirstBar;
Component[2].Value = new double[Bars];
}
Component[0] = new IndicatorComp();
Component[0].CompName = "MA Value";
Component[0].DataType = IndComponentType.IndicatorValue;
Component[0].ChartType = IndChartType.Line;
Component[0].ChartColor = Color.Red;
Component[0].FirstBar = iFirstBar;
Component[0].Value = ExtMapBuffer1;
if (SlotType == SlotTypes.Open)
{
Component[1].CompName = "Position opening price";
Component[1].DataType = IndComponentType.OpenPrice;
}
else if (SlotType == SlotTypes.OpenFilter)
{
Component[1].DataType = IndComponentType.AllowOpenLong;
Component[1].CompName = "Is long entry allowed";
Component[2].DataType = IndComponentType.AllowOpenShort;
Component[2].CompName = "Is short entry allowed";
}
else if (SlotType == SlotTypes.Close)
{
Component[1].CompName = "Position closing price";
Component[1].DataType = IndComponentType.ClosePrice;
}
else if (SlotType == SlotTypes.CloseFilter)
{
Component[1].DataType = IndComponentType.ForceCloseLong;
Component[1].CompName = "Close out long position";
Component[2].DataType = IndComponentType.ForceCloseShort;
Component[2].CompName = "Close out short position";
}
if (SlotType == SlotTypes.OpenFilter || SlotType == SlotTypes.CloseFilter)
{
switch (IndParam.ListParam[0].Text)
{
case "The Moving Average rises":
IndicatorRisesLogic(iFirstBar, iPrvs, ExtMapBuffer1, ref Component[1], ref Component[2]);
break;
case "The Moving Average falls":
IndicatorFallsLogic(iFirstBar, iPrvs, ExtMapBuffer1, ref Component[1], ref Component[2]);
break;
case "The bar opens above the Moving Average":
BarOpensAboveIndicatorLogic(iFirstBar, iPrvs, ExtMapBuffer1, ref Component[1], ref Component[2]);
break;
case "The bar opens below the Moving Average":
BarOpensBelowIndicatorLogic(iFirstBar, iPrvs, ExtMapBuffer1, ref Component[1], ref Component[2]);
break;
case "The bar opens above the Moving Average after opening below it":
BarOpensAboveIndicatorAfterOpeningBelowLogic(iFirstBar, iPrvs, ExtMapBuffer1, ref Component[1], ref Component[2]);
break;
case "The bar opens below the Moving Average after opening above it":
BarOpensBelowIndicatorAfterOpeningAboveLogic(iFirstBar, iPrvs, ExtMapBuffer1, ref Component[1], ref Component[2]);
break;
case "The position opens above the Moving Average":
Component[0].PosPriceDependence = PositionPriceDependence.BuyHigherSellLower;
Component[0].UsePreviousBar = iPrvs;
Component[1].DataType = IndComponentType.Other;
Component[1].ShowInDynInfo = false;
Component[2].DataType = IndComponentType.Other;
Component[2].ShowInDynInfo = false;
break;
case "The position opens below the Moving Average":
Component[0].PosPriceDependence = PositionPriceDependence.BuyLowerSelHigher;
Component[0].UsePreviousBar = iPrvs;
Component[1].DataType = IndComponentType.Other;
Component[1].ShowInDynInfo = false;
Component[2].DataType = IndComponentType.Other;
Component[2].ShowInDynInfo = false;
break;
case "The bar closes below the Moving Average":
BarClosesBelowIndicatorLogic(iFirstBar, iPrvs, ExtMapBuffer1, ref Component[1], ref Component[2]);
break;
case "The bar closes above the Moving Average":
BarClosesAboveIndicatorLogic(iFirstBar, iPrvs, ExtMapBuffer1, ref Component[1], ref Component[2]);
break;
default:
break;
}
}
return;
}
///
/// Sets the indicator logic description
///
public override void SetDescription()
{
EntryPointLongDescription = "at the " + ToString();
EntryPointShortDescription = "at the " + ToString();
ExitPointLongDescription = "at the " + ToString();
ExitPointShortDescription = "at the " + ToString();
switch (IndParam.ListParam[0].Text)
{
case "The Moving Average rises":
EntryFilterLongDescription = "the " + ToString() + " rises";
EntryFilterShortDescription = "the " + ToString() + " falls";
ExitFilterLongDescription = "the " + ToString() + " rises";
ExitFilterShortDescription = "the " + ToString() + " falls";
break;
case "The Moving Average falls":
EntryFilterLongDescription = "the " + ToString() + " falls";
EntryFilterShortDescription = "the " + ToString() + " rises";
ExitFilterLongDescription = "the " + ToString() + " falls";
ExitFilterShortDescription = "the " + ToString() + " rises";
break;
case "The bar opens above the Moving Average":
EntryFilterLongDescription = "the bar opens above the " + ToString();
EntryFilterShortDescription = "the bar opens below the " + ToString();
break;
case "The bar opens below the Moving Average":
EntryFilterLongDescription = "the bar opens below the " + ToString();
EntryFilterShortDescription = "the bar opens above the " + ToString();
break;
case "The position opens above the Moving Average":
EntryFilterLongDescription = "the position opening price is higher than the " + ToString();
EntryFilterShortDescription = "the position opening price is lower than the " + ToString();
break;
case "The position opens below the Moving Average":
EntryFilterLongDescription = "the position opening price is lower than the " + ToString();
EntryFilterShortDescription = "the position opening price is higher than the " + ToString();
break;
case "The bar opens above the Moving Average after opening below it":
EntryFilterLongDescription = "the bar opens above the " + ToString() + " after opening below it";
EntryFilterShortDescription = "the bar opens below the " + ToString() + " after opening above it";
break;
case "The bar opens below the Moving Average after opening above it":
EntryFilterLongDescription = "the bar opens below the " + ToString() + " after opening above it";
EntryFilterShortDescription = "the bar opens above the " + ToString() + " after opening below it";
break;
case "The bar closes above the Moving Average":
ExitFilterLongDescription = "the bar closes above the " + ToString();
ExitFilterShortDescription = "the bar closes below the " + ToString();
break;
case "The bar closes below the Moving Average":
ExitFilterLongDescription = "the bar closes below the " + ToString();
ExitFilterShortDescription = "the bar closes above the " + ToString();
break;
default:
break;
}
return;
}
///
/// Indicator to string
///
public override string ToString()
{
string sString = IndicatorName +
(IndParam.CheckParam[0].Checked ? "* (" : " (") +
IndParam.ListParam[1].Text + ", " + // Method
IndParam.ListParam[2].Text + ", " + // Price
IndParam.NumParam[0].ValueToString + ", " + // MA period
IndParam.NumParam[1].ValueToString + ")"; // MA shift
return sString;
}
}
}
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//+--------------------------------------------------------------------+ //| 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 FRAMA : public Indicator { public: FRAMA(SlotTypes slotType) { SlotType=slotType; IndicatorName="FRAMA"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDefaultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void FRAMA::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // Reading the parameters BasePrice basePrice=(BasePrice) ListParam[2].Index; int PeriodFRAMA=(int) NumParam[0].Value; int previous=CheckParam[0].Checked ? 1 : 0; // Calculation double ExtMapBuffer1[]; ArrayResize(ExtMapBuffer1,Data.Bars); ArrayInitialize(ExtMapBuffer1,0); double adBasePrice[]; Price(basePrice,adBasePrice); int firstBar=PeriodFRAMA + PeriodFRAMA + 3; double N1 = 0; double N2 = 0; double N3 = 0; double D = 0; double ALFA = 0; for (int iBar = firstBar; iBar < Data.Bars; iBar++) { double Hi1 = 0; double Lo1 = 1000; double Hi2 = 0; double Lo2 = 1000; double Hi3 = 0; double Lo3 = 1000; for (int k=0; k < PeriodFRAMA; k++) { Hi1 = MathMax(Hi1, Data.High[iBar-k]); Lo1 = MathMin(Lo1, Data.Low[iBar-k]); } for (int k=PeriodFRAMA; k < PeriodFRAMA+PeriodFRAMA; k++) { Hi2 = MathMax(Hi2, Data.High[iBar-k]); Lo2 = MathMin(Data.Low[iBar-k], Lo2); } for (int k=0; k < PeriodFRAMA+PeriodFRAMA; k++) { Hi3 = MathMax(Hi3, Data.High[iBar-k]); Lo3 = MathMin(Data.Low[iBar-k], Lo3); } N1=(Hi1-Lo1)/PeriodFRAMA; N2=(Hi2-Lo2)/PeriodFRAMA; N3=(Hi3-Lo3)/(2*PeriodFRAMA); D=(MathLog(N1+N2)-MathLog(N3))/MathLog(2.0); ALFA=MathExp(-4.6*(D-1.0)); ExtMapBuffer1[iBar]=ALFA*adBasePrice[iBar]+(1-ALFA)*ExtMapBuffer1[iBar-1]; } // Saving the components if(SlotType==SlotTypes_Open || SlotType==SlotTypes_Close) { ArrayResize(Component[1].Value, Data.Bars); ArrayInitialize(Component[1].Value,0); for(int bar=firstBar; bar<Data.Bars; bar++) { // Covers the cases when the price can pass through the MA without a signal double value = ExtMapBuffer1[bar-previous]; // Current value double value1 = ExtMapBuffer1[bar-previous-1]; // Previous value double tempVal = value; if((value1 > Data.High[bar - 1] && value < Data.Open[bar]) || // The Data.Open price jumps above the indicator (value1 < Data.Low[bar - 1] && value > Data.Open[bar]) || // The Data.Open price jumps below the indicator (Data.Close[bar-1]<value && value < Data.Open[bar]) || // The Data.Open price is in a positive gap (Data.Close[bar-1]>value && value > Data.Open[bar])) // The Data.Open price is in a negative gap tempVal=Data.Open[bar]; Component[1].Value[bar]=tempVal; // Entry or exit value } } else { ArrayResize(Component[1].Value, Data.Bars); ArrayResize(Component[2].Value, Data.Bars); } ArrayResize(Component[0].Value,Data.Bars); Component[0].CompName = "MA Value"; Component[0].DataType = IndComponentType_IndicatorValue; Component[0].FirstBar = firstBar; ArrayCopy(Component[0].Value,ExtMapBuffer1); if(SlotType==SlotTypes_Open) { Component[1].CompName = "Position opening price"; Component[1].DataType = IndComponentType_OpenPrice; } if(SlotType==SlotTypes_OpenFilter) { Component[1].DataType = IndComponentType_AllowOpenLong; Component[1].CompName = "Is long entry allowed"; Component[2].DataType = IndComponentType_AllowOpenShort; Component[2].CompName = "Is short entry allowed"; } if(SlotType==SlotTypes_Close) { Component[1].CompName = "Position closing price"; Component[1].DataType = IndComponentType_ClosePrice; } if(SlotType==SlotTypes_CloseFilter) { Component[1].DataType = IndComponentType_ForceCloseLong; Component[1].CompName = "Close out long position"; Component[2].DataType = IndComponentType_ForceCloseShort; Component[2].CompName = "Close out short position"; } if(SlotType==SlotTypes_OpenFilter || SlotType==SlotTypes_CloseFilter) { if(ListParam[0].Text=="The Moving Average rises") IndicatorRisesLogic(firstBar,previous,ExtMapBuffer1,Component[1],Component[2]); else if(ListParam[0].Text=="The Moving Average falls") IndicatorFallsLogic(firstBar,previous,ExtMapBuffer1,Component[1],Component[2]); else if(ListParam[0].Text=="The bar opens above the Moving Average") BarOpensAboveIndicatorLogic(firstBar,previous,ExtMapBuffer1,Component[1],Component[2]); else if(ListParam[0].Text=="The bar opens below the Moving Average") BarOpensBelowIndicatorLogic(firstBar,previous,ExtMapBuffer1,Component[1],Component[2]); else if(ListParam[0].Text=="The bar opens above the Moving Average after opening below it") BarOpensAboveIndicatorAfterOpeningBelowLogic(firstBar,previous,ExtMapBuffer1,Component[1],Component[2]); else if(ListParam[0].Text=="The bar opens below the Moving Average after opening above it") BarOpensBelowIndicatorAfterOpeningAboveLogic(firstBar,previous,ExtMapBuffer1,Component[1],Component[2]); else if(ListParam[0].Text=="The position opens above the Moving Average") { Component[0].PosPriceDependence=PositionPriceDependence_BuyHigherSellLower; Component[1].DataType=IndComponentType_Other; Component[1].ShowInDynInfo=false; Component[2].DataType=IndComponentType_Other; Component[2].ShowInDynInfo=false; } else if(ListParam[0].Text=="The position opens below the Moving Average") { Component[0].PosPriceDependence=PositionPriceDependence_BuyLowerSellHigher; Component[1].DataType=IndComponentType_Other; Component[1].ShowInDynInfo=false; Component[2].DataType=IndComponentType_Other; Component[2].ShowInDynInfo=false; } else if(ListParam[0].Text=="The bar closes below the Moving Average") BarClosesBelowIndicatorLogic(firstBar,previous,ExtMapBuffer1,Component[1],Component[2]); else if(ListParam[0].Text=="The bar closes above the Moving Average") BarClosesAboveIndicatorLogic(firstBar,previous,ExtMapBuffer1,Component[1],Component[2]); } } //+------------------------------------------------------------------+
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.;