MQL4 Learning - page 90

 

Thank you Jan100

 

..........

............

Thank you all very much

 

Small programming problem

Hi there I just wanted to know ,

I am using an indicator that returns a % e.g 70%

and this does not seem to work when I say if indicator

says 70% then open trade ,

but I know it will work if I remove the % sign ...

but how can this be done ?

Thanks Alot !

 

I am willing to look at your indicator and EA code to find out what the problem is. Send to:

mql4coder@gmail.com

I will let you know what I find.

 

You are stating that stochk0 is equal to stochk10 in this statement, iStochastic is using the same settings in both instances:

double stochk0 = iStochastic(Symbol(), Period(), Stoch_K,Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_MAIN, i);

double stochk2 = iStochastic(Symbol(), Period(), Stoch_K,Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_MAIN, i+1);

double stochk10 = iStochastic(Symbol(), Period(), Stoch_K,Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_MAIN, i);

double stochk12 = iStochastic(Symbol(), Period(), Stoch_K,Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_MAIN, i+1);

I'm having trouble getting the cross-overs to work:

STOCHMain = iStochastic(NULL,0,8,5,3,0,0, MODE_MAIN, i);

STOCHSignal = iStochastic(NULL,0,8,5,3,0,0, MODE_SIGNAL, i);

if(STOCHMain >= STOCHSignal) Buy();

if(STOCHMain < STOCHSignal) CloseTrade();

It seems to randomly buy and close trades.

 

Small Fix for EA

Okay guys thanks for all the help thus far !...

I have almost complete my EA but one more problemo or feature that I think is a good idea to have in an EA

The Idea :

When In a specific trend in my EAs scalping mode ,

when you look at the tick chart data ,

you will see it will generally move in that trend direction

(Dont worry about giving the trend direction indication i have already done this.),

but to get the best entry possible you would wait for a counter trend tick or two to occur so this your order will be placed and you will have a little extra profit when it gets back into trend...Usually 2-5 pips Extra... Small but can get rid of damn spreads easily...It would be nice if this counter trend value can also be designed so that you can edit the amount of how much the counter ticks must be...

another note is that we will have to create the order to have a "pending" function so once the order is pending , it must wait for however many counter trend ticks and then insert the order...

any Idea how we can get this into code?

Hope you get the idea I'm trying as hard as I can to put it into words ha ha

Thanks a lot guys...

Will post the EA up soon soon for you to try if you wish , it is looking insanely promising so far as it has a vast range of features.

cheers!

 

use moving average

rule :

buy if price < MA

sell if price > MA

MA periode ... 12 or 16

 

SL management code help

Hi guys,

I have written a piece of code to manage my EA open orders but part of it is not executing (when in loss part). Can someone help?

Here is the code (sorry, it's not nice to read it here but I don't know other way to post it):

//stop loss management

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

{

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL && // check for opened position

OrderSymbol()==Symbol()) // check for symbol

{

if (OrderLots() == Lots) //Prevent closing multiple times

{

if(OrderType()==OP_BUY) // long position is opened

{

// Move Stop

if (Bid - OrderOpenPrice () >= TakeProfitPartial * Point)

//if(true)

{

OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice() + 30 * Point,OrderTakeProfit()*Point,0,Purple);//

OrderClose (OrderTicket(), LotsPartial, Bid, 30 /*Slippage*/, Yellow);

////// to close part if in loss and move take profit to b/e --NOT WORKING

if(Bid - OrderOpenPrice () <= - (TakeProfitPartial * Point))

{

OrderModify(OrderTicket(),OrderOpenPrice(),StopLossLevel,OrderOpenPrice() +30*Point,0,Purple);//

OrderClose (OrderTicket(), LotsPartial, Bid, 30 /*Slippage*/, Yellow);

return(0);

}

}

}

else // go to short position

{

// Move Stop

if (OrderOpenPrice() - Ask >= TakeProfitPartial * Point)

//if(true)

{

OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice() - 30 * Point,OrderTakeProfit()*Point,0,Purple);/////

OrderClose (OrderTicket(), LotsPartial, Ask, 30 /*Slippage*/, Yellow);

////// to close part if in loss and move take profit to b/e --NOT WORKING

if(OrderOpenPrice() - Ask <= - (TakeProfitPartial * Point))

{

OrderModify(OrderTicket(),OrderOpenPrice(),StopLossLevel,OrderOpenPrice()-30 *Point,0,Purple);/////

OrderClose (OrderTicket(), LotsPartial, Ask, 30 /*Slippage*/, Yellow);

return(0);

}

}

}

}

}

}

 

SL management code help

It's ok. I fixed it.

Cheers!

 

Help! How to sort a two dimension array

I am using a two dimension array, say, ZigZag[2][100]. and I want to sort by the first dimension. I use the following function:

ArraySort(ZigZag,WHOLE_ARRAY,0,MODE_DESCEND);

but it seem neither sort by first dimention, nor by second dimension. is there anybody here can help me?

Thanks a lot

Reason: