1 CBot error- MarketSeriesname - pls help me 🤖

Created at 12 Feb 2024, 22:48
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
ainewsisrael's avatar

ainewsisrael

Joined 23.01.2024

1 CBot error- MarketSeriesname - pls help me 🤖
12 Feb 2024, 22:48


hey friends 🤖 , I have 1 error in my Cbot script

 

 


private MarketSeries _series;

        private RelativeStrengthIndex _rsi;



        protected override void OnStart()

        {

            _series = MarketData.GetSeries(Symbol, TimeFrame);


@ainewsisrael
Replies

PanagiotisCharalampous
13 Feb 2024, 07:20

Hi there,

Please provide the complete script.

Best regards,

Panagiotis


@PanagiotisCharalampous

ainewsisrael
13 Feb 2024, 07:59 ( Updated at: 13 Feb 2024, 14:40 )

RE: 1 CBot error- MarketSeriesname - pls help me 🤖

 

 

PanagiotisCharalampous said: 

Hi there,

Please provide the complete script.

Best regards,

Panagiotis

using System;
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 PnF_UT_RSI : Robot
 {
   [Parameter("Box Size", DefaultValue = 1)]
   public double BoxSize { get; set; }

   [Parameter("Reversal", DefaultValue = 3)]
   public int Reversal { get; set; }

   [Parameter("RSI Length", DefaultValue = 14)]
   public int RsiLength { get; set; }

   [Parameter("Overbought Level", DefaultValue = 70)]
   public double OverboughtLevel { get; set; }

   [Parameter("Oversold Level", DefaultValue = 30)]
   public double OversoldLevel { get; set; }

   private MarketSeries _series;
   private RelativeStrengthIndex _rsi;

    protected override void OnStart()
    {
        _series = MarketData.GetSeries(Symbol, TimeFrame);
        _rsi = Indicators.RelativeStrengthIndex(_series.Close, RsiLength);
    }

    // ... other methods ...

    private void CalculatePnF()
    {
        if (_series.Close.Count < 2)
            return;

        var boxSizeInPts = BoxSize * Symbol.PipSize;
        var priceUp = _series.Close.LastValue > _series.Close.Last(1) + boxSizeInPts;
        var priceDown = _series.Close.LastValue < _series.Close.Last(1) - boxSizeInPts;
        var isUp = priceUp ? _series.High.LastValue > 0 : false;
        var isDown = priceDown ? _series.Low.LastValue > 0 : false;

        if (isNewColumn(isUp, isDown))
        {
            Print("P&F Column High: " + _series.High.LastValue.ToString("0.00000"));
            Print("P&F Column Low: " + _series.Low.LastValue.ToString("0.00000"));
        }
    }

   private bool isNewColumn(bool isUp, bool isDown)
   {
     return (isUp && !isDown) || (isDown && !isUp);
   }

   private void CheckUTBotAlert()
   {
     var utLong = _rsi.Result.LastValue > OversoldLevel;
     var utShort = _rsi.Result.LastValue < OverboughtLevel;

     if (utLong)
       Print("UT Bot: RSI crossed above oversold level");
     if (utShort)
       Print("UT Bot: RSI crossed below overbought level");
   }
 }
}
 


@ainewsisrael