Description
- ストキャスティクスのクロスを検知してチャート上に矢印を表示します。
- ストキャスティクスのパラメータは任意に設定できます。
- Detects stochastic crosses and displays an arrow on the chart.
- The stochastic parameters can be set as desired.
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class StochasticEntryMarker : Indicator
{
[Parameter("K Periods", DefaultValue = 5)]
public int kPeriods { get; set; }
[Parameter("K Slowing", DefaultValue = 3)]
public int kSlowing { get; set; }
[Parameter("D Periods", DefaultValue = 3)]
public int dPeriods { get; set; }
[Parameter("UP Level", DefaultValue = 70)]
public int Up_Level { get; set; }
[Parameter("Down Level", DefaultValue = 30)]
public int Down_Level { get; set; }
[Parameter("MA Type", DefaultValue = MovingAverageType.Simple)]
public MovingAverageType maType { get; set; }
private StochasticOscillator _stochastic;
private double offset = 1;
protected override void Initialize()
{
// Initialize and create nested indicators
_stochastic = Indicators.StochasticOscillator(kPeriods, kSlowing, dPeriods, maType);
}
public override void Calculate(int index)
{
// Calculate value at specified index
// Result[index] = ...
var bars = MarketData.GetBars(Chart.TimeFrame);
//dedcloss
if (_stochastic.PercentK.Last(2) > _stochastic.PercentD.Last(2) && _stochastic.PercentK.Last(1) < _stochastic.PercentD.Last(1))
{
Print("_stochastic.PercentD.Last(1) {0}", _stochastic.PercentD.Last(1));
Print("_stochastic.PercentD.Last(2) {0}", _stochastic.PercentD.Last(2));
if (_stochastic.PercentK.Last(2) > Up_Level)
{
Chart.DrawIcon("test" + bars.OpenTimes.Last(1).ToString(), ChartIconType.DownArrow, bars.OpenTimes.Last(1), bars.HighPrices.Last(1) + (offset * Symbol.PipSize), "Red");
}
}
//goldencloss
if (_stochastic.PercentK.Last(2) < _stochastic.PercentD.Last(2) && _stochastic.PercentK.Last(1) > _stochastic.PercentD.Last(1))
{
Print("_stochastic.PercentD.Last(1) {0}", _stochastic.PercentD.Last(1));
Print("_stochastic.PercentD.Last(2) {0}", _stochastic.PercentD.Last(2));
if (_stochastic.PercentK.Last(2) < Down_Level)
{
Chart.DrawIcon("test" + bars.OpenTimes.Last(1).ToString(), ChartIconType.UpArrow, bars.OpenTimes.Last(1), bars.LowPrices.Last(1) - (offset * Symbol.PipSize), "Yellow");
}
}
}
}
}
summer
Joined on 10.08.2020
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: StochasticEntryMarker.algo
- Rating: 5
- Installs: 3286
- Modified: 13/10/2021 09:55
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
No comments found.