Ask! - page 155

 

help to code SL and TP

Hey guys,

I have a problem with an ea that I trying to use on a live ac with fxcm bt,

the problem is they won't allow the sl and tp to be placed with the market order,

so I need to get a code to somhow delay this by a few seconds,

any help on this would be most appricated

thankyou in advance

Files:
 
mallet52:
Hey guys,

I have a problem with an ea that I trying to use on a live ac with fxcm bt,

the problem is they won't allow the sl and tp to be placed with the market order,

so I need to get a code to somhow delay this by a few seconds,

any help on this would be most appricated

thankyou in advance

You can use the "sleep" function between each ordersend's or ordermodify's. For example:

Sleep(5000);

Thats a 5 seconds delay ( the sleep parameter is in miliseconds).

Regards,

Marcel.

 

ADX and MACD CrossOver

Senior members can anyone write a code for a crossover of the MACD and the ADX on a seperate window and and it crossover to place a dotted vertical line when it does. Hopefully, say a green one on the buy and a red for the sell. Also, an audible alert when it does.

Thanks so much.

 

help needed to code delay for SL and TP

Hey guys,

I still haveing trouble getting my ea to work with fxcm bt,they tell me that I have a problem with the ea placing sl ant tp at the same time it puts in a market order,

Mladen kindly recoded this ea for so it would accept the 5 digit pricing and now this problem came up,

It would be great if somone could code the delay in to the ea that is needed for me,or explain it in great detail ( as I have no knowalge on how to code) and I will have a go at it myself, so I don't have to keep bothering everyone else.

thankyou in advance

and to all those who have helped me in the past

 

here is my ea that I forgot to add in last post

Files:
 

...

The way it has to be coded is not to use the delay (delay will not help in cases like these) but to break apart new order placement into two parts :
1. Placing orders without stop loss and/or take profit

2. Placing stop loss and/or take profit in separate step (when and only when an order is already accepted)

__________________________________

Now, Phoenix EA is doing that operation on 10 separate places and all of them would need to be rewritten (or the logic of the EA placing orders should be rewritten in order to be able to control potential errors strictly, and so on, and so on...) Right now I do not have the time to do the complete rewriting (it would require more time in order to do it right), so I can not promise you that I will do that .

regards

mladen

mallet52:
Hey guys,

I still haveing trouble getting my ea to work with fxcm bt,they tell me that I have a problem with the ea placing sl ant tp at the same time it puts in a market order,

Mladen kindly recoded this ea for so it would accept the 5 digit pricing and now this problem came up,

It would be great if somone could code the delay in to the ea that is needed for me,or explain it in great detail ( as I have no knowalge on how to code) and I will have a go at it myself, so I don't have to keep bothering everyone else.

thankyou in advance

and to all those who have helped me in the past

 

Original Mov. Ave to be placed in seperate window

I tried to change the one line of original code for the Moving Average that comes with MetaTrader 4 and place it in a seperate window but when I do it does not show all the options that I would like to have that comes with the original code i.e. like [ Ma method 'simple'] and apply to 'close' or open etc...

What am I doing wrong?

Thanks so much.

 

...

You are not doing anything wrong

Metatrader, for now (it is going to be changed in version 5) does not allow those "descriptive" parameter entries in custom indicators (so, the non-built-in indicators).

newcoder:
I tried to change the one line of original code for the Moving Average that comes with MetaTrader 4 and place it in a seperate window but when I do it does not show all the options that I would like to have that comes with the original code i.e. like [ Ma method 'simple'] and apply to 'close' or open etc...

What am I doing wrong?

Thanks so much.
 

Quick thankyou to mladen

Thankyou for helping me out mladen,your help is much apricated,

I tried sending you a pm but can't for some reason

anyway, thanks again

 

Custom Indicator Alert Frequency

I am new to mq4 and i am trying to create a display on screen when there is a crossover for my custom MACDs. Below is my code but the alerts keep poping up every few minutes.

How can i code it to display alerts only once every hour? Or one alert per bar?

//--------------------------

int start()

{

string MACD1="";

color colt9;

double MACDM_S10 = iCustom(NULL, PERIOD_H1, "MACD", 8,17,9, MODE_MAIN, 0);

double MACDS_S10 = iCustom(NULL, PERIOD_H1, "MACD", 8,17,9, MODE_SIGNAL,0);

double MACDM_S11 = iCustom(NULL, PERIOD_H1, "MACD", 8,17,9, MODE_MAIN, 1);

double MACDS_S11 = iCustom(NULL, PERIOD_H1, "MACD", 8,17,9, MODE_SIGNAL,1);

if ((MACDM_S11 < MACDS_S11 && MACDM_S10 < MACDS_S10)) { MACD1="IN UPTREND"; colt9=LimeGreen; }

if ((MACDM_S11 > MACDS_S11 && MACDM_S10 > MACDS_S10)) { MACD1="IN DOWNTREND"; colt9=Red; }

if ((MACDM_S11 > MACDS_S11 && MACDM_S10 < MACDS_S10)) { MACD1="NEW UP CROSSING"; colt9=LimeGreen; }

if ((MACDM_S11 MACDS_S10)) { MACD1="NEW DOWN CROSSING"; colt9=Red; }

string MACD2="";

color colt14;

double MACDM_L10 = iCustom(NULL, PERIOD_H1, "MACD", 12,26,9, MODE_MAIN, 0);

double MACDS_L10 = iCustom(NULL, PERIOD_H1, "MACD", 12,26,9, MODE_SIGNAL,0);

double MACDM_L11 = iCustom(NULL, PERIOD_H1, "MACD", 12,26,9, MODE_MAIN, 1);

double MACDS_L11 = iCustom(NULL, PERIOD_H1, "MACD", 12,26,9, MODE_SIGNAL,1);

if ((MACDM_L11 < MACDS_L11 && MACDM_L10 < MACDS_L10)) { MACD2="IN UPTREND"; colt14=LimeGreen; }

if ((MACDM_L11 > MACDS_L11 && MACDM_L10 > MACDS_L10)) { MACD2="IN DOWNTREND"; colt14=Red; }

if ((MACDM_L11 > MACDS_L11 && MACDM_L10 < MACDS_L10)) { MACD2="NEW UP CROSSING"; colt14=LimeGreen; }

if ((MACDM_L11 MACDS_L10)) { MACD2="NEW DOWN CROSSING"; colt14=Red; }

if(MACD1=="NEW UP CROSSING"&&MACD2=="IN UPTREND")

Alert(Symbol()," - ","H1:"," MACD MAIN UPTREND MOVEMENT"," at ", Bid, " - ",TimeToStr(CurTime(),TIME_SECONDS));

if(MACD1=="NEW DOWN CROSSING"&&MACD2=="IN DOWNTREND")

Alert(Symbol()," - ","H1:"," MACD MAIN DOWNTREND MOVEMENT"," at ", Bid, " - ",TimeToStr(CurTime(),TIME_SECONDS));

if(MACD2=="NEW UP CROSSING"&&MACD1=="IN UPTREND")

Alert(Symbol()," - ","H1:"," MACD, MAIN TREND CHANGE TO UPTREND"," at ", Bid, " - ",TimeToStr(CurTime(),TIME_SECONDS));

if(MACD2=="NEW DOWN CROSSING"&&MACD1=="IN DOWNTREND")

Alert(Symbol()," - ","H1:"," MACD, MAIN TREND CHANGE TO DOWNTREND"," at ", Bid, " - ",TimeToStr(CurTime(),TIME_SECONDS));

return(0);

}

Reason: