0% found this document useful (0 votes)
3 views

SupportResistanceWithSignals

This document describes a custom MT4 indicator for support and resistance levels with buy and sell signals. It includes properties for indicator buffers, colors, and initialization, as well as the main calculation function that determines support, resistance, and signals based on price data. The indicator visually represents these levels and signals on a separate window in the MT4 platform.

Uploaded by

ldoit2484
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

SupportResistanceWithSignals

This document describes a custom MT4 indicator for support and resistance levels with buy and sell signals. It includes properties for indicator buffers, colors, and initialization, as well as the main calculation function that determines support, resistance, and signals based on price data. The indicator visually represents these levels and signals on a separate window in the MT4 platform.

Uploaded by

ldoit2484
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Indicador Personalizado MT4: Suporte/Resistência com Sinais

#property indicator_separate_window

#property indicator_buffers 4

#property indicator_color1 Red

#property indicator_color2 Green

#property indicator_color3 Blue

#property indicator_color4 Orange

// Buffers

double ResistanceBuffer[];

double SupportBuffer[];

double BuySignalBuffer[];

double SellSignalBuffer[];

// Inputs

input int LookbackPeriod = 10; // Período para suporte/resistência

input color ResistanceColor = Red;

input color SupportColor = Green;

input color BuySignalColor = Blue;

input color SellSignalColor = Orange;

// Inicialização

int OnInit() {

SetIndexBuffer(0, ResistanceBuffer);

SetIndexBuffer(1, SupportBuffer);
SetIndexBuffer(2, BuySignalBuffer);

SetIndexBuffer(3, SellSignalBuffer);

SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2, ResistanceColor);

SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2, SupportColor);

SetIndexStyle(2, DRAW_ARROW, STYLE_SOLID, 1, BuySignalColor);

SetIndexArrow(2, 233); // Código do triângulo para compra

SetIndexStyle(3, DRAW_ARROW, STYLE_SOLID, 1, SellSignalColor);

SetIndexArrow(3, 234); // Código do triângulo para venda

IndicatorShortName("Suporte/Resistência com Sinais");

return(INIT_SUCCEEDED);

// Função principal

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

// Valida se há dados suficientes


if (rates_total < LookbackPeriod + 1) return 0;

// Loop para calcular suporte, resistência e sinais

for (int i = rates_total - 1; i >= 0; i--) {

// Suporte e Resistência

double highestHigh = High[iHighest(NULL, 0, MODE_HIGH, LookbackPeriod, i)];

double lowestLow = Low[iLowest(NULL, 0, MODE_LOW, LookbackPeriod, i)];

ResistanceBuffer[i] = highestHigh;

SupportBuffer[i] = lowestLow;

// Sinais de Compra e Venda

BuySignalBuffer[i] = EMPTY_VALUE;

SellSignalBuffer[i] = EMPTY_VALUE;

if (Close[i] > lowestLow) { // Condição de Compra

BuySignalBuffer[i] = Low[i] - Point * 5; // Coloca o sinal abaixo do candle

} else if (Close[i] < highestHigh) { // Condição de Venda

SellSignalBuffer[i] = High[i] + Point * 5; // Coloca o sinal acima do candle

return rates_total;

You might also like