Polynomial regression bot is not working properly

Created at 26 Feb 2021, 02:37
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!
R.

r.stipriaan

Joined 05.02.2021

Polynomial regression bot is not working properly
26 Feb 2021, 02:37


 

Hi coders,

I am working on applying the polynomial regression indicator in a bot. unfortunately the data the bot reads is incorrect. so, I gave the order to print the prices in the log, but they do not match the indicator at all. 

I also made an order to take a sell position when the result is lower than 1 period ago with a tp / sl of 2 pips. this clearly shows that the bot is currently taking almost random positions.

does anyone know how this is possible?

 

thanks in advance!

Robin


using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.WEuropeStandardTime, AccessRights = AccessRights.None)]
    public class b : Robot
    {
        [Parameter("Stop Loss", DefaultValue = 2)]
        public int StopLoss { get; set; }

        [Parameter("Take Profit", DefaultValue = 2)]
        public int TakeProfit { get; set; }


        private PolynomialRegressionChannels prc;


        protected override void OnStart()
        {

            prc = Indicators.PolynomialRegressionChannels(3, 120, 1.62, 2);


        }

        protected override void OnBar()
        {


            Print("PRC high =  ", prc.Sqh.LastValue);
            Print("PRC low =  ", prc.Sql.LastValue);



            if (prc.Sqh.LastValue < prc.Sqh.Last(1))
            {
                ExecuteMarketOrder(TradeType.Sell, SymbolName, 15000, "Short", StopLoss, TakeProfit);
            }


        }

    }
}

 


@r.stipriaan
Replies

PanagiotisCharalampous
26 Feb 2021, 08:09

Hi r.stipriaan,

unfortunately the data the bot reads is incorrect

Can you please provide some evidence for this so that we can reproduce this situation as well?

Best Regards,

Panagiotis 

Join us on Telegram 


 


@PanagiotisCharalampous

r.stipriaan
13 Mar 2021, 17:33 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi r.stipriaan,

unfortunately the data the bot reads is incorrect

Can you please provide some evidence for this so that we can reproduce this situation as well?

Best Regards,

Panagiotis 

Join us on Telegram 


 


Hi PanagiotisCharalampous!

 

First of all, my apologies for being late reacting, was a bit busy lately and I didn't quite know how to explain this situation.

To give a clear picture of what exactly happened I printed all the prices in the log of the high and the low and tagged them exactly in the chart of the eur usd 1d. (see picture).

As we can see, the prices indicated by the indicator do not correspond at all to what is shown in the chart. We see 2 different channels.

I also added an order to only take a sell position when price is falling (see red and green dots on the bars). From this we can see that they do not correspond to one of the 2 channels.

Then did some research on the bot itself but this one is still too hard to read for me, if you want to see this one: https://ctrader.com/algos/indicators/show/71

(not sure if this ecxact is the same indicator as the built-in one. As far as visible everything is the same).

Thank you very much in advance. I am very curious how this can be explained and resolved!

 

Robin

Chart polynomial channels


@r.stipriaan

PanagiotisCharalampous
16 Mar 2021, 08:32

Hi r.stipriaan,

Are you aware that the Polynomial Regression Channels is a redrawing indicator and its values change over time?

Best Regards,

Panagiotis 

Join us on Telegram 


@PanagiotisCharalampous