How to code? - page 53

 

Try this..

Put

double ma_cross;[/CODE] as a global variable.

In the start function :

[CODE]

double ma1=NormalizeDouble(first_ma,Digits);

double ma2=NormalizeDouble(second_ma,Digits);

if(ma1=ma2)

{

ma_cross=ma1;

}

int spread=MarketInfo(Symbol(), MODE_SPREAD);

SLbuy=ma1+spread-SL*Point;

SLsell=ma1+SL*Point;

Hope this helps

 

Close/Open trades at inversed signal

I have a small problem here:

In my EA I have a BuyCondition and Sell Condition and a close order for inversed signals. To prevent opening and closing trades inside the same bar I have the following code:

if(OneEntryPerBar==true)

{

if(CheckEntryTime==iTime(NULL,PERIOD_H1,0)) return(0); else CheckEntryTime = iTime(NULL,PERIOD_H1,0);

}

All fine. But now if he finds a sell condition during an open buy trade, he closes the buy, which is OK. But he doesn't open the sell as the above code is preventing this.

Any idea on how to make him close and open inside 1 bar... but only once per bar?

I hope I make myself understood.

Thanks

 

Close and cancel at a certain time?

Can anyone help me with setting up EA that closes all open orders and cancels all pending order at a certain time, i.e., 5:15 a.m. UTC+1 ?

Is it also possible to specify not only the time but the date?

 
dxtrade:
I have a small problem here:

In my EA I have a BuyCondition and Sell Condition and a close order for inversed signals. To prevent opening and closing trades inside the same bar I have the following code:

if(OneEntryPerBar==true)

{

if(CheckEntryTime==iTime(NULL,PERIOD_H1,0)) return(0); else CheckEntryTime = iTime(NULL,PERIOD_H1,0);

}

All fine. But now if he finds a sell condition during an open buy trade, he closes the buy, which is OK. But he doesn't open the sell as the above code is preventing this.

Any idea on how to make him close and open inside 1 bar... but only once per bar?

I hope I make myself understood.

Thanks

it won't open cause of the code you use above.. until the next hour..

you can try this..

if (OrderOpenTime() >= iTime(NULL, PERIOD_H1, 0)) order++;

if (order < 1)

{

order conditions

}

hope that helps.. not an expert.. but this code won't stop from doing it more than once..

 

Help Me Ea

I Don't Speak English,I want to add Maxtrade And Risk Do you help me

Thankyou

Files:
zero.mq4  10 kb
 
wasanmyza:
I Don't Speak English,I want to add Maxtrade And Risk Do you help me Thankyou

Hi,

You have other issues with this EA. You are stating that you would like to make a buy or sell when VAR1, VAR2 or VAR3 has reached or exceeded certain values.

You must first define what is VAR1, 2 and 3? Some indicator with specific settings?

Thanks,

StrangeGuy

 

Take Profit, cancel all other orders

Does anyone know how to code once the open order hit profit target, the rest of the pending orders will be deleted? It is different from oco. I have checked the elite section, but nothing there.

 

question

I do not understand the difference of two programs, but would teach it?

int limit = Bars-IndicatorCounted();

int i ;

for( i=limit-1; i>=0; i--)

int counted_bars=IndicatorCounted();

//---- check for possible errors

if(counted_bars<0) return(-1);

//---- last counted bar will be recounted

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = 0; i <= limit; i++)

 
nakata79087:
I do not understand the difference of two programs, but would teach it?

int limit = Bars-IndicatorCounted();

int i ;

for( i=limit-1; i>=0; i--)

int counted_bars=IndicatorCounted();

//---- check for possible errors

if(counted_bars<0) return(-1);

//---- last counted bar will be recounted

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = 0; i <= limit; i++)

The most important difference is the direction of the "for" loop:

The first one scan the bars following the natural time, ie from the oldest to the newest bar.

The second one scan the bars in the opposite direction: it can work if the calcul of a bar doesn't involve the result of the previous bar;

In general it's better to use the same direction as the time: it always works and there are no possibilties of mistaken.

 

Thank you

thank you for your kind,Michel!!

I was troubled for a long time,why it start a different signature though two these are slight differences.