Is there a way to generate predictive MA values?

Created at 24 Jul 2020, 01:44
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!
RG

rgasch

Joined 14.12.2017

Is there a way to generate predictive MA values?
24 Jul 2020, 01:44


Would it be possible to generate theoretical/predictive MA values? I would like to be able to check the next/future MA value based on the prediction/possibility that the next bar is [insert next bar characteristics here]. 

I'm thinking that it should be possible to create a custom data array of data values and plug this into an MA function but I don't really see how to go about this. If you look at this piece of code as a sample 

_ma = Indicators.MovingAverage(Bars.ClosePrices, maPeriod, MAType);

then this suggests that it should be possible to create a custom/altered bars data array and pass this to the MovingAverage method but I'm not sure how to go about doing this. Could someone maybe suggest a few lines of code which demonstrate how to do this? 


@rgasch
Replies

rgasch
29 Jul 2020, 02:01

RE:

I've been playing around with this idea in the back of my head and have written a few lines of test code... I have these questions in case someone knows the answers (I should mention that I'm a quite experienced developer but this is my first time using C#, so I'm not familiar with the ecosystem, apologies if these are questions which would be completely obvious to someone with real C# experience): 

1) Does anybody know the arguments the "Bar" constructor will accept? It's not documented anywhere. I understand that it's probably only used internally but my guess is, it exists and can be used. 

2) Assuming #1 can be used/solved, how would I create a new instance of Bars with a leading/first element being the Bar created in #1. I've found that .Net 4.5 comes with an IEnumerable.prepend() method but my understanding is that CAlgo is not on 4.5 yet. 

Thank you in advance

 

rgasch said:

Would it be possible to generate theoretical/predictive MA values? I would like to be able to check the next/future MA value based on the prediction/possibility that the next bar is [insert next bar characteristics here]. 

I'm thinking that it should be possible to create a custom data array of data values and plug this into an MA function but I don't really see how to go about this. If you look at this piece of code as a sample 

_ma = Indicators.MovingAverage(Bars.ClosePrices, maPeriod, MAType);

then this suggests that it should be possible to create a custom/altered bars data array and pass this to the MovingAverage method but I'm not sure how to go about doing this. Could someone maybe suggest a few lines of code which demonstrate how to do this? 

 


@rgasch

PanagiotisCharalampous
31 Jul 2020, 08:20

Hi rgasch,

There is not constructor for Bars. You cannot generate new Bars objects.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous