Trying to place an arrow/text if there is three consecutive bearish or bullish candles formed. Tried a couple of options, but unable to handle Arrow's position. Either too many arrows got painted or the location was at the wrong place. Also tried place text but no luck.
#property copyright""#property link""#property indicator_chart_window#property indicator_buffers0// exported variables// local variablesstring LF = "\n"; // use this in custom or utility blocks where you need line feedsint ObjCount = 0; // count of all objects created on the chart, allows creation of objects with unique namesint current = 0; // variable points to current barint init()
{
if (true) ObjectsDeleteAll(); // clear the chart
IndicatorShortName("");
IndicatorDigits(0);
IndicatorBuffers(0);
return(0);
}
//+------------------------------------------------------------------+//| Custom indicator deinitialization function |//+------------------------------------------------------------------+int deinit()
{
if (true) ObjectsDeleteAll();
return(0);
}
//+------------------------------------------------------------------+//| Custom indicator start function |//+------------------------------------------------------------------+int start()
{
OnEveryTick1();
return(0);
}
//+------------------------------------------------------------------+void OnEveryTick1()
{
int i;
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
i = Bars - counted_bars;
// main calculation loopwhile (i >= 0)
{
current = i;
TA();
i--;
}
}
void TA()
{
if (Open[1] > Close[1] && Open[2] > Close[2] && Open[3] > Close[3])
{
Arrow();
}
}
void Arrow()
{
ObjCount += 1;
string objName = "EAChart_" + ObjCount;
ObjectCreate(objName, OBJ_ARROW, 0, Time[current], Bid);
ObjectSet(objName, OBJPROP_COLOR, White);
ObjectSet(objName, OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
}
#property indicator_chart_window// an indicator is drawn in the main chart window#property indicator_buffers1int limit;
int init ()
{
//----return(0);
}
int deinit()
{
return(0);
}
int start()
{
string text;
int counted_bars=IndicatorCounted();
limit=Bars-counted_bars;
//---- check for possible errorsif(counted_bars<0) {
Alert("No Bars..");
return(-1);
}
//---- last counted bar will be recountedfor(int i=1; i<limit; i++) {
text="";
if (Open[1] > Close[1] && Open[2] > Close[2] && Open[3] > Close[3])
text="3HC";
if(text!="")
{
ObjectCreate(DoubleToStr(i,0)+" label", OBJ_TEXT, 0, Time[i], High[i]);
ObjectSetText(DoubleToStr(i,0)+" label", text, 10, "Arial",Yellow);
}
}
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Trying to place an arrow/text if there is three consecutive bearish or bullish candles formed. Tried a couple of options, but unable to handle Arrow's position. Either too many arrows got painted or the location was at the wrong place. Also tried place text but no luck.