Topics

Forum Topics not found

Replies

danieljclsilva
13 Oct 2020, 05:29

Hi,

I have the same issue. I can pass the objects to the class, but I still don´t know how to execute/place orders inside this new class.

// MycBot.cs
namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MycBot : Robot
    {
        [...]

        protected override void OnBar()
        {
            foreach (string GetSymbol in SymbolList)
            {
                var symbol = Symbols.GetSymbol(GetSymbol);
                var symbolBars = MarketData.GetBars(TimeFrame, symbol.Name);
                var _ATR = Indicators.AverageTrueRange(symbolBars, 14, MovingAverageType.Exponential);
                var _ATRSMA = Indicators.SimpleMovingAverage(_ATR.Result, 100);
                InsideBarBreakout InsideBarBreakout = new InsideBarBreakout(Server, symbol, symbolBars, _ATR, _ATRSMA, Label, PrmPercMotherBar);
                InsideBarBreakout.EntrySignal();
            }
        }
        [...]
    }
}

// IsideBarBreakout.cs
namespace cAlgo.Strategies
{
    class InsideBarBreakout
    {
        public IServer server;
        public Bars symbolBars;
        public Symbol symbol;
        public string Label;
        public bool InsideBar;
        public bool IDNR4Pattern;
        public bool LATRAboveSMA;
        public InsideBarBreakout(IServer Getserver, Symbol GetSymbol, Bars GetBars, AverageTrueRange ATR, SimpleMovingAverage ATRSMA, string GetLabel, double PrmPercMotherBar)
        {
            server = Getserver;
            symbol = GetSymbol;
            symbolBars = GetBars;
            Label = GetLabel;
            var PercMotherBar = PrmPercMotherBar;
            var _ATR = ATR;
            var _ATRSMA = ATRSMA;
            [...]
        }

        public void EntrySignal()
        {
            if (InsideBar && IDNR4Pattern && LATRAboveSMA)
            {
                [...]
                // CS0103  C# The name does not exist in the current context
                PlaceStopOrder(TradeType.Buy, symbol.Name, 1000, BuyPrice, Label, BuySL, null, server.Time.AddHours(22).AddMinutes(55));
                PlaceStopOrder(TradeType.Sell, symbol.Name, 1000, SellPrice, Label, SellSL, null, server.Time.AddHours(22).AddMinutes(55));
            }
        }
    }
}

Any suggestion?


@danieljclsilva