Revisar e ajustar um Indicador MT5

Tâche terminée

Temps d'exécution 23 heures

Spécifications

Eu criei um indicador pelo ChatGPT e ele está compilando corretamente mas as linhas que são plotadas na janela separada do indicador MT5 não estão sendo atualizadas corretamente, elas aparecem como linhas retas horizontais e não tem nenhuma variação, e eu não sei programar e não sei como ajustar isso e o chatGPT também não conseguiu resolver.

O código é bem pequeno e básico, acredito ser simples de resolver para quem sabe programar.


Segue o código gerado pelo chatGPT:


//+------------------------------------------------------------------+

//| Custom indicator for MetaTrader 5                                |

//+------------------------------------------------------------------+

#property indicator_separate_window

#property indicator_buffers 3

#property indicator_plots   3

#property indicator_type1   DRAW_LINE

#property indicator_type2   DRAW_LINE

#property indicator_type3   DRAW_LINE

#property indicator_color1  DeepSkyBlue  // Amplitude

#property indicator_color2  Red          // Média da Amplitude

#property indicator_color3  Green        // Linha Limite


//--- input parameters

input int PeriodoAmplitude = 30;

input int PeriodoMediaAmplitude = 17;

input double LinhaLimite = 20.0;


//--- indicator buffers

double amplitudeBuffer[];

double mediaAmplitudeBuffer[];

double linhaLimiteBuffer[];


//+------------------------------------------------------------------+

//| Indicator initialization function                                |

//+------------------------------------------------------------------+

int OnInit()

{

    SetIndexBuffer(0, amplitudeBuffer);

    SetIndexBuffer(1, mediaAmplitudeBuffer);

    SetIndexBuffer(2, linhaLimiteBuffer);


    ArraySetAsSeries(amplitudeBuffer, true);

    ArraySetAsSeries(mediaAmplitudeBuffer, true);

    ArraySetAsSeries(linhaLimiteBuffer, true);


    PlotIndexSetString(0, PLOT_LABEL, "Amplitude");

    PlotIndexSetString(1, PLOT_LABEL, "Média da Amplitude");

    PlotIndexSetString(2, PLOT_LABEL, "Linha Limite");


    IndicatorSetString(INDICATOR_SHORTNAME, "Indicador Customizado de Amplitude");

    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[])

{

    int required = MathMax(PeriodoAmplitude, PeriodoMediaAmplitude);

    if (rates_total < required)

        return 0;


    for (int i = prev_calculated > required ? prev_calculated : required; i < rates_total; i++)

    {

        amplitudeBuffer[i] = high[iHighest(NULL, 0, MODE_HIGH, PeriodoAmplitude, i)] - low[iLowest(NULL, 0, MODE_LOW, PeriodoAmplitude, i)];

        mediaAmplitudeBuffer[i] = iMA(NULL, 0, PeriodoMediaAmplitude, 0, MODE_SMA, PRICE_CLOSE);

        linhaLimiteBuffer[i] = LinhaLimite;


        // Debugging information

        Print("Bar ", i, ": Amplitude = ", amplitudeBuffer[i], ", Media = ", mediaAmplitudeBuffer[i], ", LinhaLimite = ", linhaLimiteBuffer[i]);

    }


    return rates_total;

}



---------------------------------------------------------------------




Ele deveria ficar como na imagem anexo...




Répondu

1
Développeur 1
Évaluation
(23)
Projets
29
14%
Arbitrage
3
0% / 67%
En retard
3
10%
Travail
2
Développeur 2
Évaluation
(35)
Projets
60
22%
Arbitrage
3
33% / 33%
En retard
15
25%
Gratuit
3
Développeur 3
Évaluation
(845)
Projets
1447
72%
Arbitrage
119
29% / 47%
En retard
355
25%
Travail
Publié : 3 articles
Commandes similaires
I need to modify the CURRENCY indicator to allow viewing the same currency on different timeframes simultaneously, overlaid on the same chart. Insert the same currency multiple times into the indicator. Example: USD D1 USD H4 USD H1 USD M30 USD M15 USD M5 Display all these curves on the same chart, each representing the currency's slope on a different timeframe. Customizable settings for each line, including: Color

Informations sur le projet

Budget
34+ USD
Délais
à 1 jour(s)