philipp469: draws an arrow on the bar where the highest high occurred over the last X bars
Highbuffer[i] = iHighest(NULL,0,MODE_HIGH,lookback,i);
- RTFM. iHighest returns the INDEX of the high, and you put it (as a price) into your buffer.
Tryint iHH = iHighest(NULL,0,MODE_HIGH,lookback,i); Highbuffer[iHH] = High[iHH]; // + offset
if(counted > 0) counted--;
Unnecessary Contradictory information on IndicatorCounted() - MQL4 forum Get in the habit of counting down.for(int i = Bars - 1 - counted; i >= 0; i--)
Hi WHRoeder,
this has been very helpful - thank you. Of course, in the future I ll pay more attention to the manual.
I have changed Setindexstyle to arrow, however, it draws me an arrow on every bar on on the chart- i would like to change it to solely draw an arrow on the bar where the high[ihighest] or low[lowest] occured. Anyone any suggestions? once again, thanks for any help :-)
did you code HighBuffer[i] =
WHRoeder:
did you code HighBuffer[i] =
did you code HighBuffer[i] =
Yes, as instructed by you. I am adding the code again if it helps! Once again thanks for the help.
I only havent adjusted the counted bar error - I want to read on it and get it :)
#property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Red #property indicator_color2 DodgerBlue //input parameters extern int lookback = 5; extern int N =5; //Buffers double Highbuffer[]; double Lowbuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0,DRAW_ARROW); SetIndexStyle(1,DRAW_ARROW); SetIndexDrawBegin(0, N); SetIndexDrawBegin(1, N); SetIndexArrow(0,159); SetIndexArrow(1,159); SetIndexEmptyValue(0,0.0); SetIndexEmptyValue(1,0.0); //---- indicator buffers mapping SetIndexBuffer(0,Highbuffer); SetIndexBuffer(1,Lowbuffer); //---- name for DataWindow and indicator subwindow label IndicatorShortName("Swingpoints"); SetIndexLabel(0,"Swing_High"); SetIndexLabel(1,"Swing_Low"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ void start() { int counted = IndicatorCounted(); //---- if(counted < 0) return (-1); //---- if(counted > 0) counted--; int limit = Bars - counted; //---- for(int i = 0; i < limit; i++) { int IHH = iHighest(NULL,0,MODE_HIGH,lookback,i); Highbuffer[i] = High[IHH]; int ILL = iLowest(NULL,0,MODE_LOW,lookback,i); Lowbuffer[i] = Low[ILL]; } } //+------------------------------------------------------------------+
philipp469:
Reread my post. CLOSELY this time.
WHRoeder: did you code HighBuffer[i] =
Yes, as instructed by you.
thank you soo much! Worked :) Have a gr8 weekend!
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hi everyone,
I have attempted to code a little swing indicator, where the indicator draws an arrow on the bar where the highest high occurred over the last X bars and an arrow on the bar where the lowest low occured for X bars. But something must be wrong in my code, while the indicator loads in MT4, and the individual buffers show results - but not actual price, rather absolute numbers (See attached image) which seems to be a problem as well as I want to compare prices in between the highlighted bars, in addition no actual arrows are drawn :S I would be grateful it if someone could have a look and let me know where I have gone wrong.
I am developing this indicator to function as a supportive indicator to confirm direction and strength of direction as part of an EA I want to build :)
Below the code and attached the mq4 file. Once again, thank you soo much to anyone who can offer some thought!