Hi mladen, Could you please help me with this. I have tried some combinations and different things, but can't figure out how to do this. Thanks!
Simon
The conditions should be more refined. For example : when both are signaling the same is very often. So, when exactly should they do that. On the first occurrence of that? On every occurrence of that? Also, if you are exiting on ever change of one of the two, the exits are going to be very frequent
The conditions should be more refined. For example : when both are signaling the same is very often. So, when exactly should they do that. On the first occurrence of that? On every occurrence of that? Also, if you are exiting on ever change of one of the two, the exits are going to be very frequent
Thanks for reply! Yes, this might not be a good strategy. It's just that if I get this as a template I can probably do some changes by myself later. What I want is the possibility to combine two indicators (and the use of their buffers).
Lets say the strategy instead should be: buy when both indicators indicate. And sell when both indicators indicate. It should happen after indicator change and closed bar. It should happen on every occurrence of that.
when the indi is applied during the EA execution ( the standard moving average in MT4 ) the values are very different to the values wich are displayed applying the same indicator at the end of the EA execution.
Could you please explain why and if feasible correct the indi ?
Mladen just finished my customization in the previous indicator you modified. What's wrong in this code? It does not display nothing...No errors when compiled.
#property version"1.00"#property strict#property indicator_chart_window#property indicator_buffers4#property indicator_color1 Gold
#property indicator_color2 DodgerBlue
#property indicator_color3 LimeGreen
#property indicator_color4 Crimson
#property indicator_width1 2#property indicator_width2 2#property indicator_width3 2#property indicator_width4 2externstring NOTE1 = "SELECT PARAMETERS OF THE INDICATOR"; //SPAN MA CROSS PARAMSexternint SpanPeriod = 1; // Period of Spanexternint SpanShift = -26; // Shift of SpanexternENUM_MA_METHOD SpanMode = 1; // Mode of SpanexternENUM_APPLIED_PRICE SpanPrice = 0; // Applied price of Spanexternint MaPeriod = 55; // Period of Moving averageexternint MaShift = 0; // Shift of Moving averageexternENUM_MA_METHOD MaMode = 1; // Mode of Moving averageexternENUM_APPLIED_PRICE MaPrice = 0; // Applied price of Moving averageexternstring NOTE2 = "SELECT COLORS/STYLES OF THE INDICATOR"; //SPAN MA CROSS COLORS/STYLESexterncolor SpanClr = Gold; // Span colorexternint SpanWdt = 2; // Span widthexternENUM_LINE_STYLE SpanStl = 0; // Span line styleexterncolor MaClr = DodgerBlue; // Moving average colorexternint MaWdt = 2; // Moving average widthexternENUM_LINE_STYLE MaStl = 0; // Moving average line styleexternstring NOTE3 = "SELECT PARAMETERS OF THE SIGNAL ARROWS"; //SPAN MA CROSS PARAMETERS OF THE SIGNAL ARROWSexternbool DrawArrows = true; // Draw signal arrows?externbool DrawMaLines = true; // Draw lines?externcolor UpArrowClr = LimeGreen; // Up arrow colorexternint UpArrowWdt = 2; // Up arrow widthexterncolor DnArrowClr = Crimson; // Down arrow colorexternint DnArrowWdt = 2; // Down arrow widthexternint ArrowsDistance = 10; // Arrows distance from candleexternstring NOTE4 = "SELECT PARAMETERS OF THE ALERT"; //SPAN MA CROSS PARAMETERS OF THE ALERTexternbool AlertsOn = true; // Active alert?externbool AlertsOnCurrent = true; // Alert on current unclosed barexternbool AlertsMessage = true; // Alert messageexternbool AlertsSound = true; // Alert soundexternbool AlertsEmail = false; // Alert e-mailexternstring SoundFile = "alert2.wav"; // Filename of sound alertstring IndicatorFileName;
int WhichBar;
double Gap;
double SpanBuffer[]; // Buffer of the Spandouble MaBuffer[]; // Buffer of the Moving averagedouble CrossUpBuffer[]; // Up arrow bufferdouble CrossDnBuffer[]; // Down arrow bufferdouble TrendBuffer[]; // Span/Ma cross bufferint init()
{
IndicatorFileName = WindowExpertName();
IndicatorBuffers(5);
SetIndexBuffer(0, SpanBuffer);
SetIndexBuffer(1, MaBuffer);
SetIndexBuffer(2, CrossUpBuffer);
SetIndexBuffer(3, CrossDnBuffer);
SetIndexBuffer(4, TrendBuffer);
if (DrawMaLines) {
SetIndexStyle (0, DRAW_LINE, SpanStl, SpanWdt, SpanClr);
SetIndexStyle (1, DRAW_LINE, MaStl, MaWdt, MaClr);}
else {
SetIndexStyle(0, DRAW_NONE);
SetIndexStyle(1, DRAW_NONE);}
if (DrawArrows) {
SetIndexStyle (2, DRAW_ARROW, 0, UpArrowWdt, UpArrowClr); SetIndexArrow(0, 233);
SetIndexStyle (3, DRAW_ARROW, 0, DnArrowWdt, DnArrowClr); SetIndexArrow(0, 234);}
else {
SetIndexStyle(2, DRAW_NONE);
SetIndexStyle(3, DRAW_NONE);}
return(0);}
int deinit() { return(0); }
int start() {
int counted_bars = IndicatorCounted();
int i, limit;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit = MathMin(Bars-counted_bars, Bars-1);
for(i=limit; i>=0; i--){
SpanBuffer[i] = iMA(NULL, 0, SpanPeriod, SpanShift, SpanMode, SpanPrice, i);
MaBuffer[i] = iMA(NULL, 0, MaPeriod, MaShift, MaMode, MaPrice, i);
Gap = iATR(NULL,0,20,i);
TrendBuffer[i] = TrendBuffer[i+1];
if (SpanBuffer[i] > MaBuffer[i]) TrendBuffer[i] = 1;
if (SpanBuffer[i] < MaBuffer[i]) TrendBuffer[i] =-1;
CrossUpBuffer[i] = EMPTY_VALUE;
CrossDnBuffer[i] = EMPTY_VALUE;
if (TrendBuffer[i]!= TrendBuffer[i+1])
if (TrendBuffer[i] == 1)
CrossUpBuffer[i] = Low[i] - ArrowsDistance * Gap;
else CrossDnBuffer[i] = High[i] + ArrowsDistance * Gap;
}
if (AlertsOn)
{
if (AlertsOnCurrent)
WhichBar = 0;
else WhichBar = 1;
if (TrendBuffer[WhichBar] != TrendBuffer[WhichBar+1])
if (TrendBuffer[WhichBar] == 1)
doAlert("uptrend");
else doAlert("downtrend");
}
return(0);
}
// CUSTOM FUNCTIONS -------------------------void doAlert(string doWhat)
{
staticstring previousAlert="nothing";
staticdatetime previousTime;
string message;
if (previousAlert != doWhat || previousTime != Time[0]) {
previousAlert = doWhat;
previousTime = Time[0];
message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," Span ma cross ", doWhat);
if (AlertsMessage) Alert(message);
if (AlertsEmail) SendMail(StringConcatenate(Symbol()," Span ma cross "), message);
if (AlertsSound) PlaySound(SoundFile);
}
}
Mladen just finished my customization in the previous indicator you modified. What's wrong in this code? It does not display nothing...No errors when compiled.
thefxpros
Try it like this
#property version"1.00"#property strict#property indicator_chart_window#property indicator_buffers4#property indicator_color1 Gold
#property indicator_color2 DodgerBlue
#property indicator_color3 LimeGreen
#property indicator_color4 Crimson
#property indicator_width1 2#property indicator_width2 2#property indicator_width3 2#property indicator_width4 2externstring NOTE1 = "SELECT PARAMETERS OF THE INDICATOR"; //SPAN MA CROSS PARAMSexternint SpanPeriod = 1; // Period of Spanexternint SpanShift = -26; // Shift of SpanexternENUM_MA_METHOD SpanMode = 1; // Mode of SpanexternENUM_APPLIED_PRICE SpanPrice = 0; // Applied price of Spanexternint MaPeriod = 55; // Period of Moving averageexternint MaShift = 0; // Shift of Moving averageexternENUM_MA_METHOD MaMode = 1; // Mode of Moving averageexternENUM_APPLIED_PRICE MaPrice = 0; // Applied price of Moving averageexternstring NOTE2 = "SELECT COLORS/STYLES OF THE INDICATOR"; //SPAN MA CROSS COLORS/STYLESexterncolor SpanClr = Gold; // Span colorexternint SpanWdt = 2; // Span widthexternENUM_LINE_STYLE SpanStl = 0; // Span line styleexterncolor MaClr = DodgerBlue; // Moving average colorexternint MaWdt = 2; // Moving average widthexternENUM_LINE_STYLE MaStl = 0; // Moving average line styleexternstring NOTE3 = "SELECT PARAMETERS OF THE SIGNAL ARROWS"; //SPAN MA CROSS PARAMETERS OF THE SIGNAL ARROWSexternbool DrawArrows = true; // Draw signal arrows?externbool DrawMaLines = true; // Draw lines?externcolor UpArrowClr = LimeGreen; // Up arrow colorexternint UpArrowWdt = 2; // Up arrow widthexterncolor DnArrowClr = Crimson; // Down arrow colorexternint DnArrowWdt = 2; // Down arrow widthexternint ArrowsDistance = 10; // Arrows distance from candleexternstring NOTE4 = "SELECT PARAMETERS OF THE ALERT"; //SPAN MA CROSS PARAMETERS OF THE ALERTexternbool AlertsOn = true; // Active alert?externbool AlertsOnCurrent = true; // Alert on current unclosed barexternbool AlertsMessage = true; // Alert messageexternbool AlertsSound = true; // Alert soundexternbool AlertsEmail = false; // Alert e-mailexternstring SoundFile = "alert2.wav"; // Filename of sound alertstring IndicatorFileName;
int WhichBar;
double Gap;
double SpanBuffer[]; // Buffer of the Spandouble MaBuffer[]; // Buffer of the Moving averagedouble CrossUpBuffer[]; // Up arrow bufferdouble CrossDnBuffer[]; // Down arrow bufferdouble TrendBuffer[]; // Span/Ma cross bufferint init()
{
IndicatorFileName = WindowExpertName();
IndicatorBuffers(5);
SetIndexBuffer(0, SpanBuffer);
SetIndexBuffer(1, MaBuffer);
SetIndexBuffer(2, CrossUpBuffer);
SetIndexBuffer(3, CrossDnBuffer);
SetIndexBuffer(4, TrendBuffer);
if (DrawMaLines) {
SetIndexStyle (0, DRAW_LINE, SpanStl, SpanWdt, SpanClr);
SetIndexStyle (1, DRAW_LINE, MaStl, MaWdt, MaClr);}
else {
SetIndexStyle(0, DRAW_NONE);
SetIndexStyle(1, DRAW_NONE);}
if (DrawArrows) {
SetIndexStyle (2, DRAW_ARROW, 0, UpArrowWdt, UpArrowClr); SetIndexArrow(0, 233);
SetIndexStyle (3, DRAW_ARROW, 0, DnArrowWdt, DnArrowClr); SetIndexArrow(0, 234);}
else {
SetIndexStyle(2, DRAW_NONE);
SetIndexStyle(3, DRAW_NONE);}
return(0);}
int deinit() { return(0); }
int start() {
int counted_bars = IndicatorCounted();
int i, limit;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit = MathMin(Bars-counted_bars, Bars-1);
for(i=limit; i>=0; i--){
SpanBuffer[i] = iMA(NULL, 0, SpanPeriod, SpanShift, SpanMode, SpanPrice, i);
MaBuffer[i] = iMA(NULL, 0, MaPeriod, MaShift, MaMode, MaPrice, i);
Gap = iATR(NULL,0,20,i);
if (i<Bars-1) TrendBuffer[i] = TrendBuffer[i+1];
if (SpanBuffer[i] > MaBuffer[i]) TrendBuffer[i] = 1;
if (SpanBuffer[i] < MaBuffer[i]) TrendBuffer[i] =-1;
CrossUpBuffer[i] = EMPTY_VALUE;
CrossDnBuffer[i] = EMPTY_VALUE;
if (i<Bars-1 && TrendBuffer[i]!= TrendBuffer[i+1])
if (TrendBuffer[i] == 1)
CrossUpBuffer[i] = Low[i] - ArrowsDistance * Gap;
else CrossDnBuffer[i] = High[i] + ArrowsDistance * Gap;
}
if (AlertsOn)
{
if (AlertsOnCurrent)
WhichBar = 0;
else WhichBar = 1;
if (TrendBuffer[WhichBar] != TrendBuffer[WhichBar+1])
if (TrendBuffer[WhichBar] == 1)
doAlert("uptrend");
else doAlert("downtrend");
}
return(0);
}
// CUSTOM FUNCTIONS -------------------------void doAlert(string doWhat)
{
staticstring previousAlert="nothing";
staticdatetime previousTime;
string message;
if (previousAlert != doWhat || previousTime != Time[0]) {
previousAlert = doWhat;
previousTime = Time[0];
message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," Span ma cross ", doWhat);
if (AlertsMessage) Alert(message);
if (AlertsEmail) SendMail(StringConcatenate(Symbol()," Span ma cross "), message);
if (AlertsSound) PlaySound(SoundFile);
}
}
Tried Mladen and it seems working but in the strategy tester it doesn't refresh itself and doesn't pop up the alert, when market will open i will try in real market. thanks
Hi mladen,
Could you please help me with this. I have tried some combinations and different things, but can't figure out how to do this. Thanks!
Simon
The conditions should be more refined. For example : when both are signaling the same is very often. So, when exactly should they do that. On the first occurrence of that? On every occurrence of that? Also, if you are exiting on ever change of one of the two, the exits are going to be very frequent
Simon
The conditions should be more refined. For example : when both are signaling the same is very often. So, when exactly should they do that. On the first occurrence of that? On every occurrence of that? Also, if you are exiting on ever change of one of the two, the exits are going to be very frequent
Thanks for reply! Yes, this might not be a good strategy. It's just that if I get this as a template I can probably do some changes by myself later. What I want is the possibility to combine two indicators (and the use of their buffers).
Lets say the strategy instead should be: buy when both indicators indicate. And sell when both indicators indicate. It should happen after indicator change and closed bar. It should happen on every occurrence of that.
All the best!
Dear mladen,
I have an issue with the attached indicator:
when the indi is applied during the EA execution ( the standard moving average in MT4 ) the values are very different to the values wich are displayed applying the same indicator at the end of the EA execution.
Could you please explain why and if feasible correct the indi ?
Mr mladen ,
I am doing some change for the ma ribbon filled to ma channel but I have problem with the buffer .
Is that any way can hide the channel behind the histogram or make for the blank between the channel ?
I try to blank it but only can do it on one side , is that need to adding one more buffer ?
And one more problem is at line 44 , i cant extern or delete it .
it always have error come out .
Please give me some advise , thank you .
Steven .
Mr mladen ,
I am doing some change for the ma ribbon filled to ma channel but I have problem with the buffer .
Is that any way can hide the channel behind the histogram or make for the blank between the channel ?
I try to blank it but only can do it on one side , is that need to adding one more buffer ?
And one more problem is at line 44 , i cant extern or delete it .
it always have error come out .
Please give me some advise , thank you .
Steven .
I am not sure if this is what you are trying to do, but try it out
I am not sure if this is what you are trying to do, but try it out
YES , exactly what i want :D
But can you help me to check the code on line 44 'AlertOnClosedCandle' , why it cant delete or extern bool ?
This is my first time having this type of problem .
Any way i have learn some things on the buffer .
Thank you .
Mladen just finished my customization in the previous indicator you modified. What's wrong in this code? It does not display nothing...No errors when compiled.
Mladen just finished my customization in the previous indicator you modified. What's wrong in this code? It does not display nothing...No errors when compiled.
thefxpros
Try it like this
Correction :
Change lines 74 and 75 of sigma from this :
to this :
And it should work
Or remove the strict statement completely (since that indicator needs a complete rewrite if it is going to be used with the "strict")
Dear mladen,
I've tried both suggestions without succes but I've realized that the indi does't update when running in a EA as in the following picture.
Should be possible to fix it ?
:
thefxpros
Try it like this