Disliked{quote} Here you go. I updated the source code too: https://github.com/jblanked/MQL-Libr...A-Candle-Setup {file} {file}Ignored
1
I will code your pivot EAs for no charge 28 replies
I will code your scalping EAs for no charge 163 replies
Oanda MT4 - Indicators and EAs not showing 2 replies
EAs and indicators relating to moutaki... 22 replies
InterbankFX has loaded its MT4 platform with custom EAs, indicators and scripts 1 reply
Disliked{quote} Here you go. I updated the source code too: https://github.com/jblanked/MQL-Libr...A-Candle-Setup {file} {file}Ignored
int OnCalculate(const int rates_total,
const int prev_calculated,
const int begin,
const double &price[])
{
//---
if(prev_calculated<0 || IsStopped())
return(-1);
//---
int limit = rates_total - prev_calculated;
//--- initial zero
if(prev_calculated < 1)
{
ArrayInitialize(Histogram, EMPTY_VALUE);
ArrayInitialize(MACD_Main, EMPTY_VALUE);
ArrayInitialize(MACD_Signal, EMPTY_VALUE);
}
else
limit = MathMax(limit + 1, 1);
//---
const int toCopy=rates_total!=prev_calculated?rates_total-prev_calculated:1;
//---
if(BarsCalculated(MACD_handle) <= 0)
return(0);
if(CopyBuffer(MACD_handle, MAIN_LINE, 0, toCopy, MACD_Main) != toCopy)
return(0);
//---
if(BarsCalculated(MACD_handle) <= 0)
return(0);
if(CopyBuffer(MACD_handle, SIGNAL_LINE, 0, toCopy, MACD_Signal) != toCopy)
return(0);
//---
//---
if(BarsCalculated(MACD_handle) <= 0)
return(0);
if(CopyBuffer(MACD_handle, MAIN_LINE, 0, toCopy, Histogram) != toCopy)
return(0);
//---
for(int i = limit - 1; i >= 0 && !_StopFlag; i--)
{
//---Set Histogram Color
if(i < rates_total - 1)
{
if(Histogram[i] > 0 || Histogram[i+1] > 0)
{
if(Histogram[i] > 0 && Histogram[i+1] < 0)
HistogramColors[i] = 0;
else
HistogramColors[i+1] = (Histogram[i] > Histogram[i+1]) ? 0 : 1;
}
if(Histogram[i] < 0 || Histogram[i+1] < 0)
{
if(Histogram[i] < 0 && Histogram[i+1] > 0)
HistogramColors[i] = 2;
else
HistogramColors[i+1] = (Histogram[i] < Histogram[i+1]) ? 2 : 3;
}
}
}
return(rates_total);
} DislikedHello, I'd appreciate it if someone could help fix this (MQL5) code bug. I've spent significant time on this code, even working through the entire weekend. It seemed to work correctly with Bitcoin, but today it broke with GBP. I have another version that uses 6 buffers and works flawlessly without issues. However, my MetaTrader 5 platform has been freezing lately, preventing me from seeing price movements. I had to remove some tools to mitigate this. To optimize the code, I tried replacing the 4 histogram buffers with DRAW_COLOR_HISTOGRAM using...Ignored
//--- initial zero
if (prev_calculated < 1)
{
ArrayInitialize(Histogram, EMPTY_VALUE);
ArrayInitialize(MACD_Main, EMPTY_VALUE);
ArrayInitialize(MACD_Signal, EMPTY_VALUE);
}
else
limit = MathMax(limit + 1, 1);
//---
const int toCopy = rates_total != prev_calculated ? rates_total - prev_calculated : 1;
//---
ArraySetAsSeries(Histogram, true);
ArraySetAsSeries(MACD_Main, true);
ArraySetAsSeries(MACD_Signal, true); Dislikedi found this Currency Meter indicator on the web, but it doesn't have human readable code - the one i found, so i ran it on Grok AI, resolved some errors, but i cant manage to re-align Signal Strength Bars or resolve those blue & red rectangle strips, can someone please help by checking the code, its now readable. {file} {image}Ignored
DislikedHey Guys, i want to learn and improve my MQL4 skills. I think the best way to do this is to practice. Unfortunately sometimes I don`t have any nice idea which i can implement in a Expert Advisor / Indicator. So if any of you is interested, please post in this forum your ideas and i will try to implement it into mql4. AndiIgnored
Disliked{quote} a kind request to place a text area below the buttons to set a target on the go while taking the trade {image}Ignored
DislikedHello, I'd appreciate it if someone could help fix this (MQL5) code bug. I've spent significant time on this code, even working through the entire weekend. It seemed to work correctly with Bitcoin, but today it broke with GBP. I have another version that uses 6 buffers and works flawlessly without issues. However, my MetaTrader 5 platform has been freezing lately, preventing me from seeing price movements. I had to remove some tools to mitigate this. To optimize the code, I tried replacing the 4 histogram buffers with DRAW_COLOR_HISTOGRAM using...Ignored
ArrayResize(Array,rates_total);
Dislikedi found this Currency Meter indicator on the web, but it doesn't have human readable code - the one i found, so i ran it on Grok AI, resolved some errors, but i cant manage to re-align Signal Strength Bars or resolve those blue & red rectangle strips, can someone please help by checking the code, its now readable. {file} {image}Ignored
Disliked{quote} That means it was likely decompiled, thus no serious developer would even touch that file (even if you used AI to fix it up)Ignored
Dislikedi found this Currency Meter indicator on the web, but it doesn't have human readable code - the one i found, so i ran it on Grok AI, resolved some errors, but i cant manage to re-align Signal Strength Bars or resolve those blue & red rectangle strips, can someone please help by checking the code, its now readable. {file} {image}Ignored
Disliked{quote} The full code would be helpful but you could try setting the buffers as series. //--- initial zero if (prev_calculated < 1) { ArrayInitialize(Histogram, EMPTY_VALUE); ArrayInitialize(MACD_Main, EMPTY_VALUE); ArrayInitialize(MACD_Signal, EMPTY_VALUE); } else limit = MathMax(limit + 1, 1); //--- const int toCopy = rates_total != prev_calculated ? rates_total - prev_calculated : 1; //--- ArraySetAsSeries(Histogram, true); ArraySetAsSeries(MACD_Main, true); ArraySetAsSeries(MACD_Signal, true);Ignored
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_plots 3
#property strict
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//--- plot HISTOGRAM
#property indicator_label1 "HISTOGRAM"
#property indicator_type1 DRAW_COLOR_HISTOGRAM
#property indicator_color1 C'186,207,222',clrDodgerBlue,C'222,186,190',clrTomato
#property indicator_style1 STYLE_SOLID
#property indicator_width1 3
//--- plot MACD
#property indicator_label2 "MACD"
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrGray
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
//--- plot Signal
#property indicator_label3 "Signal"
#property indicator_type3 DRAW_LINE
#property indicator_color3 clrBlack
#property indicator_style3 STYLE_DOT
#property indicator_width3 1
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//Macd
input group "MACD Setting"
input int Fast_EMA = 12;
input int Slow_EMA = 26;
input int MACD_SMA = 9;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int MACD_handle;
double MACD_Main[];
double MACD_Signal[];
double Histogram[];
double HistogramColors[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
IndicatorSetString(INDICATOR_SHORTNAME,"MACD ("+(string)Fast_EMA+","+(string)Slow_EMA+","+(string)MACD_SMA+")");
IndicatorSetInteger(INDICATOR_DIGITS,Digits()+1);
//---
MACD_handle = iMACD(NULL, PERIOD_CURRENT, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_CLOSE);
if(MACD_handle < 0)
{
Print("The creation of iMACD has failed: MACD_handle = ", INVALID_HANDLE);
Print("Runtime error = ", GetLastError());
return(INIT_PARAMETERS_INCORRECT);
}
//---
int iBuf=0;
SetIndexBuffer(iBuf,Histogram, INDICATOR_DATA);
iBuf++;
SetIndexBuffer(iBuf,HistogramColors, INDICATOR_COLOR_INDEX);
iBuf++;
SetIndexBuffer(iBuf,MACD_Main, INDICATOR_DATA);
iBuf++;
SetIndexBuffer(iBuf,MACD_Signal, INDICATOR_DATA);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
if(MACD_handle != INVALID_HANDLE)
IndicatorRelease(MACD_handle);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const int begin,
const double &price[])
{
//---
if(prev_calculated<0 || IsStopped())
return(-1);
//---
int limit = rates_total - prev_calculated;
//--- initial zero
if(prev_calculated < 1)
{
ArrayInitialize(Histogram, EMPTY_VALUE);
ArrayInitialize(MACD_Main, EMPTY_VALUE);
ArrayInitialize(MACD_Signal, EMPTY_VALUE);
}
else
limit = MathMax(limit + 1, 1);
//---
const int toCopy = rates_total != prev_calculated ? rates_total - prev_calculated : 1;
//---
if(BarsCalculated(MACD_handle) <= 0)
return(0);
if(CopyBuffer(MACD_handle, MAIN_LINE, 0, toCopy, MACD_Main) != toCopy)
return(0);
//---
if(BarsCalculated(MACD_handle) <= 0)
return(0);
if(CopyBuffer(MACD_handle, SIGNAL_LINE, 0, toCopy, MACD_Signal) != toCopy)
return(0);
//---
//---
if(BarsCalculated(MACD_handle) <= 0)
return(0);
if(CopyBuffer(MACD_handle, MAIN_LINE, 0, toCopy, Histogram) != toCopy)
return(0);
//---
ArraySetAsSeries(Histogram, true);
ArraySetAsSeries(MACD_Main, true);
ArraySetAsSeries(MACD_Signal, true);
//---
for(int i = limit - 1; i >= 0 && !_StopFlag; i--)
{
//---Set Histogram Color
if(i < rates_total - 1)
{
if(Histogram[i] > 0 || Histogram[i+1] > 0)
{
//When the histogram transitions from negative to positive, the first positive column always uses color index 0.
if(Histogram[i] > 0 && Histogram[i+1] < 0)
HistogramColors[i] = 0;
else
//Positive column higher than the previous uses index 0 | Positive column lower than the previous uses index 1.
HistogramColors[i+1] = (Histogram[i] > Histogram[i+1]) ? 0 : 1;
}
if(Histogram[i] < 0 || Histogram[i+1] < 0)
{
//When the histogram transitions from positive to negative, the first negative column always uses color index 2.
if(Histogram[i] < 0 && Histogram[i+1] > 0)
HistogramColors[i] = 2;
else
//Negative column lower than the previous uses index 2 | Negative column higher than the previous uses index 3.
HistogramColors[i+1] = (Histogram[i] < Histogram[i+1]) ? 2 : 3;
}
}
}
return(rates_total);
} Disliked{quote} Can't fix anything without the full source code. If it's working and then it stops, the most likely reason is array out of range. Try doing this for every array: ArrayResize(Array,rates_total);Ignored
Disliked{quote} It's not a special code, but I think most of the time the problem is with OnCalculate. Although I posted the entire code a few posts ago, since it's a tool that is really useful for me, I want to have the code so I can make edits if needed later. Even though I currently have a good and healthy code, it has six buffers, and unfortunately, an issue occurred with one of the tools in live trading, and MetaTrader froze for several minutes. That's why I want to use a code that I'm sure is optimized. In this thread, you can see that I even used...Ignored
DATETIME var1, var2;
If (var1 > var2) {
// do something ...
} Int iVar1 = (int) var1;
int iVar2 = (int) var2;
if (iVar > iVar2 ) {
// do something
} string sTime1 = IntegerToString (iVar1);
string myObjName1 = StringConcatenate (""xxxxx", sTime1, "XXX", .. );
// Do somethink