simple coding question...
Results 1 to 4 of 34

Thread: simple coding question...

  1. #1
    Hello, sorry for this dumb question, but pls help me out here:

    If you've some indior which is composed of 1 line in the chart window, and now you would like to include standard deviation bands to that lineup, such as Bollinger bands. How do you do this:
    let's say your buffer that plots your initial indior is named abc
    so first you announce that these:
    extern int BandsPeriod=20;
    extern int BandsShift=0;
    extern dual BandsDeviations=2.0;
    1) you change
    #property indior_buffers 1 (1 becomes 3)
    two)
    SetIndexBuffer(0,abc);
    SetIndexStyle(0,DRAW_LINE);
    and include
    SetIndexBuffer(1,UpperBuffer);
    SetIndexStyle(1,DRAW_LINE);
    SetIndexBuffer(2,LowerBuffer);
    SetIndexStyle(2,DRAW_LINE);
    SetIndexDrawBegin(0,BandsPeriod BandsShift);
    SetIndexDrawBegin(1,BandsPeriod BandsShift);
    3) you include the rest of the bollinger bands code in the initialization loop
    int begin()
    {
    int I,k,counted_bars=IndiorCounted();
    double deviation,sum,oldval,newres;

    //--
    if(Barslt;=BandsPeriod) return(0);
    //-- initial zero
    if(counted_barslt;1)
    etc....
    4) but how the heck do you replace the buffer called MovingBuffer in the first bands.mq4 code from your new buffer from your indior, called abc?

    What is the best way to go about this?
    Should I try to get my indior code to the bands.mq4 code or another way around?

    I connected a well-known piece of code called bands.mq4 so that you can see what I am working with.

    Again, sorry for the coding-ignorance

    Perhaps somebody knows of a 'incorporating stdev circles tutorial' ? That would be exactly what I need. Thx

  2. #2
    Quote Originally Posted by ;
    Hello, sorry for the stupid question, but pls help me out here:

    If you have some indior that is composed of 1 line in the chart window, and you also want to add standard deviation rings to this lineup, like Bollinger bands. How do you do so:
    let us say your buffer that plots your initial indior is named abc
    so first you declare these:
    extern int BandsPeriod=20;
    extern int BandsShift=0;
    extern double BandsDeviations=2.0;
    1) you alter
    #property indior_buffers 1 (1 becomes 3)
    2)
    SetIndexBuffer(0,abc);
    SetIndexStyle(0,DRAW_LINE);
    and add
    SetIndexBuffer(1,UpperBuffer);
    SetIndexStyle(1,DRAW_LINE);
    SetIndexBuffer(2,LowerBuffer);
    SetIndexStyle(2,DRAW_LINE);
    SetIndexDrawBegin(0,BandsPeriod BandsShift);
    SetIndexDrawBegin(1,BandsPeriod BandsShift);
    3)...
    utilize the iBandsOnArray item:

    iBandsOnArray(array[],complete,period,deviation,bands_shift,mode,shift)

    array is the clearly your initial indior, simply put wedges from the entire part, period and deviations are evident, shift will most likely be zero, style is the place you select MODE_UPPER or MODE_LOWER depending on the band, and shift will be either 0 or I, your choice.

    Just do two of these, one for upper ring, one for lower ring.


    Update:
    Here is an example of the code:

    #property indior_separate_window
    #property indior_buffers 3
    #property indior_color1 Crimson
    #property indior_color2 White
    #property indior_color3 White

    //-- inputs

    extern int Stoch_Period = 5;
    extern int Bands_Period = 20;
    extern int Deviations = 2;

    //-- buffers

    double StochBuffer[];
    double UpperBuffer[];
    double LowerBuffer[];


    int init()

    //----------
    SetIndexStyle(0,DRAW_LINE);
    SetIndexBuffer(0,StochBuffer);
    //----------
    SetIndexStyle(1,DRAW_LINE);
    SetIndexBuffer(1,UpperBuffer);
    //----------
    SetIndexStyle(2,DRAW_LINE);
    SetIndexBuffer(2,LowerBuffer);

    IndiorShortName(Stoch-Bands example( Stoch_Period , Bands_Period , Deviations ));
    //----------
    return(0);




    int start()

    int limit;
    int counted_bars=IndiorCounted();
    //--
    if(counted_barsgt;0) counted_bars--;
    restrict=Bars-counted_bars;
    //--
    for(int I=0; ilt;limit; I )
    StochBuffer[I] = iStochastic(NULL,0,Stoch_Period,3,3,MODE_SMA,PRICE _CLOSE,0,I);
    //--
    for(I=0; ilt;limit; I )
    UpperBuffer[I] = iBandsOnArray(StochBuffer,Bars,Bands_Period,Deviat ions,0,MODE_UPPER,I);
    //--
    for(I=0; ilt;limit; I )
    LowerBuffer[I] = iBandsOnArray(StochBuffer,Bars,Bands_Period,Deviat ions,0,MODE_LOWER,I);
    //--
    return(0);

    // ------------------------------------------------------------------

  3. #3
    Quote Originally Posted by ;
    use the iBandsOnArray thing:

    iBandsOnArray(range[],complete,period,deviation,bands_shift,mode,shift)

    range is the obviously your original indior, simply put wedges from the total part, period and deviations are obvious, shift will likely be zero, mode is where you select MODE_UPPER or MODE_LOWER based on the band, and shift will be either I or 0, your own pick.

    Just do two of these, one for upper band, one for lesser band.
    That is the good manner, B, but the only matter - butbandsonarray - int
    iBandsOnArray (double array[], int total, int period, int deviation,
    so in the Event That You need dual - or stDev or iCustom - Bands - like HA it goes standard and it is dual

  4. #4
    Thanks guys, I'll get to work on this.

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.