HI Hedge, can u help me please wih this code on MC.
Can't solve :-( MC plot arrow sometimes and in wrong mode, I think thi code that I wrote have logical defeat.
Thanks
inputs:
StartTime(1500), // Orario di inizio sessione
EndTime(2200), // Orario di fine sessione
ShortEMAPeriod(5), // Periodo dell'EMA corta
LongEMAPeriod(50), // Periodo dell'EMA lunga
MinEMADiff(40), // Differenza minima tra le EMA
SignalSize(1), // Dimensione del segnale
ShortEMAColor(Blue), // Colore dell'EMA corta
LongEMAColor(Red), // Colore dell'EMA lunga
ShortEMALineWidth(1), // Spessore linea EMA corta
LongEMALineWidth(1); // Spessore linea EMA lunga
// Calcolo delle EMA
EMAShort = XAverage(Close, ShortEMAPeriod);
EMALong = XAverage(Close, LongEMAPeriod);
EMADiff = absvalue(EMAShort - EMALong);
// Inizializzazione dei valori di plot
plotLong = false;
plotShort = false;
// Verifica se l'orario ? all'interno della sessione
if (Time >= StartTime and Time EMALong and Close[1] EMALong and EMAShort[1] MinEMADiff) then begin
plotLong = true;
end;
// Verifica delle condizioni di ingresso con filtro per short
if (Close = EMALong[1] and
EMAShort = EMALong[1] and
EMADiff > MinEMADiff) then begin
plotShort = true;
end;
// Disegna le frecce sul grafico per long
if (plotLong) then begin
arrowIDLong = Arw_New(Date, Time, Low, True);
Arw_SetColor(arrowIDLong, Green);
Arw_SetSize(arrowIDLong, SignalSize);
end;
// Disegna le frecce sul grafico per short
if (plotShort) then begin
arrowIDShort = Arw_New(Date, Time, High, False);
Arw_SetColor(arrowIDShort, Red);
Arw_SetSize(arrowIDShort, SignalSize);
end;
end;
// Plot delle EMA con colori e spessori configurabili
Plot1(EMAShort, "ShortEMA", ShortEMAColor, Default, ShortEMALineWidth);
Plot2(EMALong, "LongEMA", LongEMAColor, Default, LongEMALineWidth);