DonchianChannel Reversal+Volume
DonchianChannel Reversal+Volume
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class DonchianChannelBot : Robot
{
if (Trade.IsExecuting) return;
if (!tradeTime)
return;
// Check if the current price has reached the trailing stop trigger
level
if ((position.TradeType == TradeType.Buy &&
MarketSeries.High.LastValue >= triggerLevel) ||
(position.TradeType == TradeType.Sell &&
MarketSeries.Low.LastValue <= triggerLevel))
{
double newStopLevel = (position.TradeType == TradeType.Buy)
? MarketSeries.High.LastValue - TrailingStopSteps *
Symbol.PipSize
: MarketSeries.Low.LastValue + TrailingStopSteps *
Symbol.PipSize;
// Check if the current candle is the first bullish candle closing above the
Donchian Channel top
if (MarketSeries.High.Last(2) > donchianChannel.Top.Last(2) &&
MarketSeries.Close.Last(2) > MarketSeries.Open.Last(2) && isPreviousVolumeGreater||
MarketSeries.Close.Last(2) > donchianChannel.Top.Last(2) &&
MarketSeries.Close.Last(2) > MarketSeries.Open.Last(2) && isPreviousVolumeGreater)
{
// Add more debug prints for conditions
Print("Conditions met for entering a sell order...");