Tweezer Tops and Bottoms by tho.schu
6812 downloads / 559 views / Created: 06.10.2020 Average Rating: 0
Indicator Description
2 candle formation. First candle down, second candle up. Both lows are at the same level.
Comments
//==============================================================
// Forex Strategy Builder
// Copyright � Miroslav Popov. All rights reserved.
//==============================================================
// THIS CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
//==============================================================
using System;
using System.Drawing;
using ForexStrategyBuilder.Infrastructure.Entities;
using ForexStrategyBuilder.Infrastructure.Enums;
using ForexStrategyBuilder.Infrastructure.Interfaces;
namespace ForexStrategyBuilder.Indicators.Store
{
public class TweezerTopsandBottoms : Indicator
{
///
/// Sets the default indicator parameters for the designated slot type
///
public TweezerTopsandBottoms()
{
// General properties
IndicatorName = "Tweezer Tops and Bottoms";
PossibleSlots = SlotTypes.OpenFilter ;
IndicatorAuthor = "Tho.Schu";
IndicatorVersion = "1.0";
IndicatorDescription = "Bundled in FSB distribution.";
}
public override void Initialize(SlotTypes slotType)
{
SlotType = slotType;
// The ComboBox parameters
IndParam.ListParam[0].Caption = "Logic";
IndParam.ListParam[0].ItemList = new string[] { "tweezer top or bottom" };
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.";
// 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;
}
///
/// Calculates the indicator's components
///
public override void Calculate(IDataSet dataSet)
{
DataSet = dataSet;
// Reading the parameters
int iFirstBar = 2;
double[] adUp = new double[Bars];
double[] adDn = new double[Bars];
for (int iBar = 2; iBar < Bars; iBar++)
{
// Long trade
if (Close[iBar - 2] < Open[iBar - 2] && // Candle 1 is Black
Close[iBar - 1] > Open[iBar - 1] && // Candle 2 is White
Low[iBar - 1] == Low[iBar - 2])
adUp[iBar] = 1;
// Short trade
if (Close[iBar - 2] > Open[iBar - 2] && // Candle 1 is White
Close[iBar - 1] < Open[iBar - 1] && // Candle 2 is Black
High[iBar - 1] == High[iBar - 2])
adDn[iBar] = 1;
}
// Saving the components
Component = new IndicatorComp[2];
Component[0] = new IndicatorComp();
Component[0].CompName = "Allow long entry";
Component[0].DataType = IndComponentType.AllowOpenLong;
Component[0].ChartType = IndChartType.NoChart;
Component[0].FirstBar = iFirstBar;
Component[0].Value = adUp;
Component[1] = new IndicatorComp();
Component[1].CompName = "Allow short entry";
Component[1].DataType = IndComponentType.AllowOpenShort;
Component[1].ChartType = IndChartType.NoChart;
Component[1].FirstBar = iFirstBar;
Component[1].Value = adDn;
// Sets the Component's Type
if (SlotType == SlotTypes.OpenFilter)
{Component[0].DataType = IndComponentType.AllowOpenLong;
Component[0].CompName = "Is long entry allowed";
Component[1].DataType = IndComponentType.AllowOpenShort;
Component[1].CompName = "Is short entry allowed";}
return;
}
///
/// Sets the indicator logic description
///
public override void SetDescription()
{
EntryFilterLongDescription = "Tweezer Tops and Bottoms";
EntryFilterShortDescription = "Tweezer Tops and Bottoms";
return;
}
///
/// Indicator to string
///
public override string ToString()
{
string sString = IndicatorName;
return sString;
}
}
}
//+--------------------------------------------------------------------+ //| 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 "1.00" #property strict #include <Forexsb.com/Indicator.mqh> #include <Forexsb.com/Enumerations.mqh> //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class TweezerTopsandBottoms : public Indicator { public: TweezerTopsandBottoms(SlotTypes slotType) { SlotType=slotType; IndicatorName="Tweezer Tops and Bottoms"; WarningMessage = ""; IsAllowLTF = true; ExecTime = ExecutionTime_DuringTheBar; IsSeparateChart = false; IsDiscreteValues = false; IsDeafultGroupAll = false; } virtual void Calculate(DataSet &dataSet); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void TweezerTopsandBottoms::Calculate(DataSet &dataSet) { Data=GetPointer(dataSet); int firstBar=2; // Calculation double adUp[]; ArrayResize(adUp,Data.Bars); ArrayInitialize(adUp,0); double adDn[]; ArrayResize(adDn,Data.Bars); ArrayInitialize(adUp,0); for(int bar=firstBar; bar<Data.Bars; bar++) { // Long trade if(Data.Close[bar-2]<Data.Open[bar-2] && // Data.Close[bar-1]>Data.Open[bar-1] && // Data.Low[bar-1]==Data.Low[bar-2]) adUp[bar]=1; // Short trade if(Data.Close[bar-2]>Data.Open[bar-2] && // Data.Close[bar-1]<Data.Open[bar-1] && // Data.High[bar-1]==Data.High[bar-2]) adDn[bar]=1; } // Saving the components ArrayResize(Component[0].Value,Data.Bars); Component[0].CompName = "Is long entry allowed"; Component[0].DataType = IndComponentType_AllowOpenLong; Component[0].FirstBar = firstBar; ArrayCopy(Component[0].Value,adUp); ArrayResize(Component[1].Value,Data.Bars); Component[1].CompName = "Is short entry allowed"; Component[1].DataType = IndComponentType_AllowOpenShort; Component[1].FirstBar = firstBar; ArrayCopy(Component[1].Value,adDn); } //+------------------------------------------------------------------+
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 - 2021, Forex Software Ltd.;
Copyright © 2006 - 2021, Forex Software Ltd.;