Spread Level Pro by Popov
46571 downloads / 4966 views / Created: 13.07.2013 Average Rating: 5
Indicator Description
This indicators is designed to work in FSB Pro. It differs from Spread Limiter by the way it takes the Spread.
In Builder mode: indicator uses Spread sets in the Symbol properties. It's a constant value.
In Trader mode: indicator calculates Spread = (Ask - Bid)/Point.
In Builder mode: indicator uses Spread sets in the Symbol properties. It's a constant value.
In Trader mode: indicator calculates Spread = (Ask - Bid)/Point.
Comments
Yesterday ( 2015 01 15 ) this indicator could save many accounts which traded CHF pairs and not only after the 2800 pips drop of EURCHF (in some brokers I measured that the drop was 7800 pips and the spread the same time was more than 300 pips).
Thanks to God this drop did not harm me at all.
I believe that Spread Level Pro is a must for every Strategy.
It can save your entire account from crashes like this and not only.
Thanks to God this drop did not harm me at all.
I believe that Spread Level Pro is a must for every Strategy.
It can save your entire account from crashes like this and not only.
Fixed visualization of the spread on Builder mode. However, you should not use this indicator for backtesting since the history data doesn't contain spread information. The indicator shows a fixed value on Builder mode.
//==============================================================
// Forex Strategy Builder
// Copyright Р’В© Miroslav Popov. All rights reserved.
//==============================================================
// THIS CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
//==============================================================
using System;
using ForexStrategyBuilder.Infrastructure.Entities;
using ForexStrategyBuilder.Infrastructure.Enums;
using ForexStrategyBuilder.Infrastructure.Interfaces;
namespace ForexStrategyBuilder.Indicators.Store
{
public class SpreadLevelPro : Indicator
{
public SpreadLevelPro()
{
IndicatorName = "Spread Level Pro";
PossibleSlots = SlotTypes.OpenFilter | SlotTypes.CloseFilter;
IsDeafultGroupAll = true;
IsGeneratable = false;
WarningMessage = "The indicator works properly only on Trader mode.";
IndicatorAuthor = "Popov";
IndicatorVersion = "2.2";
IndicatorDescription = "A custom indicator for FST. Based on Footon's Spread Limiter";
}
public override void Initialize(SlotTypes slotType)
{
SlotType = slotType;
IndParam.IndicatorType = TypeOfIndicator.Additional;
// The ComboBox parameters
IndParam.ListParam[0].Caption = "Logic";
IndParam.ListParam[0].ItemList = new[]
{
"Spread is lower than the selected level",
"Spread is higher than the selected level"
};
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 = "Indicator's logic.";
// The NumericUpDown parameters
IndParam.NumParam[0].Caption = "Spread level in points";
IndParam.NumParam[0].Value = 20;
IndParam.NumParam[0].Min = 1;
IndParam.NumParam[0].Max = 500;
IndParam.NumParam[0].Enabled = true;
IndParam.NumParam[0].ToolTip = "Spread in points.";
}
public override void Calculate(IDataSet dataSet)
{
DataSet = dataSet;
// Reading the parameters
double spreadLevel = IndParam.NumParam[0].Value;
// Calculation
const int firstBar = 1;
double spread = IsBacktester
? DataSet.Properties.Spread
: (DataSet.Ask - DataSet.Bid)/Point;
var spr = new double[Bars];
var showspread = new double[Bars];
switch (IndParam.ListParam[0].Text)
{
case "Spread is lower than the selected level":
if (spread < spreadLevel - Epsilon)
for (int bar = 1; bar < Bars; bar++)
spr[bar] = 1;
break;
case "Spread is higher than the selected level":
if (spread > spreadLevel + Epsilon)
for (int bar = 1; bar < Bars; bar++)
spr[bar] = 1;
break;
}
for (int bar = 1; bar < Bars; bar++)
showspread[bar] = spread;
Component = SlotType == SlotTypes.OpenFilter
? new IndicatorComp[3]
: new IndicatorComp[2];
Component[0] = new IndicatorComp
{
CompName = "Spread",
DataType = IndComponentType.IndicatorValue,
ChartType = IndChartType.NoChart,
FirstBar = firstBar,
Value = showspread
};
if (SlotType == SlotTypes.OpenFilter)
{
Component[1] = new IndicatorComp
{
CompName = "Is long entry allowed",
DataType = IndComponentType.AllowOpenLong,
ChartType = IndChartType.NoChart,
FirstBar = firstBar,
Value = spr
};
Component[2] = new IndicatorComp
{
CompName = "Is short entry allowed",
DataType = IndComponentType.AllowOpenShort,
ChartType = IndChartType.NoChart,
FirstBar = firstBar,
Value = spr
};
}
else if (SlotType == SlotTypes.CloseFilter)
{
Component[1] = new IndicatorComp
{
CompName = "Force close",
DataType = IndComponentType.ForceClose,
ChartType = IndChartType.NoChart,
FirstBar = firstBar,
Value = spr
};
}
}
public override void SetDescription()
{
var spreadLevel = IndParam.NumParam[0].Value.ToString("F1");
switch (IndParam.ListParam[0].Text)
{
case "Spread is lower than the selected level":
var lowerThan = "Spread is lower than " + spreadLevel;
EntryFilterLongDescription = lowerThan;
EntryFilterShortDescription = lowerThan;
ExitFilterLongDescription = lowerThan;
ExitFilterShortDescription = lowerThan;
break;
case "Spread is higher than the selected level":
var higherThan = "Spread is higher than " + spreadLevel;
EntryFilterLongDescription = higherThan;
EntryFilterShortDescription = higherThan;
ExitFilterLongDescription = higherThan;
ExitFilterShortDescription = higherThan;
break;
}
}
public override string ToString()
{
return IndicatorName;
}
}
}
//+--------------------------------------------------------------------+ //| Copyright: (C) 2014, Miroslav Popov - All rights reserved! | //| 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 | //| another applications without a permission. 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 2014, Miroslav Popov" #property link "http://forexsb.com" #property version "1.00" #property strict #include <Forexsb.com/Indicator.mqh> #include <Forexsb.com/Enumerations.mqh> //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class SpreadLevelPro : public Indicator { public: SpreadLevelPro(SlotTypes slotType) { SlotType=slotType; IndicatorName="Spread Level Pro"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDeafultGroupAll = true; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void SpreadLevelPro::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); // Reading the parameters double spreadLevel=NumParam[0].Value; // Calculation const int firstBar=1; double spread=(Data.Ask-Data.Bid)/Data.Point; double spr[]; ArrayResize(spr,Data.Bars);ArrayInitialize(spr,0); if(ListParam[0].Text=="Spread is lower than the selected level") { if(spread<spreadLevel-Epsilon()) ArrayInitialize(spr,1); } else if(ListParam[0].Text=="Spread is higher than the selected level") { if(spread>spreadLevel+Epsilon()) ArrayInitialize(spr,1); } ArrayResize(Component[0].Value,Data.Bars); Component[0].CompName = "Spread"; Component[0].DataType = IndComponentType_IndicatorValue; Component[0].FirstBar = firstBar; ArrayInitialize(Component[0].Value,spread); if(SlotType==SlotTypes_OpenFilter) { ArrayResize(Component[1].Value,Data.Bars); Component[1].CompName = "Is long entry allowed"; Component[1].DataType = IndComponentType_AllowOpenLong; Component[1].FirstBar = firstBar; ArrayCopy(Component[1].Value,spr); ArrayResize(Component[2].Value,Data.Bars); Component[2].CompName = "Is short entry allowed"; Component[2].DataType = IndComponentType_AllowOpenShort; Component[2].FirstBar = firstBar; ArrayCopy(Component[2].Value,spr); } else if(SlotType==SlotTypes_CloseFilter) { ArrayResize(Component[1].Value,Data.Bars); Component[1].CompName = "Force close"; Component[1].DataType = IndComponentType_ForceClose; Component[1].FirstBar = firstBar; ArrayCopy(Component[1].Value,spr); } } //+------------------------------------------------------------------+
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 - 2024, Forex Software Ltd.;
Copyright © 2006 - 2024, Forex Software Ltd.;