MQL4 Learning - page 59

 

sto and MA robot

I am looking for an EA that can test the following system

on H1 timeframe, if MA13 (moving average set to 13) goes above (crosses) MA120

and

stochastic 120 > 50 and

sto 15 > 60

then buy

if MA 13 goes below MA120 and

sto 120 >50

and sto 15 <20

then sell

with the parameters changeable

Best regards

 
promoteam:
I am looking for an EA that can test the following system

on H1 timeframe, if MA13 (moving average set to 13) goes above (crosses) MA120

and

stochastic 120 > 50 and

sto 15 > 60

then buy

if MA 13 goes below MA120 and

sto 120 >50

and sto 15 <20

then sell

with the parameters changeable

Best regards

I can code this for you, private message me.

 

Stop Loss Flips Order Type

I'm new to mql programming and hope this is the right area to post this.

I'm wondering if it's possible to program this capability into an EA:

Stop Loss and Trailing Stop triggers the opening of the Opposite order type. I mean... say I have an open Long position. The market drops and my SL or TS is hit and that order is closed (possibly in Loss). I'd like an EA that can instantly open a Short position to follow that brief trend to recover some of that Loss and/or possibly gain some good Profit.

Is this too complex to program? From my "newbie" point of view, all I can see is calling the account's trading History and searching for the last closed order to determine whether it was Long or Short, and then opening the opposite order type. But would that really be the best way to go for something like this or does anyone have a better idea maybe?

One of the problems I'm running into is that I have a few different EA's that I'm forwarding testing on this demo account so I'd need to be able to determine the last order type by a specific Magic Number if I have to search through the history.

Thanks!!!

 

Look at the "OrderSend" function. It returns the ticket number for that particular order when the order is successfully sent and opened (or pending). Use the order ticket as the unique id to search through history etc. Also, look into Global Variables, it'll be very handy as well, especially in terms of storing several order ticket ids and recalling them for future use.

 

Thanks! I'll check that out. I started studying and modifying the code found here: https://www.mql5.com/en/forum/177488

...but then got busy tweaking a bunch of other EA's during today's testing so had to put it aside. But hopefully I'll get back to this soon.

Thanks again!

 

Only 1 Order per Bar

New question for anyone: Does anyone know what code I can use to limit EA orders to one-per-bar? What I mean is:

I have some EA's working on the H1 timeframe of a few pairs. But every now and then, an EA will open an order, and then a little while later close it when it hits a Trailing Stop or Take Profit during that same bar. But then it will re-open that same order type because the trigger for opening the original order is still True. (One EA uses Heiken Ashi and Stochastic Oscillator, so it needs to be based on the comparison between the current bar and the previous bar - Shift0>Shift1 etc.)

Is there any way to make it leave the current bar alone once an order has been opened on the that bar, regardless of whether that order is still open or has been closed? I've seen code that prevents it from having multiple OPEN orders, but none that can stop it if the orders have already been closed.

The EA I mentioned does pretty good at opening profitable orders, but it just needs a better order closing system to lock in that profit. In fact it's one of 3 EA's I'm forward-testing that have this same problem so I'm hoping this kind of code does exist.

Thanks!

 

Mirroring code for usdx indicator

Can someone help me with the mirroring code

I want to put a mirroring , invert option on the usdx indicator

so it will line up better depending on what pair i put it on

like eurusd or usdchf where the dollar is opposite

Files:
 

Nevermind about my last question. I came up with the following code to find the order time of the most recent closed order. Now I can just use math to determine how long to wait on each timeframe to open orders. Thanks

string last;

int lastorderbar;

for(int h=0;h<OrdersHistoryTotal();h++)

{

OrderSelect(h, SELECT_BY_POS, MODE_HISTORY);

if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)

{

if(OrderType()==OP_BUY) {

last="Buy";

lastorderbar=OrderOpenTime();

}

if(OrderType()==OP_SELL) {

last="Sell";

lastorderbar=OrderOpenTime();

}

}

}
 

Suppress Journal and Expert Logging

I have this indicator that is called by an EA that keeps logging stuff in the logs of the Experts and Journal tabs and was wondering if I can turn that off in MT4 or if you now of a command that will stop the Indicator from logging what it is doing every tick. There is no print command but every time the EA checks it every tick it keeps saying loaded successfully ....

Thank you

 

....with a little help from my friends..

Hi guys,

at first sorry for my bad english,

so I'm buildind an EA, but I've got a problem.....

I need to know the value of the max and min of a certain candle ( for example the candle from 8,00 to 9,00 ( gmt + 1 )).

Can you help me please ?

Thanks a lot.

Reason: