Coding help - page 509

 
tfi_markets:
Hi Pro-Coders,

I get the warning: "check operator precedence for possible error; use parentheses to clarify precedence"

if ((STC115)||(STC185)&&(Ask>emaFilter && ADXmain>25))

{

OpenBuy();

}

It looks like the ..AND (Ask>emaFilter) statement gets also ignored by MT4.

Could someone please advise?

Thank you in advance!

you probably should write it like this :

if (((STC115) || (STC185)) && (Ask>emaFilter && ADXmain>25) )

But it mainly depends on what exactly you want to test. The warning comes because before the precedence of && (and) and || (or) was different - they inverted it and now all those logical comparisons must be checked

 
mladen:
you probably should write it like this :

if (((STC115) || (STC185)) && (Ask>emaFilter && ADXmain>25) )

But it mainly depends on what exactly you want to test. The warning comes because before the precedence of && (and) and || (or) was different - they inverted it and now all those logical comparisons must be checked

Hi Mladen,

thank you very much for your suggestion. I will try it out! You are always very helpful!

In simple words spoken, all three parentheses should become true before the EA opens a trade.

I guess your code will provide this functionality.

Kind regards,

T.

 

Coders,

Could someone help me with the following?

I'm using an Elliot wave script to manually label the waves. The script places 8 different objects on the chart (i,ii,iii,iv,v,a,b,c).

Everything works fine, but deleting the objects is a lot work. Because I have to click on every object(i,ii,iii,iv,v,a,b,c), to delete them. I would like to add something to the code which makes me able to highlight all objects (i,ii,iii,iv,v,a,b,c) with just one click on the objects. I've already searched but I couldn't find the function I need.

