Page 1959 of 2169

Re: MT4 Indicator requests and ideas

Posted: Sat Nov 18, 2023 6:41 pm
by josi
kvak wrote: Sat Nov 18, 2023 8:47 am Here is mod for levels cross.
Interesting, thanks, kvak

Re: MT4 Indicator requests and ideas

Posted: Sat Nov 18, 2023 10:15 pm
by sal
hello experts
any one has zigzag cg line cross ray indicator. !!
someone posted earlier , unable to find.
see snap

Re: MT4 Indicator requests and ideas

Posted: Sun Nov 19, 2023 9:03 am
by Forexlearner
RodrigoRT7 wrote: Sat Nov 18, 2023 1:28 pm I already feared that, considering that I remember that someone once asked for a Half trend AVGs. I looked for more than 30 minutes (until now) and I didn't find any repaint in this version (until now)
i don't think a non repaint half trend version has ever existed

Re: MT4 Indicator requests and ideas

Posted: Sun Nov 19, 2023 2:48 pm
by mrtools
Forexlearner wrote: Sun Nov 19, 2023 9:03 am i don't think a non repaint half trend version has ever existed
No, there is one non-repaint version here

Re: MT4 Indicator requests and ideas

Posted: Sun Nov 19, 2023 8:20 pm
by simon_n3z
I tried to make a smoothed volume weighted two pole (no smoothing) RSX of Ehler's Center of Gravity. OpenAI keeps telling me this code is the one.

But it does not

2. paint in the subwindow nor display data in the data window
1. complile correctly. it keeps using input in the 2 pole calculation

Code: Select all

//+------------------------------------------------------------------+
//|                                               tpsvw_rsx-ecog.mq4 |
//|                                        Copyright 2023, simon_n3z |
//|                                    https://www.forex-station.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, simon_n3z"
#property link      "https://www.forex-station.com"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
#define MathPI 3.14159265358979323846

double TPSVM_RSX_ECG[];
double Trigger[];

