You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Doc,
In order to allow combinations of hour like from 22 to 03 (just one example) and to include the starting and ending our in the time filter, the code for time checking should look like this :
if (EndingHour<StartHour)
allowedHours = (ct.hour>=StartHour || ct.hour<=EndingHour);
else allowedHours = (ct.hour>=StartHour && ct.hour<=EndingHour);
Mladen,
tried with it but I got problem again, just please take a look on this draft attached...trading hour 0 and minutes 5, instead ea enters immediately. And we don't have the "ending minutes" parameter.
But the most important thing...I wrote a few posts ago a big nonsense, if one position is opened and in the same moment we need to close and open an opposite new position, it's possible with just double the lot value.
doc
Mladen,
tried with it but I got problem again, just please take a look on this draft attached...trading hour 0 and minutes 5, instead ea enters immediately. And we don't have the "ending minutes" parameter.
But the most important thing...I wrote a few posts ago a big nonsense, if one position is opened and in the same moment we need to close and open an opposite new position, it's possible with just double the lot value.
docDoc
Will make a new time filter that should cover all the possible cases
Doc
Attaching an indicator that contains now a simple to use function to check time limits (to filter the time). It finds out if the time checked is within limits given by start hour, minute, second and end hour, minute second. To turn the filter off, set the start time to 0,0,0 and end time to 24,0,0. It recognizes cases when it should check periods like 20 to 03 for example too, so it should fit for a time filter now.
Made it as an indicator simply to be able to test all the input variations and as far as I see it works OK in all the cases. It checks the correctness of the time parameters too (it does not allow incorrect hour, minute or second usage in the comparison). It is easy to include it in any EA too (does not require any include files).
Here is a version that is showing how can a function be overloaded in metatrader 5
In this one there are 3 ways how checkTimeLimits() function can be calledHi Mladen,
this is a new try...I don't understand why the ea doesn't respect the close.
Thanks in advance
doc
Ok, this is what I have right now, a double bollinger bands ea that has a time filter and many other things...
It works properly but the icing on the cake would be code the ea to be able, only in the circumstance of an opposite position needed on trade, to "average" the lots amount instead of loosing time on close a position and than open a new one.
I'll try.
doc
Dear Mladen,
I tried to change the time filter for 2 reasons:
1- I need to have different time condition for friday,
2- When a position is opened the close hour shouldn't mean close opened position, but manage until normal signal close and don't open new one until start hour,
all of this, it's inside this code:
{
bool tresult = false;
double MonStart, FriEnd;
datetime MonSessionStart, FriSessionEnd;
if(((TradeDay >= 0 && DayOfWeek() == TradeDay) || TradeDay == -1) && DayOfWeek()!= NonTradeDay)
{
if(Start_h == 24) Start_h = 0;
datetime SessionStart = StringToTime((string)Start_h+":"+(string)StartMinute);
double Start = Start_h + StartMinute/60.0;
datetime SessionEnd = StringToTime((string)EndHour+":"+(string)EndMinute);
double End = EndHour + EndMinute/60.0;
if(DayOfWeek() != 1 && DayOfWeek() != 5)
{
if (Start = SessionStart && TimeCurrent() < SessionEnd);
else
if (Start > End)
tresult = (TimeCurrent() >= SessionStart && TimeCurrent() < StringToTime((string)23+":"+(string)59))
||(TimeCurrent() >= StringToTime((string)0+":"+(string)0) && TimeCurrent() < SessionEnd);
}
else
if(DayOfWeek() == 1)
{
if(MonStart_h < 0 || MonStart_min < 0) {MonStart_h = Start_h; MonStart_min = StartMinute;}
if(MonStart_h > 0 || MonStart_min > 0)
{
MonSessionStart = StringToTime((string)MonStart_h+":"+(string)MonStart_min);
MonStart = MonStart_h + MonStart_min/60.0;
}
else
{
MonSessionStart = StringToTime((string)0+":"+(string)0); //SessionStart;
MonStart = 0;//Start;
}
if (Start < End)
{
if (MonStart != 0) tresult = TimeCurrent() >= MonSessionStart && TimeCurrent() < SessionEnd;
else tresult = TimeCurrent() >= SessionStart && TimeCurrent() < SessionEnd;
}
else
if (Start > End)
{
tresult = (TimeCurrent() >= MonSessionStart && TimeCurrent() < SessionEnd)
||(TimeCurrent() >= SessionStart && TimeCurrent() < StringToTime((string)23+":"+(string)59));
}
}
else
if(DayOfWeek() == 5)
{
if(FriEnd_h < 0 || FriEnd_min < 0) {FriEnd_h = EndHour; FriEnd_min = EndMinute;}
if(FriEnd_h > 0 || FriEnd_min > 0)
{
FriSessionEnd = StringToTime((string)FriEnd_h+":"+(string)FriEnd_min);
FriEnd = FriEnd_h + FriEnd_min/60.0;
}
else
{
FriSessionEnd = SessionEnd;
FriEnd = End;
}
if (Start < End)
{
if (FriEnd != End) tresult = TimeCurrent() >= SessionStart && TimeCurrent() < FriSessionEnd;
else
tresult = TimeCurrent() >= SessionStart && TimeCurrent() < SessionEnd;
}
else
if (Start > End)
tresult = (TimeCurrent() >= StringToTime((string)0+":"+(string)0) && TimeCurrent() < SessionEnd)
||(TimeCurrent() >= SessionStart && TimeCurrent() < FriSessionEnd);
}
}
return(tresult);
}but I don't know why it doesn't work, cause the ea received the close signal but it doesn't close the position.
Could you please give me some support?
Thanks
doc
Using PlotIndexSetInteger to change arrow code on the fly
From the documentation I thought it would be possible, but so far I haven't manage to make it work. I have included my code below, could someone please take a look and show me where I've gone wrong. As you can see from the commented out sections, I originally was going to do what I wanted with 9 separate buffers, but one is better if I can manage it.
I am sure there are other errors as well, I am just getting started with mql5 so if you could suggest any improvements that would be greatly appreciated as well.
//| CandleSentiment.mq5 |
//| whitebloodcell |
//| tmclayson@gmail.com |
//+------------------------------------------------------------------+
#property copyright "whitebloodcell"
#property link "tmclayson@gmail.com"
#property version "1.00"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots 1
#property indicator_maximum 5
#property indicator_minimum -5
#property indicator_width1 2
#property indicator_label1 "CandleSentiment"
/*
#property indicator_label1 "HighCloseBullPattern"
#property indicator_label2 "MidCloseBullPattern"
#property indicator_label3 "LowCloseBullPattern"
#property indicator_label4 "HighCloseRangePattern"
#property indicator_label5 "MidCloseRangePattern"
#property indicator_label6 "LowCloseRangePattern"
#property indicator_label7 "HighCloseBearPattern"
#property indicator_label8 "MidCloseBearPattern"
#property indicator_label9 "LowCloseBearPattern"
double HighCloseBullPattern[];
double MidCloseBullPattern[];
double LowCloseBullPattern[];
double HighCloseRangePattern[];
double MidCloseRangePattern[];
double LowCloseRangePattern[];
double HighCloseBearPattern[];
double MidCloseBearPattern[];
double LowCloseBearPattern[];
*/
double CandleSentiment[];
//#include
bool FirstRun = true;
double RangePercent;
//+------------------------------------------------------------------+
//| Initialization
//+------------------------------------------------------------------+
int OnInit() {
//--- name for DataWindow
IndicatorSetString(INDICATOR_SHORTNAME,"CandleSentiment("+_Symbol+")");
//--- Not sure if it was being calculated when declared as a global
RangePercent = 1.0/3.0;
//--- indicator buffers mapping
if(!SetIndexBuffer(0,CandleSentiment,INDICATOR_DATA)) {
Print("SetIndexBuffer(0,CandleSentiment,INDICATOR_DATA) returning false");
}
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);
/*
SetIndexBuffer(0,HighCloseBullPattern,INDICATOR_DATA);
SetIndexBuffer(1,MidCloseBullPattern,INDICATOR_DATA);
SetIndexBuffer(2,LowCloseBullPattern,INDICATOR_DATA);
SetIndexBuffer(3,HighCloseRangePattern,INDICATOR_DATA);
SetIndexBuffer(4,MidCloseRangePattern,INDICATOR_DATA);
SetIndexBuffer(5,LowCloseRangePattern,INDICATOR_DATA);
SetIndexBuffer(6,HighCloseBearPattern,INDICATOR_DATA);
SetIndexBuffer(7,MidCloseBearPattern,INDICATOR_DATA);
SetIndexBuffer(8,LowCloseBearPattern,INDICATOR_DATA);
//--- indicator arrow styles
PlotIndexSetInteger(0,PLOT_ARROW,241);//Up
PlotIndexSetInteger(1,PLOT_ARROW,246);//Diagonal Up
PlotIndexSetInteger(3,PLOT_ARROW,240);//Sidewards
PlotIndexSetInteger(4,PLOT_ARROW,244);// Up Down
PlotIndexSetInteger(5,PLOT_ARROW,244);// Up Down
PlotIndexSetInteger(5,PLOT_ARROW,244;// Up Down
PlotIndexSetInteger(6,PLOT_ARROW,240);//Sidewards
PlotIndexSetInteger(7,PLOT_ARROW,248);//Diagonal Down
PlotIndexSetInteger(8,PLOT_ARROW,242);//Down
//---- sets drawing line empty value--
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(4,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(6,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(7,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(8,PLOT_EMPTY_VALUE,EMPTY_VALUE);
*/
//--- set accuracy
IndicatorSetInteger(INDICATOR_DIGITS,1);
//--- sets first bar from what index will be drawn
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,1);
//--- return if completed successfully.
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Main Indicator Logic
//+------------------------------------------------------------------+
int OnCalculate(const int _BarsTotal,
const int _BarsCalculated,
const datetime &T[],
const double &O[],
const double &H[],
const double &L[],
const double &C[],
const long &TV[],
const long &V[],
const int &S[]) {
int StartIndex = MathMax(_BarsCalculated-1,1);
int FinishIndex =_BarsTotal-1;
int Sentiment;
int Temp4,Temp3,Temp2,Temp1,Temp0,Temp_1,Temp_2,Temp_3,Temp_4;
if(_BarsTotal<FinishIndex) {
return(0);
}
else {
if(FirstRun) {
ArrayInitialize(CandleSentiment,EMPTY_VALUE);
/*
ArrayInitialize(HighCloseBullPattern,EMPTY_VALUE);
ArrayInitialize(MidCloseBullPattern,EMPTY_VALUE);
ArrayInitialize(LowCloseBullPattern,EMPTY_VALUE);
ArrayInitialize(HighCloseRangePattern,EMPTY_VALUE);
ArrayInitialize(MidCloseRangePattern,EMPTY_VALUE);
ArrayInitialize(LowCloseRangePattern,EMPTY_VALUE);
ArrayInitialize(HighCloseBearPattern,EMPTY_VALUE);
ArrayInitialize(MidCloseBearPattern,EMPTY_VALUE);
ArrayInitialize(LowCloseBearPattern,EMPTY_VALUE);
*/
// Set the price arrays to match with the indicator arrays
ArraySetAsSeries(T,true);
ArraySetAsSeries(O,true);
ArraySetAsSeries(H,true);
ArraySetAsSeries(L,true);
ArraySetAsSeries(C,true);
ArraySetAsSeries(TV,true);
ArraySetAsSeries(V,true);
ArraySetAsSeries(S,true);
//ArraySetAsSeries(CandleSentiment,true);
FirstRun=false;
}
}
for(int Bar=StartIndex; Bar<FinishIndex; Bar++) {
Sentiment = CandleSentiment(Bar,Bar-1,RangePercent,RangePercent,O,H,L,C);
switch(Sentiment) {
case 4:
if(!PlotIndexSetInteger(0,PLOT_ARROW,241)) {
Print("case 4: PlotIndexSetInteger(0,PLOT_ARROW,241) Failed");
};
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrGreen);
CandleSentiment=Sentiment;
Temp4 = CandleSentiment;
break;
case 3:
if(!PlotIndexSetInteger(0,PLOT_ARROW,246)) {
Print("case 3: PlotIndexSetInteger(0,PLOT_ARROW,246) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrGreen);
CandleSentiment=Sentiment;
Temp3 = CandleSentiment;
break;
case 2:
if(!PlotIndexSetInteger(0,PLOT_ARROW,240)) {
Print("case 2: PlotIndexSetInteger(0,PLOT_ARROW,240) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrGreen);
CandleSentiment=Sentiment;
Temp2 = CandleSentiment;
break;
case 1:
if(!PlotIndexSetInteger(0,PLOT_ARROW,244)) {
Print("case 1: PlotIndexSetInteger(0,PLOT_ARROW,244) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrGreen);
CandleSentiment=Sentiment;
Temp1 = CandleSentiment;
break;
case 0:
if(!PlotIndexSetInteger(0,PLOT_ARROW,244)) {
Print("case 0: PlotIndexSetInteger(0,PLOT_ARROW,244) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrGray);
CandleSentiment=Sentiment;
Temp0 = CandleSentiment;
break;
case -1:
if(!PlotIndexSetInteger(0,PLOT_ARROW,244)) {
Print("case -1: PlotIndexSetInteger(0,PLOT_ARROW,244) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrRed);
CandleSentiment=Sentiment;
Temp_1 = CandleSentiment;
break;
case -2:
if(!PlotIndexSetInteger(0,PLOT_ARROW,240)) {
Print("case -2: PlotIndexSetInteger(0,PLOT_ARROW,240) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrRed);
CandleSentiment=Sentiment;
Temp_2 = CandleSentiment;
break;
case -3:
if(!PlotIndexSetInteger(0,PLOT_ARROW,248)) {
Print("case -3: PlotIndexSetInteger(0,PLOT_ARROW,248) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrRed);
CandleSentiment=Sentiment;
Temp_3 = CandleSentiment;
break;
case -4:
if(!PlotIndexSetInteger(0,PLOT_ARROW,242)) {
Print("case -4: PlotIndexSetInteger(0,PLOT_ARROW,242) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrRed);
CandleSentiment=Sentiment;
Temp_4 = CandleSentiment;
break;
default: Print("Unexpected Sentiment"); break;
}
}
//--- return value of prev_calculated for next call
return(_BarsCalculated);
}From the documentation I thought it would be possible, but so far I haven't manage to make it work. I have included my code below, could someone please take a look and show me where I've gone wrong. As you can see from the commented out sections, I originally was going to do what I wanted with 9 separate buffers, but one is better if I can manage it.
I am sure there are other errors as well, I am just getting started with mql5 so if you could suggest any improvements that would be greatly appreciated as well.
//| CandleSentiment.mq5 |
//| whitebloodcell |
//| tmclayson@gmail.com |
//+------------------------------------------------------------------+
#property copyright "whitebloodcell"
#property link "tmclayson@gmail.com"
#property version "1.00"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots 1
#property indicator_maximum 5
#property indicator_minimum -5
#property indicator_width1 2
#property indicator_label1 "CandleSentiment"
double CandleSentiment[];
//#include
bool FirstRun = true;
double RangePercent;
//+------------------------------------------------------------------+
//| Initialization
//+------------------------------------------------------------------+
int OnInit() {
//--- name for DataWindow
IndicatorSetString(INDICATOR_SHORTNAME,"CandleSentiment("+_Symbol+")");
//--- Not sure if it was being calculated when declared as a global
RangePercent = 1.0/3.0;
//--- indicator buffers mapping
if(!SetIndexBuffer(0,CandleSentiment,INDICATOR_DATA)) {
Print("SetIndexBuffer(0,CandleSentiment,INDICATOR_DATA) returning false");
}
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);
/*
SetIndexBuffer(0,HighCloseBullPattern,INDICATOR_DATA);
SetIndexBuffer(1,MidCloseBullPattern,INDICATOR_DATA);
SetIndexBuffer(2,LowCloseBullPattern,INDICATOR_DATA);
SetIndexBuffer(3,HighCloseRangePattern,INDICATOR_DATA);
SetIndexBuffer(4,MidCloseRangePattern,INDICATOR_DATA);
SetIndexBuffer(5,LowCloseRangePattern,INDICATOR_DATA);
SetIndexBuffer(6,HighCloseBearPattern,INDICATOR_DATA);
SetIndexBuffer(7,MidCloseBearPattern,INDICATOR_DATA);
SetIndexBuffer(8,LowCloseBearPattern,INDICATOR_DATA);
//--- indicator arrow styles
PlotIndexSetInteger(0,PLOT_ARROW,241);//Up
PlotIndexSetInteger(1,PLOT_ARROW,246);//Diagonal Up
PlotIndexSetInteger(3,PLOT_ARROW,240);//Sidewards
PlotIndexSetInteger(4,PLOT_ARROW,244);// Up Down
PlotIndexSetInteger(5,PLOT_ARROW,244);// Up Down
PlotIndexSetInteger(5,PLOT_ARROW,244;// Up Down
PlotIndexSetInteger(6,PLOT_ARROW,240);//Sidewards
PlotIndexSetInteger(7,PLOT_ARROW,248);//Diagonal Down
PlotIndexSetInteger(8,PLOT_ARROW,242);//Down
//---- sets drawing line empty value--
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(4,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(6,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(7,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(8,PLOT_EMPTY_VALUE,EMPTY_VALUE);
*/
//--- set accuracy
IndicatorSetInteger(INDICATOR_DIGITS,1);
//--- sets first bar from what index will be drawn
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,1);
//--- return if completed successfully.
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Main Indicator Logic
//+------------------------------------------------------------------+
int OnCalculate(const int _BarsTotal,
const int _BarsCalculated,
const datetime &T[],
const double &O[],
const double &H[],
const double &L[],
const double &C[],
const long &TV[],
const long &V[],
const int &S[]) {
int StartIndex = MathMax(_BarsCalculated-1,1);
int FinishIndex =_BarsTotal-1;
int Sentiment;
int Temp4,Temp3,Temp2,Temp1,Temp0,Temp_1,Temp_2,Temp_3,Temp_4;
if(_BarsTotal<FinishIndex) {
return(0);
}
else {
if(FirstRun) {
ArrayInitialize(CandleSentiment,EMPTY_VALUE);
/*
ArrayInitialize(HighCloseBullPattern,EMPTY_VALUE);
ArrayInitialize(MidCloseBullPattern,EMPTY_VALUE);
ArrayInitialize(LowCloseBullPattern,EMPTY_VALUE);
ArrayInitialize(HighCloseRangePattern,EMPTY_VALUE);
ArrayInitialize(MidCloseRangePattern,EMPTY_VALUE);
ArrayInitialize(LowCloseRangePattern,EMPTY_VALUE);
ArrayInitialize(HighCloseBearPattern,EMPTY_VALUE);
ArrayInitialize(MidCloseBearPattern,EMPTY_VALUE);
ArrayInitialize(LowCloseBearPattern,EMPTY_VALUE);
*/
// Set the price arrays to match with the indicator arrays
ArraySetAsSeries(T,true);
ArraySetAsSeries(O,true);
ArraySetAsSeries(H,true);
ArraySetAsSeries(L,true);
ArraySetAsSeries(C,true);
ArraySetAsSeries(TV,true);
ArraySetAsSeries(V,true);
ArraySetAsSeries(S,true);
//ArraySetAsSeries(CandleSentiment,true);
FirstRun=false;
}
}
for(int Bar=StartIndex; Bar<FinishIndex; Bar++) {
Sentiment = CandleSentiment(Bar,Bar-1,RangePercent,RangePercent,O,H,L,C);
switch(Sentiment) {
case 4:
if(!PlotIndexSetInteger(0,PLOT_ARROW,241)) {
Print("case 4: PlotIndexSetInteger(0,PLOT_ARROW,241) Failed");
};
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrGreen);
CandleSentiment=Sentiment;
Temp4 = CandleSentiment;
break;
case 3:
if(!PlotIndexSetInteger(0,PLOT_ARROW,246)) {
Print("case 3: PlotIndexSetInteger(0,PLOT_ARROW,246) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrGreen);
CandleSentiment=Sentiment;
Temp3 = CandleSentiment;
break;
case 2:
if(!PlotIndexSetInteger(0,PLOT_ARROW,240)) {
Print("case 2: PlotIndexSetInteger(0,PLOT_ARROW,240) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrGreen);
CandleSentiment=Sentiment;
Temp2 = CandleSentiment;
break;
case 1:
if(!PlotIndexSetInteger(0,PLOT_ARROW,244)) {
Print("case 1: PlotIndexSetInteger(0,PLOT_ARROW,244) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrGreen);
CandleSentiment=Sentiment;
Temp1 = CandleSentiment;
break;
case 0:
if(!PlotIndexSetInteger(0,PLOT_ARROW,244)) {
Print("case 0: PlotIndexSetInteger(0,PLOT_ARROW,244) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrGray);
CandleSentiment=Sentiment;
Temp0 = CandleSentiment;
break;
case -1:
if(!PlotIndexSetInteger(0,PLOT_ARROW,244)) {
Print("case -1: PlotIndexSetInteger(0,PLOT_ARROW,244) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrRed);
CandleSentiment=Sentiment;
Temp_1 = CandleSentiment;
break;
case -2:
if(!PlotIndexSetInteger(0,PLOT_ARROW,240)) {
Print("case -2: PlotIndexSetInteger(0,PLOT_ARROW,240) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrRed);
CandleSentiment=Sentiment;
Temp_2 = CandleSentiment;
break;
case -3:
if(!PlotIndexSetInteger(0,PLOT_ARROW,248)) {
Print("case -3: PlotIndexSetInteger(0,PLOT_ARROW,248) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrRed);
CandleSentiment=Sentiment;
Temp_3 = CandleSentiment;
break;
case -4:
if(!PlotIndexSetInteger(0,PLOT_ARROW,242)) {
Print("case -4: PlotIndexSetInteger(0,PLOT_ARROW,242) Failed");
}
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrRed);
CandleSentiment=Sentiment;
Temp_4 = CandleSentiment;
break;
default: Print("Unexpected Sentiment"); break;
}
}
//--- return value of prev_calculated for next call
return(_BarsCalculated);
}the code is missing CandleSentiment() function
Also, if you use PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrGreen); it will change the color for the entire line (not just the current bar). You have to use SetIndexBuffer(bufferNumber,buffer,INDICATOR_COLOR_INDEX); and then set the color number in the buffer to the desired value.
That much I can say without the function
________________________________
PS: you should probably stop thinking the metatrader 4 way. No need to set buffers as series at all and it will make your code much cleaner and much easier to work on
Adding a simple example how can one line have 3 colors in metatrader 5 in a very simple way. All in all you can have up to 64 colors (if I am not mistaken but don't take this limit for granted - in the list you are going to see only 16) for one drawing buffer