Status
Open
Budget
50.00 USD
Payment Method
Direct Payment
Job Description
criar um cbot para o indicador seu mATRLevelStopReverse.algo
using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class mATRLevelStopReverse : Indicator
{
[Parameter("UseATRMode (yes)", DefaultValue = true)]
public bool inpUseATRMode { get; set; }
[Parameter("NonATRStopPips (40)",DefaultValue = 40)]
public int inpNonATRStopPips { get; set; }
[Parameter("ATRPeriod (9)", DefaultValue = 9)]
public int inpATRPeriod { get; set; }
[Parameter("ATRMultiplier (3.0)", DefaultValue = 3.0)]
public int inpATRMultiplier { get; set; }
[Parameter("ATRType (sma)", DefaultValue = MovingAverageType.Simple)]
public MovingAverageType inpATRType { get; set; }
[Parameter("ATRSmoothPeriod (1)", DefaultValue = 1)]
public int inpATRSmoothPeriod { get; set; }
[Parameter("ATRSmoothType (sma)", DefaultValue = MovingAverageType.WilderSmoothing)]
public MovingAverageType inpATRSmoothType { get; set; }
[Output("ATR Level Stop-Reverse", LineColor = "Magenta", PlotType = PlotType.DiscontinuousLine, LineStyle = LineStyle.Lines, Thickness = 1)]
public IndicatorDataSeries outLSR { get; set; }
[Output("OpenLong trigger", LineColor = "Green", PlotType = PlotType.Points, LineStyle = LineStyle.Dots, Thickness = 5)]
public IndicatorDataSeries outLongOpen { get; set; }
[Output("OpenShort trigger", LineColor = "Red", PlotType = PlotType.Points, LineStyle = LineStyle.Solid, Thickness = 5)]
public IndicatorDataSeries outShortOpen { get; set; }
private AverageTrueRange _atr;
private MovingAverage _atrma;
private IndicatorDataSeries _deltastop, _stoplevel, _arrowup, _arrowdown;
protected override void Initialize()
{
_atr = Indicators.AverageTrueRange(inpATRPeriod, inpATRType);
_atrma = Indicators.MovingAverage(_atr.Result, inpATRSmoothPeriod, inpATRSmoothType);
_deltastop = CreateDataSeries();
_stoplevel = CreateDataSeries();
_arrowup = CreateDataSeries();
_arrowdown = CreateDataSeries();
}
public override void Calculate(int i)
{
_deltastop[i] = inpUseATRMode == true
? Math.Round(_atrma.Result[i] * inpATRMultiplier, Symbol.Digits)
: Math.Round(inpNonATRStopPips * Symbol.PipSize, Symbol.Digits);
_stoplevel[i] = Bars.ClosePrices[i];
_arrowup[i] = double.NaN;
_arrowdown[i] = double.NaN;
if(i>1 && Bars.ClosePrices[i] == _stoplevel[i-1])
_stoplevel[i] = _stoplevel[i-1];
else
{
if(i>1 && Bars.ClosePrices[i-1] <= _stoplevel[i-1] && Bars.ClosePrices[i] < _stoplevel[i-1])
_stoplevel[i] = Math.Min(_stoplevel[i-1], (Bars.ClosePrices[i] + _deltastop[i]));
else
{
if(i>1 && Bars.ClosePrices[i-1] >= _stoplevel[i-1] && Bars.ClosePrices[i] > _stoplevel[i-1])
_stoplevel[i] = Math.Max(_stoplevel[i-1], (Bars.ClosePrices[i] - _deltastop[i]));
else
{
if(i>1 && Bars.ClosePrices[i] > _stoplevel[i-1])
{
_stoplevel[i] = Bars.ClosePrices[i] - _deltastop[i];
_arrowup[i] = Bars.LowPrices[i] - (5 * Symbol.PipSize);
}
else
{
_stoplevel[i] = Bars.ClosePrices[i] + _deltastop[i];
_arrowdown[i] = Bars.HighPrices[i] + (5 * Symbol.PipSize);
}
}
}
}
outLSR[i] = _stoplevel[i];
outLongOpen[i] = _arrowup[i];
outShortOpen[i] = _arrowdown[i];
}
}
}
Comments
Log in to add a comment.
VA
vanderlei-martinss
·
8 months ago
Mandei e-mail se quiser me passar telegram ou WhatsApp
Hi there,
We can help you with your project. Feel free to contact me at development@clickalgo.com
Best regards,
Panagiotis