(I'm not looking for a script who deletes all objects on the chart. )

Thanks in advance

//+------------------------------------------------------------------+//| wave labels ff.mq4 |

//+------------------------------------------------------------------+

#property version "1.00"

#property strict

#include

//+------------------------------------------------------------------+

//| Script program start function |

//+------------------------------------------------------------------+

extern string Text1 = "(i)"; // Enter Text to place on screen

extern string Text2 = "(ii)"; // Enter Text to place on screen

extern string Text3 = "(iii)"; // Enter Text to place on screen

extern string Text4 = "(iv)"; // Enter Text to place on screen

extern string Text5 = "(v)"; // Enter Text to place on screen

extern string Text6 = "(a)"; // Enter Text to place on screen

extern string Text7 = "(b)"; // Enter Text to place on screen

extern string Text8 = "(c)"; // Enter Text to place on screen

extern string Text_font="Arial Bold"; // font of text

extern int Text_fontsize = 14; // size of text

extern color Text_color = Red; // color of text

int TextBarsAhead2 = 7; // # bars to space 2nd letter from first

int TextBarsAhead3 = 14; // # bars to space 3rd letter from first

int TextBarsAhead4 = 21; // # bars to space 4th letter from first

int TextBarsAhead5 = 28; // # bars to space 5th letter from first

int TextBarsAhead6 = 35; // # bars to space 6th letter from first

int TextBarsAhead7 = 42; // # bars to space 7th letter from first

int TextBarsAhead8 = 49; // # bars to space 8th letter from first

//+------------------------------------------------------------------+

//+-----------------------------SCRIPT CODE--------------------------+

int OnStart(){

double price = WindowPriceOnDropped(); // find the price point where dropped

datetime Time1 = WindowTimeOnDropped(); // find the time point where dropped

datetime TimeNow = TimeCurrent(); // get the current time ( makes name unique)

datetime Time2 = (int)Time1+TextBarsAhead2*(int)Period()*60;

datetime Time3 = (int)Time1+TextBarsAhead3*(int)Period()*60;

datetime Time4 = (int)Time1+TextBarsAhead4*(int)Period()*60;

datetime Time5 = (int)Time1+TextBarsAhead5*(int)Period()*60;

datetime Time6 = (int)Time1+TextBarsAhead6*(int)Period()*60;

datetime Time7 = (int)Time1+TextBarsAhead7*(int)Period()*60;

datetime Time8 = (int)Time1+TextBarsAhead8*(int)Period()*60;

string gap=" "; // spacing between text characters

string text=Text1+gap+Text2+gap+Text3+gap+Text4+gap+Text5; // put the text in a line

TextToPrint ("Wave labels 1 " + (string)TimeNow, Text1, Text_fontsize, Text_font, Text_color, Time1, price); //print 1st letter

TextToPrint ("Wave labels 2 " + (string)TimeNow, Text2, Text_fontsize, Text_font, Text_color, Time2, price); //print 1st letter

TextToPrint ("Wave labels 3 " + (string)TimeNow, Text3, Text_fontsize, Text_font, Text_color, Time3, price); //print 1st letter

TextToPrint ("Wave labels 4 " + (string)TimeNow, Text4, Text_fontsize, Text_font, Text_color, Time4, price); //print 1st letter

TextToPrint ("Wave labels 5 " + (string)TimeNow, Text5, Text_fontsize, Text_font, Text_color, Time5, price); //print 1st letter

TextToPrint ("Wave labels 6 " + (string)TimeNow, Text6, Text_fontsize, Text_font, Text_color, Time6, price); //print 1st letter

TextToPrint ("Wave labels 7 " + (string)TimeNow, Text7, Text_fontsize, Text_font, Text_color, Time7, price); //print 1st letter

TextToPrint ("Wave labels 8 " + (string)TimeNow, Text8, Text_fontsize, Text_font, Text_color, Time8, price); //print 1st letter

return(0);

}

//+------------------------------------------------------------------+

void TextToPrint(string TextName,string LabelText,int FontSize,string FontName,color TextColor,datetime Time0,double Price0)

{

if(StringLen(LabelText)>1){

ObjectCreate(TextName,OBJ_TEXT,0,Time0,Price0);

ObjectSetText(TextName,LabelText,FontSize,FontName,TextColor);

}

}

//+------------------------------------------------------------------+
 
xtractalpha:
Coders,

Could someone help me with the following?

I'm using an Elliot wave script to manually label the waves. The script places 8 different objects on the chart (i,ii,iii,iv,v,a,b,c).

Everything works fine, but deleting the objects is a lot work. Because I have to click on every object(i,ii,iii,iv,v,a,b,c), to delete them. I would like to add something to the code which makes me able to highlight all objects (i,ii,iii,iv,v,a,b,c) with just one click on the objects. I've already searched but I couldn't find the function I need.

(I'm not looking for a script who deletes all objects on the chart. )

Thanks in advance

//+------------------------------------------------------------------+//| wave labels ff.mq4 |

//+------------------------------------------------------------------+

#property version "1.00"

#property strict

#include

//+------------------------------------------------------------------+

//| Script program start function |

//+------------------------------------------------------------------+

extern string Text1 = "(i)"; // Enter Text to place on screen

extern string Text2 = "(ii)"; // Enter Text to place on screen

extern string Text3 = "(iii)"; // Enter Text to place on screen

extern string Text4 = "(iv)"; // Enter Text to place on screen

extern string Text5 = "(v)"; // Enter Text to place on screen

extern string Text6 = "(a)"; // Enter Text to place on screen

extern string Text7 = "(b)"; // Enter Text to place on screen

extern string Text8 = "(c)"; // Enter Text to place on screen

extern string Text_font="Arial Bold"; // font of text

extern int Text_fontsize = 14; // size of text

extern color Text_color = Red; // color of text

int TextBarsAhead2 = 7; // # bars to space 2nd letter from first

int TextBarsAhead3 = 14; // # bars to space 3rd letter from first

int TextBarsAhead4 = 21; // # bars to space 4th letter from first

int TextBarsAhead5 = 28; // # bars to space 5th letter from first

int TextBarsAhead6 = 35; // # bars to space 6th letter from first

int TextBarsAhead7 = 42; // # bars to space 7th letter from first

int TextBarsAhead8 = 49; // # bars to space 8th letter from first

//+------------------------------------------------------------------+

//+-----------------------------SCRIPT CODE--------------------------+

int OnStart(){

double price = WindowPriceOnDropped(); // find the price point where dropped

datetime Time1 = WindowTimeOnDropped(); // find the time point where dropped

datetime TimeNow = TimeCurrent(); // get the current time ( makes name unique)

datetime Time2 = (int)Time1+TextBarsAhead2*(int)Period()*60;

datetime Time3 = (int)Time1+TextBarsAhead3*(int)Period()*60;

datetime Time4 = (int)Time1+TextBarsAhead4*(int)Period()*60;

datetime Time5 = (int)Time1+TextBarsAhead5*(int)Period()*60;

datetime Time6 = (int)Time1+TextBarsAhead6*(int)Period()*60;

datetime Time7 = (int)Time1+TextBarsAhead7*(int)Period()*60;

datetime Time8 = (int)Time1+TextBarsAhead8*(int)Period()*60;

string gap=" "; // spacing between text characters

string text=Text1+gap+Text2+gap+Text3+gap+Text4+gap+Text5; // put the text in a line

TextToPrint ("Wave labels 1 " + (string)TimeNow, Text1, Text_fontsize, Text_font, Text_color, Time1, price); //print 1st letter

TextToPrint ("Wave labels 2 " + (string)TimeNow, Text2, Text_fontsize, Text_font, Text_color, Time2, price); //print 1st letter

TextToPrint ("Wave labels 3 " + (string)TimeNow, Text3, Text_fontsize, Text_font, Text_color, Time3, price); //print 1st letter

TextToPrint ("Wave labels 4 " + (string)TimeNow, Text4, Text_fontsize, Text_font, Text_color, Time4, price); //print 1st letter

TextToPrint ("Wave labels 5 " + (string)TimeNow, Text5, Text_fontsize, Text_font, Text_color, Time5, price); //print 1st letter

TextToPrint ("Wave labels 6 " + (string)TimeNow, Text6, Text_fontsize, Text_font, Text_color, Time6, price); //print 1st letter

TextToPrint ("Wave labels 7 " + (string)TimeNow, Text7, Text_fontsize, Text_font, Text_color, Time7, price); //print 1st letter

TextToPrint ("Wave labels 8 " + (string)TimeNow, Text8, Text_fontsize, Text_font, Text_color, Time8, price); //print 1st letter

return(0);

}

//+------------------------------------------------------------------+

void TextToPrint(string TextName,string LabelText,int FontSize,string FontName,color TextColor,datetime Time0,double Price0)

{

if(StringLen(LabelText)>1){

ObjectCreate(TextName,OBJ_TEXT,0,Time0,Price0);

ObjectSetText(TextName,LabelText,FontSize,FontName,TextColor);

}

}

//+------------------------------------------------------------------+

xtractalpha

In the deinit() procedure add clean up part

In your case it would be ObjectDelete(objectName) for each object that your code have created

 

Hello Mladen

Could you assist with the compile errors in the below

Files:
 
candyman752:
Hello Mladen Could you assist with the compile errors in the below

Check it out now : genie_stoch_rsittt_1.mq4

Files:
 

Dear Mladen

Thanx for this great indy

Is possible histogram version???

 
SLAVOLJUB:
Dear Mladen

Thanx for this great indy

Is possible histogram version???

It is possible buy then the two signal lines must be completely ignored and cut out

 
mladen:
It is possible buy then the two signal lines must be completely ignored and cut out

No problem.... i need only this red-green line

(red green line as histogram)

Thanx in advance

 

Hello Mladen,

I added a code for trailing stop to the EA. I am getting two compile errors. The instructions on adding the code were:

How to use?

very simple. place below code in any part of your Expert Advisor program and call the functiontrail2(#ticket) in the Start() function.ticket = is your order ticket, it could be either buy or sell order. But it has to be live order not pending order.

e.g.

{...(yourcode)

ticket=ordersend(...)

...

}

..

trail2(ticket)

or trail2(ticket, 300, 40, 250, 100)

..

Files:
wip.mq4  8 kb
Reason: