Tristen Shaw #: I will give it a try. I will use the framework we built in this post and try to redo what I was initially attempting. Then I'll post back with what happens.
Thank you very much for taking the time to help out, it's nice to see there are a few experienced coders that will help a new person out without the need to make us feel like crap first.
One thing I've been looking at as far as this code is this part:
// Calculate bar counting variablesint// Adjust number of previously calculated bars accounting for incomplete current bar
nPrevCalc = prev_calculated > rates_total ? rates_total - 1
: ( prev_calculated > 1 ? prev_calculated - 1 : 0 ),
// Calculate how many bars need to be updated
nBarsUpdate = rates_total - nPrevCalc;
My understanding of prev_calculated is that it's value is equal to the last value of rates_total. So, in what situation would prev_calculated be greater than rates_total? It just seems that it would always be equal or less than.
First Cycle:
rates_total = Bars;
prev_calculated = 0;
Second Cycle:
rates_total = Bars;
prev_calculated = Bars;
Candle Close:
rates_total = Bars (+1 from last cycle);
prev_calculated = Bars;
Another thing I was toying with was calling the REX indicator at a different timeframe. However, obviously a different timeframe isn't going to have the same number of bars as the current timeframes rates_total.
Would there be a way to rewrite that code block so that nBarUpdates could be used to call a different timeframe?
Tristen Shaw #: So, in what situation would prev_calculated be greater than rates_total? It just seems that it would always be equal or less than.
There can be rare cases where that happens. Say a user reduced the number of bars for charts, or a broker reduced the number of available historical data. So, it's a precautionary measure.
Tristen Shaw #: Another thing I was toying with was calling the REX indicator at a different timeframe. However, obviously a different timeframe isn't going to have the same number of bars as the current timeframes rates_total. Would there be a way to rewrite that code block so that nBarUpdates could be used to call a different timeframe?
For a different time-frame, I would not recommend you store the copied data into a buffer, because obviously none of it will sync up with the other buffers.
It would have to be handled in a completely different way.
At your current level of coding, I would recommend you wait until your skill and knowledge has improved somewhat more.
Ok! Then, good coding! 👍
Ok! Then, good coding! 👍
Thank you very much for taking the time to help out, it's nice to see there are a few experienced coders that will help a new person out without the need to make us feel like crap first.
One thing I've been looking at as far as this code is this part:
My understanding of prev_calculated is that it's value is equal to the last value of rates_total. So, in what situation would prev_calculated be greater than rates_total? It just seems that it would always be equal or less than.
First Cycle:
rates_total = Bars;
prev_calculated = 0;
Second Cycle:
rates_total = Bars;
prev_calculated = Bars;
Candle Close:
rates_total = Bars (+1 from last cycle);
prev_calculated = Bars;
Another thing I was toying with was calling the REX indicator at a different timeframe. However, obviously a different timeframe isn't going to have the same number of bars as the current timeframes rates_total.
Would there be a way to rewrite that code block so that nBarUpdates could be used to call a different timeframe?
There can be rare cases where that happens. Say a user reduced the number of bars for charts, or a broker reduced the number of available historical data. So, it's a precautionary measure.
For a different time-frame, I would not recommend you store the copied data into a buffer, because obviously none of it will sync up with the other buffers.
It would have to be handled in a completely different way.
At your current level of coding, I would recommend you wait until your skill and knowledge has improved somewhat more.