Histogram Indior Question
Page 1 of 502 12 LastLast
Results 1 to 10 of 15

Thread: Histogram Indior Question

  1. #1
    Hello,
    Could someone please help me by posting the complete minimum code required to plot a value for a histogram? (The value I'm working with is your pip difference between Pair1 and Pair2 for instance)

    I have been messing about with it by stealing bits from here and there, but from the bits I have copied from other indiors I can not work out how to specify a 0 point for the histogram bars to originate from, nor the amount of pubs back to be calculated. I would like to get a range /- .

    Thanks very much.
    John

  2. #2
    Hi John,

    Hope that this gets you one step closer. Instead of anything it plots the job of the near as a proportion of this candle height.

    Range of the indior subwindow is set by:
    #property indior_minimum -10
    #property indior_maximum 110

    Levels (dotted lines, optional) plotted by:
    #property indior_level1 100
    #property indior_level2 0

    Amount of histogram bars is set by the loop:
    for(int I=0; ilt;Bars; I ) {
    0 = rightmost (latest) pub on chart
    Bars = predefined variable giving number of bars chart

    David

    Inserted Code // ------------------------------------------------------------------ //| Histogram sample.mq4 | // ------------------------------------------------------------------ #property indior_separate_window #property indior_minimum -10 #property indior_maximum 110 #property indior_level1 100 #property indior_level2 0 #property indior_buffers 1 dual HistBuffer#91;#93;; //p------------------------------------------------------------------ int init() //p------------------------------------------------------------------ SetIndexBuffer(0, HistBuffer); SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 3, Red); IndiorDigits(0); return(0); // ------------------------------------------------------------------ int deinit() // ------------------------------------------------------------------ return(0); // ------------------------------------------------------------------ int begin() // ------------------------------------------------------------------ for(int I=0; ilt;Bars; I ) if (Top#91;I#93;-Low#91;I#93; gt; 0) HistBuffer#91;I#93; = 100 * (Close#91;I#93;-Low#91;I#93;-RRB- / (Top#91;I#93;-Low#91;I#93;-RRB-; return(0);

  3. #3
    Hi David,
    Thanks very much! This will surely help me in my way.

    All of the best,
    John

  4. #4
    Ok got something working. There are some issues however.

    First, allow me to explain what I am attempting to do. I want to compare the pip differential between Pair1 and Pair2 (in this instance EURUSD and GBPUSD). I am using the day's opening price since the zero point.

    So, we consider the open price of 1.6120 and subtract the current price of 1.6100 and we see that price has proceeded down 20 pips at the moment. Do the exact same for another pair and think of a 40 pip move (for instance).

    So say we have GBPUSD=-LRB--20) and EURUSD=-LRB--40). We can see that both pairs are going down from the open, and that EUR is forward in the movement by 20 pips.

    What I am attempting to do is make a wonderful small histogram that shows me this gap. The code below (that was cut and glued by me by an indior Swingman composed, and the piece from above) does pretty much exactly what I want. At the moment it's just displaying the price from around the histogram (for one pair), and this brings me to problem number1.

    Issue #1) Right now the indior is drawing tick by tick. Which is excellent, but if you load it onto a new chart you have to wait hours/minutes/days in order to have it populate with data. Is there a way to call the previous tick(I suppose thats the exact same thing as the near huh?) And replie all bars other than the current bar? Is there a better call than MarketInfo Mode_Bid to calculate this with?

    Issue #2) That is more advanced, but would it be possible to indie a blip at the top/bottom of this histogram to signify high/low, like on a stereo equalizer, because the histo bars might hit a high/low then receede before closing?

    Issue #3) Right now I am manually entering a beginning date. What would be the code to have the indior automatically start on the 1M candle's open?

    My thought could be dumb, but I'd like to play it out to the end anyway. I am hoping to use this indior to visualise the range of the pip gap between connected pairs. My thinking is, if it's possible to get a sense of the range of the correlation on a daily basis, then you can enter a trade when your at the widest part, and commerce back towards the center.

    If anyone has ideas about some of the above points I am all ears. This is something I would like to write myself but your help to steer me in the ideal directiong would be appreciated.
    Thanks
    John

    Inserted Code // ------------------------------------------------------------------ //| Histogram sample.mq4 | // ------------------------------------------------------------------ #property indior_separate_window #property indior_minimum -100 #property indior_maximum 150 #property indior_level1 100 #property indior_level2 -150 #property indior_buffers 1 dual HistBuffer#91;#93;; extern string Pair1 = GBPUSD; extern string Pair2 = EURUSD; extern int StartDate = D'2009.7.8 00:00'; extern string StartingTimeCorr = 2009.07.08 00:00; extern int TFperiod = 60; extern int moreBars = 0; dual ExtMapBuffer1#91;#93;; dual ExtMapBuffer2#91;#93;; dual dPoint; int iWindow; int firstBar; int _BarsCount, _LastBar; int init() SetIndexBuffer(0, HistBuffer); SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 3, Red); IndiorDigits(4); return(0); // ------------------------------------------------------------------ int deinit() return(0); // ------------------------------------------------------------------ int start() dual Price_1=MarketInfo(Pair1,MODE_ASK); dual Open_Pair1 = iOpen(Pair1, PERIOD_M1, iBarShift(NULL, PERIOD_M1, StartDate, True)); firstBar = iBarShift(NULL,TFperiod,StrToTime(StartingTimeCorr ),true); should (firstBar lt;0 ) Alert(StartingTimeCorr seems to be incorrect.) ; return (0); RefreshRates(); ArrayInitialize( ExtMapBuffer1, 0.0 ); ArrayInitialize( ExtMapBuffer2, 0.0 ); _BarsCount = WindowBarsPerChart() moreBars 1; int _FirstBar = firstBar; int _LastBar = _FirstBar - _BarsCount moreBars 1 ; should ( _LastBar lt; 0 ) _LastBar = 0; _BarsCount = _FirstBar moreBars 1 ; int I=0; //ilt;Bars; I ) //should (Top#91;I#93;-Low#91;I#93; gt; 0) HistBuffer#91;I#93; = (((Price_1)-(Open_Pair1))*10000); return(0);

  5. #5
    Ok. Got it more or less working.

    Oddly; I receive different results when it's on different charts, though both charts should be calling the identical details.
    Any ideas?

    Inserted Code // ------------------------------------------------------------------ //| JM_Pip Differential v1.006. Mq4 | // ------------------------------------------------------------------ #property indior_separate_window #property indior_minimum -200 #property indior_maximum 200 #property indior_level1 100 #property indior_level2 -100 #property indior_level3 -50 #property indior_level4 50 #property indior_level5 0 #property indior_buffers 1 //-- enter parameters extern colour FontColor=Red; extern int FontSize=18; extern string FontType=Arial Black; extern string Pair1 = GBPUSD; extern string Pair2 = EURUSD; extern int StartDate = D'2009.7.8 00:00'; extern string StartingTimeCorr = 2009.07.08 00:00; extern int TFperiod = 60; extern int moreBars = 0; extern double Range = 200; //-- variables int iWindow; int firstBar; int _BarsCount, _LastBar; double HistBuffer#91;#93;; double ExtMapBuffer1#91;#93;; double ExtMapBuffer2#91;#93;; double dPoint; // ------------------------------------------------------------------ //| Custom indior initialization function | // ------------------------------------------------------------------ int init() SetIndexBuffer(0, HistBuffer); SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 3, Red); IndiorDigits(0); return(0); // ------------------------------------------------------------------ //| Custom indior deinitialization function | // ------------------------------------------------------------------ int deinit() ObjectDelete(Pip_Diff_Label); ObjectDelete(Buy_Sell_Label); return(0); // ------------------------------------------------------------------ int start() double Price_1=MarketInfo(Pair1,MODE_ASK); double Price_2=MarketInfo(Pair2,MODE_ASK); double Open_Pair1 = iOpen(Pair1, PERIOD_M1, iBarShift(NULL, PERIOD_M1, StartDate, True)); double Open_Pair2 = iOpen(Pair2, PERIOD_M1, iBarShift(NULL, PERIOD_M1, StartDate, True)); double Variance1 = ((Price_1-Open_Pair1)*10000); double Variance2 = ((Price_2-Open_Pair2)*10000); double paned = Variance1-Variance2; int Output1 = Variance1; int Output2 = Variance2; firstBar = iBarShift(NULL,TFperiod,StrToTime(StartingTimeCorr ),true); should (firstBar lt;0 ) Alert(StartingTimeCorr seems to be wrong.) ; return (0); RefreshRates(); ArrayInitialize( ExtMapBuffer1, 0.0 ); ArrayInitialize( ExtMapBuffer2, 0.0 ); _BarsCount = WindowBarsPerChart() moreBars 1; int _FirstBar = firstBar; int _LastBar = _FirstBar - _BarsCount moreBars 1 ; should ( _LastBar lt; 0 ) _LastBar = 0; _BarsCount = _FirstBar moreBars 1 ; int I=0; //ilt;Bars; I ) //Add bold number to histogram window string Pip_Diff = DoubleToStr(Differential,0); ObjectCreate(Pip_Diff_Label, OBJ_LABEL, 1, 0, 0); ObjectSetText(Pip_Diff_Label,Pip_Diff, FontSize, FontType, FontColor); ObjectSet(Pip_Diff_Label, OBJPROP_CORNER, 1); ObjectSet(Pip_Diff_Label, OBJPROP_XDISTANCE, 1); ObjectSet(Pip_Diff_Label, OBJPROP_YDISTANCE, 1); HistBuffer#91;I#93; = Differential; IndiorShortName(Differential Pair2 =-LRB- Output2 ) Pair1 =-LRB- Output1 )); return(0);

  6. #6
    Quote Originally Posted by ;
    Oddly; I receive different results when it is on different charts, though both charts should be calling the same information.
    Any thoughts?
    IBarShift(NULL,...) will return the candle number of this pair on which the chart is attached. Perhaps iBarShift(Pair1,...) etc will work better?

    Sorry, I haven't the opportunity to walk thru your code in detail, which I am merely guessing.

  7. #7

  8. #8
    Could somebody please provide me a idea exactly to material data?

    I've been thru the MT4 assistance but it's too mysterious for me in this respect.

    Basically I've 20 values I wish to average. I am using some other math to make these values so I can't just use [close price, interval 20] for instance.

    Therefore for each bar I'm creating a few. Do some math that is other to it and I would like to average out the last 20 bars value of the number.

    I am imagining an array is the means to do it, but I am lost as to where to start.

    Any pointers would be greatly valued.
    Due
    John

  9. #9
    Double myarray[20];


    myarray[0] = value1; // initial value

    myarray[1] = value2; // second worth

    .
    .
    .

    Myarray[19] = value20; // 20th worth


    averageval = 0 ;

    for(int I=0;ilt;20;I )

    averageval = averageval myarray[I] ;


    averageval = averageval / 20 ;

  10. #10
    Hi Evan,
    Thanks very much for that.

    Could you assist with a succinct explanation of what I does for me and what it's doing in the above code?

    I understand it's adding 1 to itself and so forth, but I am a little fuzzy with that.

    Due
    John

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners more information