extern int Length = 10;
extern int RSX_Period = 14; // RSX period for smoothing
extern double RSX_Alpha = 0.07; // RSX smoothing factor
int buffers = 0;
int drawBegin = 0;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init() {
    drawBegin = Length;
    initBuffer(TPSVM_RSX_ECG, "TPSVM_RSX_ECG", DRAW_LINE);
    initBuffer(Trigger, "Trigger", DRAW_LINE);
    IndicatorBuffers(buffers);
    IndicatorShortName("TPSVM_RSX_ECG [" + Length + "]");
    return (0);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start() {
    int counted_bars = IndicatorCounted();
    if (counted_bars < 0)
        return (-1);
    if (counted_bars > 0)
        counted_bars--;
    int limit = Bars - counted_bars;
    if (counted_bars == 0)
        limit -= 1 + Length;

    for (int s = limit; s >= 0; s--) {
        double Num = 0.0;
        double Denom = 0.0;
        for (int count = 0; count < Length; count++) {
            Num += (1.0 + count) * VolumeWeightedPrice(s + count);
            Denom += iVolume(NULL, 0, s + count);
        }
        double VWMA = (Denom != 0) ? Num / Denom : 0.0;

        double RSX = CalculateRSX(VWMA, RSX_Period, RSX_Alpha);

        double smoothedRSX = SmoothedTwoPoleRSX(RSX, Length);

        if (Denom != 0) {
            double COG = -smoothedRSX + (Length + 1.0) / 2.0;

            double smoothedCOG = SmoothedTwoPole(COG, Length);

            TPSVM_RSX_ECG[s] = smoothedCOG;
        } else {
            TPSVM_RSX_ECG[s] = 0;
        }
        Trigger[s] = TPSVM_RSX_ECG[s + 1];
    }
    return (0);
}

//+------------------------------------------------------------------+
//| Volume Weighted Price Calculation                                |
//+------------------------------------------------------------------+
double VolumeWeightedPrice(int index) {
    return ((High[index] + Low[index] + Close[index]) / 3.0) * iVolume(NULL, 0, index);
}

//+------------------------------------------------------------------+
//| RSX Calculation                                                  |
//+------------------------------------------------------------------+
double CalculateRSX(double price, int period, double alpha) {
    double rsxValue = 0.0;
    for (int i = 1; i < period; i++) {
        double delta = price - rsxValue;
        rsxValue += alpha * delta * delta;
    }
    return MathSqrt(rsxValue / period);
}

//+------------------------------------------------------------------+
//| RSX Smoothing                                                    |
//+------------------------------------------------------------------+
double SmoothedTwoPoleRSX(double rsxValue, int period) {
    double smoothingAlpha = 1 - MathCos(2 * MathPI / period);
    double smoothingAlpha1 = 1 - MathCos(2 * MathPI / (period / 2));

    double emaValue1 = rsxValue;
    double emaValue2 = rsxValue;

    for (int i = 1; i < period; i++) {
        emaValue1 = (1 - smoothingAlpha) * rsxValue + smoothingAlpha * emaValue1;
    }

    for (int i = 1; i < period / 2; i++) {
        emaValue2 = (1 - smoothingAlpha1) * emaValue1 + smoothingAlpha1 * emaValue2;
    }

    return emaValue2;
}

//+------------------------------------------------------------------+
//| Smoothing function (Two-Pole Smoother)                           |
//+------------------------------------------------------------------+
double SmoothedTwoPole(double input, int period) {
    double smoothingAlpha = 1 - MathCos(2 * MathPI / period);
    double smoothingAlpha1 = 1 - MathCos(2 * MathPI / (period / 2));

    double emaValue1 = input;
    double emaValue2 = input;

    for (int i = 1; i < period; i++) {
        emaValue1 = (1 - smoothingAlpha) * input + smoothingAlpha * emaValue1;
    }

    for (int i = 1; i < period / 2; i++) {
        emaValue2 = (1 - smoothingAlpha1) * emaValue1 + smoothingAlpha1 * emaValue2;
    }

    return emaValue2;
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void initBuffer(double& array[], string label = "", int type = DRAW_NONE, int arrow = 0, int style = EMPTY, int width = EMPTY, color clr = CLR_NONE) {
    SetIndexBuffer(buffers, array);
    SetIndexLabel(buffers, label);
    SetIndexEmptyValue(buffers, EMPTY_VALUE);
    SetIndexDrawBegin(buffers, drawBegin);
    SetIndexShift(buffers, 0);
    SetIndexStyle(buffers, type, style, width);
    SetIndexArrow(buffers, arrow);
    buffers++;
}
and finally i wanted it done in my way of the formula, im not sure what the ai did....

WHAT IS MY MAJOR MALFUNCTION ?

Plz help a brother out *nudge nudge *

Thank you in advance

-simon

Re: MT4 Indicator requests and ideas

Posted: Mon Nov 20, 2023 3:02 am
by mrtools
simon_n3z wrote: Sun Nov 19, 2023 8:20 pm I tried to make a smoothed volume weighted two pole (no smoothing) RSX of Ehler's Center of Gravity. OpenAI keeps telling me this code is the one.

But it does not

2. paint in the subwindow nor display data in the data window
1. complile correctly. it keeps using input in the 2 pole calculation

Code: Select all

//+------------------------------------------------------------------+
//|                                               tpsvw_rsx-ecog.mq4 |
//|                                        Copyright 2023, simon_n3z |
//|                                    https://www.forex-station.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, simon_n3z"
#property link      "https://www.forex-station.com"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
#define MathPI 3.14159265358979323846

double TPSVM_RSX_ECG[];
double Trigger[];

extern int Length = 10;
extern int RSX_Period = 14; // RSX period for smoothing
extern double RSX_Alpha = 0.07; // RSX smoothing factor
int buffers = 0;
int drawBegin = 0;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init() {
    drawBegin = Length;
    initBuffer(TPSVM_RSX_ECG, "TPSVM_RSX_ECG", DRAW_LINE);
    initBuffer(Trigger, "Trigger", DRAW_LINE);
    IndicatorBuffers(buffers);
    IndicatorShortName("TPSVM_RSX_ECG [" + Length + "]");
    return (0);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start() {
    int counted_bars = IndicatorCounted();
    if (counted_bars < 0)
        return (-1);
    if (counted_bars > 0)
        counted_bars--;
    int limit = Bars - counted_bars;
    if (counted_bars == 0)
        limit -= 1 + Length;

    for (int s = limit; s >= 0; s--) {
        double Num = 0.0;
        double Denom = 0.0;
        for (int count = 0; count < Length; count++) {
            Num += (1.0 + count) * VolumeWeightedPrice(s + count);
            Denom += iVolume(NULL, 0, s + count);
        }
        double VWMA = (Denom != 0) ? Num / Denom : 0.0;

        double RSX = CalculateRSX(VWMA, RSX_Period, RSX_Alpha);

        double smoothedRSX = SmoothedTwoPoleRSX(RSX, Length);

        if (Denom != 0) {
            double COG = -smoothedRSX + (Length + 1.0) / 2.0;

            double smoothedCOG = SmoothedTwoPole(COG, Length);

            TPSVM_RSX_ECG[s] = smoothedCOG;
        } else {
            TPSVM_RSX_ECG[s] = 0;
        }
        Trigger[s] = TPSVM_RSX_ECG[s + 1];
    }
    return (0);
}

//+------------------------------------------------------------------+
//| Volume Weighted Price Calculation                                |
//+------------------------------------------------------------------+
double VolumeWeightedPrice(int index) {
    return ((High[index] + Low[index] + Close[index]) / 3.0) * iVolume(NULL, 0, index);
}

//+------------------------------------------------------------------+
//| RSX Calculation                                                  |
//+------------------------------------------------------------------+
double CalculateRSX(double price, int period, double alpha) {
    double rsxValue = 0.0;
    for (int i = 1; i < period; i++) {
        double delta = price - rsxValue;
        rsxValue += alpha * delta * delta;
    }
    return MathSqrt(rsxValue / period);
}

//+------------------------------------------------------------------+
//| RSX Smoothing                                                    |
//+------------------------------------------------------------------+
double SmoothedTwoPoleRSX(double rsxValue, int period) {
    double smoothingAlpha = 1 - MathCos(2 * MathPI / period);
    double smoothingAlpha1 = 1 - MathCos(2 * MathPI / (period / 2));

    double emaValue1 = rsxValue;
    double emaValue2 = rsxValue;

    for (int i = 1; i < period; i++) {
        emaValue1 = (1 - smoothingAlpha) * rsxValue + smoothingAlpha * emaValue1;
    }

    for (int i = 1; i < period / 2; i++) {
        emaValue2 = (1 - smoothingAlpha1) * emaValue1 + smoothingAlpha1 * emaValue2;
    }

    return emaValue2;
}

//+------------------------------------------------------------------+
//| Smoothing function (Two-Pole Smoother)                           |
//+------------------------------------------------------------------+
double SmoothedTwoPole(double input, int period) {
    double smoothingAlpha = 1 - MathCos(2 * MathPI / period);
    double smoothingAlpha1 = 1 - MathCos(2 * MathPI / (period / 2));

    double emaValue1 = input;
    double emaValue2 = input;

    for (int i = 1; i < period; i++) {
        emaValue1 = (1 - smoothingAlpha) * input + smoothingAlpha * emaValue1;
    }

    for (int i = 1; i < period / 2; i++) {
        emaValue2 = (1 - smoothingAlpha1) * emaValue1 + smoothingAlpha1 * emaValue2;
    }

    return emaValue2;
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void initBuffer(double& array[], string label = "", int type = DRAW_NONE, int arrow = 0, int style = EMPTY, int width = EMPTY, color clr = CLR_NONE) {
    SetIndexBuffer(buffers, array);
    SetIndexLabel(buffers, label);
    SetIndexEmptyValue(buffers, EMPTY_VALUE);
    SetIndexDrawBegin(buffers, drawBegin);
    SetIndexShift(buffers, 0);
    SetIndexStyle(buffers, type, style, width);
    SetIndexArrow(buffers, arrow);
    buffers++;
}
and finally i wanted it done in my way of the formula, im not sure what the ai did....

WHAT IS MY MAJOR MALFUNCTION ?

Plz help a brother out *nudge nudge *

Thank you in advance

-simon
Can you explain the way you want it done, not understanding by looking at the ai code?

Re: MT4 Indicator requests and ideas

Posted: Mon Nov 20, 2023 9:41 am
by simon_n3z
mrtools wrote: Mon Nov 20, 2023 3:02 am Can you explain the way you want it done, not understanding by looking at the ai code?
just a 2 line smoothed volume weighted two pole (no smoothing) RSX of Ehler's Center of Gravity...what do you think Mr.Tools, where was my mistake in the code ?

Re: MT4 Indicator requests and ideas

Posted: Mon Nov 20, 2023 10:31 am
by mrtools
simon_n3z wrote: Mon Nov 20, 2023 9:41 am just a 2 line smoothed volume weighted two pole (no smoothing) RSX of Ehler's Center of Gravity...what do you think Mr.Tools, where was my mistake in the code ?
Never seen a volume weighted two pole ma, can possibly do a cog pre-smoothed with super smoother (think that would be the 2 pole) then make an rsx from that, but being rsx is already pretty smooth normally not sure how adding pre-smoothing to the cog would cause more lag.

Re: MT4 Indicator requests and ideas

Posted: Mon Nov 20, 2023 10:36 am
by simon_n3z
mrtools wrote: Mon Nov 20, 2023 10:31 am Never seen a volume weighted two pole ma, can possibly do a cog pre-smoothed with super smoother (think that would be the 2 pole) then make an rsx from that, but being rsx is already pretty smooth normally not sure how adding pre-smoothing to the cog would cause more lag.
sounds good, and dont forget the volume weighted part :P

Re: MT4 Indicator requests and ideas

Posted: Mon Nov 20, 2023 11:01 am
by mrtools
simon_n3z wrote: Mon Nov 20, 2023 10:36 am sounds good, and dont forget the volume weighted part :P
Sorry don't know how to do a volume weighted two pole ma.