It was a good first effort. Just use iHigh instead of High. High is the high array for the current chart.
Thank you for your help! It looks like its what I was looking for. But how would you exactly write that?
If I take iHigh by itself, I guess I'm not able to look in multiple bars, just 1 at a time. Or is there a possibility to use iHigh together with iHighest?
Thanks!
Thank you for your help! It looks like its what I was looking for. But how would you exactly write that?
If I take iHigh by itself, I guess I'm not able to look in multiple bars, just 1 at a time. Or is there a possibility to use iHigh together with iHighest?
Yeah, my problem is, High[] is a predifined variable. So I can insert in the [] brackets whatever i want, for example iHighest(). But iHigh() is a function. And obviously I can't use a function within a function. And so I have really no clue how to write that.
Or did you mean just use iHigh() in a loop and get the highest value? Well that would be easy, I just hoped that there was a prettier way to do so.
Sorry for annoying you, but I thought a forum exist to help people. If you don't want to help me, fine. But I guess you see, it takes more effort for me to write a question in the forum as just write the code. You see, if I would have known how to do, I would have done it.
But iHigh() is a function. And obviously I can't use a function within a function. And so I have really no clue how to write that.
GoingForGold:
Sorry for annoying you, but I thought a forum exist to help people.
high20 = High[iHighest(NULL,PERIOD_D1,MODE_HIGH,20,0)];iHighest returns the highest D1 bar. High[x] returns the high of the CHART bar. Oil and Water don't mix.
// Everything in D1 int iHigh20D1 = iHighest(NULL,PERIOD_D1,MODE_HIGH,20,0); // D1 chart index. double High20days = iHigh(NULL,PERIOD_D1, iHigh20D1); // Use index on D1 chart // or convert to chart datetime dayMinus20 = iTime(NULL,PERIOD_D1, 20); int iDayMinus20 = iBarShift(NULL,0, dayMinus20); // Chart bar. int iHigh20days = iHighest(NULL,0, MODE_HIGH, iDayMinus20+1, 0); double High20days = High[iHigh20days];

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello there!
I'm quite new to this language, but not new to programming at all. And I really like the language! :)
But now I got a problem...I hope you can help me!
What I expect from this snippet: I returns me the highest value of the stock during the last 20 days, regardless of the way the chart is displayed.
But: It works perfectly, when the chart is set to D1. Whenever I switch the periodicity (e.g. to H4), the value of "high20" switches too, I'd say to some random number. Not to a value which would make sense to me.
Any help is appreciated! Thanks! :)