Hi
I am creating a buffer of 20 elements to store profit for last 20 ticks .. want to calculate a weighted average from this buffer.
However my buffer variable ProfitBuffer[i] which is declared a global seems not to hold any value. Any ideas why ?
Cheers
This is an EA or Script so your buffer is not a buffer but an array, buffers are special arrays used in Indicators, is best to use the correct terminology so everyone knows what is being talked about
Did your OrderSelect() work ? why aren't you checking it's return value to determine if it worked or failed ? if it failed your OrderProfit() will be garbage . . .
This will help: What are Function return values ? How do I use them ?
Your array runs from index 0 to index 19 not from 1 to 20, you only select one order so you can't get an average from 20 entries . . .
RaptorUK:
This is an EA or Script so your buffer is not a buffer but an array, buffers are special arrays used in Indicators, is best to use the correct terminology so everyone knows what is being talked about
Did your OrderSelect() work ? why aren't you checking it's return value to determine if it worked or failed ? if it failed your OrderProfit() will be garbage . . .
This will help: What are Function return values ? How do I use them ?
Your array runs from index 0 to index 19 not from 1 to 20, you only select one order so you can't get an average from 20 entries . . .
>>>> Your array runs from index 0 to index 19 not from 1 to 20, you only select one order so you can't get an average from 20 entries . . .
is the right answer :) i was indexing out of array bounds ... thanks for tip about buffer / array terminoloy :) ..
I have a check for open orders before order select command which i didn include in this code snippet to make it simple ..

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
I am creating a buffer of 20 elements to store profit for last 20 ticks .. want to calculate a weighted average from this buffer.
However my buffer variable ProfitBuffer[i] which is declared a global seems not to hold any value. Any ideas why ?
Cheers