MQL4 Learning - page 66

 

Money Management

In a scalp system the money manegement is more dificult, right?

 

MAE_MFE_DrawDowns.mqh

Any idea?...please help me.

 
Start function not found and cannot be run.

The warning given above seems pretty self explanatory. There's no start function so the code can't run. It looks like the code is incomplete.

Actually if you change the function name startCalculations to just start the script will compile but then you open up a whole new can of worms.

Good luck!

Lux

 

MAE/MFE calculation

luxinterior:

Realy thanks...=)

 

HELP: Need to code for trailing stops for multiple open orders

This is my first post in the forum. If it's the wrong place, my apologies and I assume it'll get moved as appropriate. I'm looking for some sound help from you smart folks out there.

I've just started coding an EA that places pending orders on the close of a bar based on various criteria. I was using a trailing stop based on the high/low of a previous bar that is updated at the close of each subsequent bar if the trade is opened and continues in the appropriate direction, e.g. trailing lows of previous bars for a long. This was a basic approach as I started learning MQL4.

What I've noticed is that a trade may go x pips or so in the right direction, but then reverse. By the time the bar has closed for a buy, the close price is below the entry price of the previous bar. Price then continues south and hits my stop.

What I would like to introduce is a function to move my SL to break even intra timeframe, so I'm reading each tick and deciding whether to update the SL on any open orders. I may have multiple open orders at different entry prices, so I need to track the different entry prices and move the SL at a different time. I'd like the ability to move SL to break even and also trail price by x pips if selected.

I've trawled around the forums but haven't found any specific code that addresses what I'm after. I've found some snippets of good MQL info, but not what I'm looking for.

I don't think I want to select all open orders on each tick and check prices. Would it be more efficient to read open orders once, move ticket number and price into an array, and then check each incoming tick price against the prices in the array and then issue a MODIFY order for a ticket when price reaches that defined profit? One further complication: new orders may get opened during a timeframe, so it can be necessary to refresh that list or could this be achieved by writing pending order prices to the array?

Anyone done this? Anyone understand this? Is it complicated? Can anyone offer code or advice? Should I perhaps change my entire EA to read each tick and then perform the appropriate actions - more CPU overhead reading each tick? And, could anyone offer a really good source with good examples for improving my understanding of MQL4?

Thanks for any input.

 
fxtradera:
This is my first post in the forum. If it's the wrong place, my apologies and I assume it'll get moved as appropriate. I'm looking for some sound help from you smart folks out there.

I've just started coding an EA that places pending orders on the close of a bar based on various criteria. I was using a trailing stop based on the high/low of a previous bar that is updated at the close of each subsequent bar if the trade is opened and continues in the appropriate direction, e.g. trailing lows of previous bars for a long. This was a basic approach as I started learning MQL4.

What I've noticed is that a trade may go x pips or so in the right direction, but then reverse. By the time the bar has closed for a buy, the close price is below the entry price of the previous bar. Price then continues south and hits my stop.

What I would like to introduce is a function to move my SL to break even intra timeframe, so I'm reading each tick and deciding whether to update the SL on any open orders. I may have multiple open orders at different entry prices, so I need to track the different entry prices and move the SL at a different time. I'd like the ability to move SL to break even and also trail price by x pips if selected.

I've trawled around the forums but haven't found any specific code that addresses what I'm after. I've found some snippets of good MQL info, but not what I'm looking for.

I don't think I want to select all open orders on each tick and check prices. Would it be more efficient to read open orders once, move ticket number and price into an array, and then check each incoming tick price against the prices in the array and then issue a MODIFY order for a ticket when price reaches that defined profit? One further complication: new orders may get opened during a timeframe, so it can be necessary to refresh that list or could this be achieved by writing pending order prices to the array?

Anyone done this? Anyone understand this? Is it complicated? Can anyone offer code or advice? Should I perhaps change my entire EA to read each tick and then perform the appropriate actions - more CPU overhead reading each tick? And, could anyone offer a really good source with good examples for improving my understanding of MQL4?

Thanks for any input.

Also, take look to this post: https://www.mql5.com/en/forum/173393

 

Deposit & withdraw..

hi all..

please tell me have any function for return total deposit and total withdraw in account?

thanks

 
DooMGuarD:
hi all..

please tell me have any function for return total deposit and total withdraw in account?

thanks

Actually, not, but if you try to look for orders with OrderType()==6 in History you will find deposits and withdraws.

 

Most simple indicator(s) needed.

Hi, I need two extremely simple indicators.

One is simply the current time, not displayed on screen just reported to an EA/data window.

The other is just the current price, again reported to an EA.

Why would I want these? It would allow me to make better use of: Expert Advisor Builder for MetaTrader 4

As I can easily substitute one icustom indicator for another, this allows me to use time and current price in the EA's logic.

Thank you very much.

 

hi all

hi all

how i initialize a double value 1.7*e-107 in a variable definition;

double MyVar = ????;

regards

Reason: