How can i tell iBands to work with a different value?

 

I want to use the bollinger bands as normal, just with one exception:

For the newest, the current candle, the bollinger bands shouldnt move as the price changes. I want to set a certain value, and the bollinger bands should form as if this value is the price of the current candle. Is that possible?

so something like

double ValueForFirstCandle = 1.115;

//then here some code to form the normal bollinger bands (iBands)

//then here some code telling bollinger bands to use ValueForFirstCandle instead of the real price for the current candle for calculation

I want to program this in mql5.

Thank you!

 
KT313: I want to … Is that possible? …I want …

Yes, it's possible. You modify the BB code that way. So do it; we're not stopping you.

Show us your attempt (using the CODE button) and state the nature of your problem.
          No free help 2017.04.21

Or pay someone. Top of every page is the link Freelance.
          Hiring to write script - General - MQL5 programming forum 2018.05.12

 
@William Roeder , thanks for responding. The problem is that i do not know how i could do that, how i could replace the PRICE_CLOSE for only the first candle with that value
William Roeder
William Roeder
  • www.mql5.com
Trader's profile
 
KT313:
@William Roeder , thanks for responding. The problem is that i do not know how i could do that, how i could replace the PRICE_CLOSE for only the first candle with that value

PRICE_OPEN 

 
@Mohamad Zulhairi Baba , thanks for responding, but if i use PRICE_OPEN, it gets used for every candle, not just the first one. Furthermore, i want to use a custom value, not PRICE_OPEN
 
KT313:
@Mohamad Zulhairi Baba , thanks for responding, but if i use PRICE_OPEN, it gets used for every candle, not just the first one. Furthermore, i want to use a custom value, not PRICE_OPEN

what do you mean with just the first one?

daily first candle, monthly first candle, first candle of the all history? Or what?

 
KT313:
@Mohamad Zulhairi Baba , thanks for responding, but if i use PRICE_OPEN, it gets used for every candle, not just the first one. Furthermore, i want to use a custom value, not PRICE_OPEN
Why not? 
Code to return value of current candle [i] will be PRICE_OPEN.
PRICE_CLOSE for [i+1].

Don’t know the whole structure of your code, but you get the idea.
 
KT313:

I want to use the bollinger bands as normal, just with one exception:

For the newest, the current candle, the bollinger bands shouldnt move as the price changes. I want to set a certain value, and the bollinger bands should form as if this value is the price of the current candle. Is that possible?

so something like

double ValueForFirstCandle = 1.115;

//then here some code to form the normal bollinger bands (iBands)

//then here some code telling bollinger bands to use ValueForFirstCandle instead of the real price for the current candle for calculation

I want to program this in mql5.

Thank you!

I haven't seen your code so I don't know for sure how you are implementing it. Your first step is to copy the arrays from iBands() to your own arrays. Lets say that Upper[] is the array of upper values for the Bollinger Bands. Upper[0] is the most recent value, of the current bar which is still developing. You want to replace the value of Upper[0] with something else. Once you have done that you can create an indicator on the chart using your Upper[] array.

The same applies for the Lower[] end of the Bollinger Bands, and Middle[] for the middle values.

Reason: