Tobias Johannes Zimmer: So the question is how can I reference &open[] etc. through &dst_buffer[] without copying them again?
You can't, dst_buffer does not have values. Stop using it, and access the values directly. case PRICE_MEDIAN : for(int i = 0; i < ArraySize(high_buffer); i++) { dst_buffer[i] = (high_buffer[i] + low_buffer[i]) / 2; } break;
Okay thank you.
Edit: here you go:
//+---------------------------------------------------------------------------+ //| Function to get the applied price in a particular position of price buffer| //+---------------------------------------------------------------------------+ double GetPositionAppliedPrice(ENUM_APPLIED_PRICE PriceApplied, const double &open_buffer[], const double &high_buffer[], const double &low_buffer[], const double &close_buffer[], const int &pos) { double result = 0.0; switch(PriceApplied) { case PRICE_OPEN : result = (open_buffer[pos]); break; case PRICE_HIGH : result = (high_buffer[pos]); break; case PRICE_LOW : result = (low_buffer[pos]); break; case PRICE_CLOSE : result = (close_buffer[pos]); break; case PRICE_MEDIAN : result = ((high_buffer[pos] + low_buffer[pos]) / 2); break; case PRICE_TYPICAL : result = ((high_buffer[pos] + low_buffer[pos] + close_buffer[pos]) / 3); break; case PRICE_WEIGHTED : result = ((high_buffer[pos] + low_buffer[pos] + (close_buffer[pos] * 2)) / 4); break; } return(result); } //+------------------------------------------------------------------+

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello everybody, I was working with MovingAverages.mqh when I saw that I also wanted a function to get the applied price. With the median, typical and weighted it seemed within good measure to store the results in a &dst_buffer[]. But it bothered me to do it with open, high, low and close because it seemed redundant to copy them (which ArrayInsert does). Why should I insert them when they are already existing. So the question is how can I reference &open[] etc. through &dst_buffer[] without copying them again?