Replies

triccomane
11 Jan 2022, 11:35

RE:

amusleh said:

Hi,

Try this:

using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

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

        private RelativeStrengthIndex diffRSI;

        private IndicatorDataSeries nasdow;

        private Bars _nasdaqSeries, _dowjonesSeries;

        protected override void OnStart()
        {
            _nasdaqSeries = MarketData.GetBars(TimeFrame, "US TECH 100");
            _dowjonesSeries = MarketData.GetBars(TimeFrame, "US 30");

            nasdow = CreateDataSeries();

            diffRSI = Indicators.RelativeStrengthIndex(nasdow, Periods);
        }

        protected override void OnTick()
        {
            var index = Bars.Count - 1;

            var dowjonesSeriesIndex = _dowjonesSeries.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);
            var nasdaqSeriesIndex = _nasdaqSeries.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);

            nasdow[index] = _dowjonesSeries.ClosePrices[dowjonesSeriesIndex] - _nasdaqSeries.ClosePrices[nasdaqSeriesIndex];
        }
    }
}

The "nasdow" series contains the subtraction result of two other series, and you can use it on any indicators.

Thanks a lot to the both of you. You were very helpful.


@triccomane

triccomane
09 Jan 2022, 13:19

RE:

I made some progress. I succeeded in getting the two symbols on two different arrays, but I still cannot find a way to subtract each element of the first array to the second one

            for (int i = 0; i < Periods; i++)
            {
                double close_nasdaq = (MarketData.GetSeries(MarketData.GetSymbol("US TECH 100"), TimeFrame.Daily).Close.Last(i));
                Print("nasdaq close price: ", i, " ", close_nasdaq);
                double close_dowjones = (MarketData.GetSeries(MarketData.GetSymbol("US 30"), TimeFrame.Daily).Close.Last(i));
                Print("dowjones close price: ", i, " ", close_dowjones);

                double downas;
                downas[i] = close_dowjones[i] - close_nasdaq[i]; //I get an erorr on this line 

 


@triccomane

triccomane
08 Jan 2022, 20:37

If the VPS is located in France and the broker's servers are in France or near France, it should work well. But if the broker's servers are located far away from France, you might have a big ping that might not be suitable for scalping bots.


@triccomane

triccomane
07 Apr 2021, 17:55

RE:

amusleh said:

The server time is based on back test data time not current time of server.

The code inside if block will only run if the server time is equal to 9:01, and for that to work you have to use the tick data for back test not bar data.

thanks for answering. How do I do that I cannot find a way to get tick data instead of bar data. What I'm trying to do is to get the high of the 9:00 candle.


@triccomane