please convert mt4 sideways indicator to prt

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #226560 quote
    Patrick K TemplarPatrick K Templar
    Participant
    Average
    //---- parameters
    input int MA_Length  = 40;
    //---- buffers
    double GreenBuffer[];
    double RedBuffer[];
    double BufferMoment[];
    double BufferMomentLine[];
    //----
    int ExtCountedBars = 0;
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function                         |
    //|------------------------------------------------------------------|
    int init()
    {
    //---- indicators
    SetIndexStyle(0, DRAW_HISTOGRAM, 0, 1, Green);
    SetIndexBuffer(0, GreenBuffer);
    SetIndexStyle(1, DRAW_HISTOGRAM, 0, 1, Red);
    SetIndexBuffer(1, RedBuffer);
    SetIndexStyle(2, DRAW_LINE, 0, 1, RoyalBlue);
    SetIndexBuffer(2, BufferMoment);
    SetIndexStyle(3, DRAW_LINE, 0, 1, Yellow);
    SetIndexBuffer(3, BufferMomentLine);
    //---- initialization done
    return(INIT_SUCCEEDED);
    }
    //+------------------------------------------------------------------+
    //| Custom indicator iteration function                              |
    //+------------------------------------------------------------------+
    int OnCalculate(const int rates_total,
    const int prev_calculated,
    const datetime &time[],
    const double &open[],
    const double &high[],
    const double &low[],
    const double &close[],
    const long &tick_volume[],
    const long &volume[],
    const int &spread[])
    {
    if(Bars <= MA_Length)
    return(0);
    //---
    ExtCountedBars = IndicatorCounted();
    if(ExtCountedBars < 0)
    return(-1);
    if(ExtCountedBars > 0)
    ExtCountedBars--;
    //---
    int pos = Bars - ExtCountedBars - 1;
    if(ExtCountedBars == 0)
    pos -= MA_Length;
    //---
    while(pos >= 0)
    {
    double   BolUpper = iBands(NULL, 0, MA_Length, 2, 0, PRICE_CLOSE, MODE_UPPER, pos),
    BolLower = iBands(NULL, 0, MA_Length, 2, 0, PRICE_CLOSE, MODE_LOWER, pos),
    Moment = BolUpper - BolLower;
    //---
    BufferMoment[pos] = Moment;
    //---
    double MomentLine = 0;
    for(int i = MA_Length; i >= 1; i--)
    MomentLine += BufferMoment[pos + i];
    //---
    MomentLine = MomentLine / MA_Length;
    //---
    BufferMomentLine[pos] = MomentLine;
    //---
    if(Moment >= MomentLine)
    GreenBuffer[pos] = Moment;
    else
    if(Moment <= MomentLine)
    RedBuffer[pos] = Moment;
    //---
    pos--;
    }
    //----
    return (rates_total);

    thannk you

    aascreenshot.jpg aascreenshot.jpg
    #232183 quote
    Iván GonzálezIván González
    Moderator
    Legend
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

please convert mt4 sideways indicator to prt


ProBuilder: Indicators & Custom Tools

New Reply
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Iván GonzálezIván González
2 years, 4 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/18/2024
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...