MQL4 Learning - page 91

 

EA draws MA

How can I draw MA line from my EA?

Thank you in advance

Masheco

 

If you want to draw a moving average line with your EA, you need to obtain the moving average value from the indicator function, then paint it onto the chart using the trend line option with the ObjectCreate() function.

Here is an example to draw the moving average trend line.

This code is executed at the close of each bar.

static double MA;

static double previousMA;

previousMA = MA;

MA=iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,0);

int time2=Time[0];

ObjectDelete("Tr1"+time2);

ObjectCreate("Tr1"+time2, OBJ_TREND,0,Time[0],MA,

Time[1],previousMA);

ObjectSet("Tr1"+time2, OBJPROP_COLOR,SteelBlue);

ObjectSet("Tr1"+time2, OBJPROP_RAY,false);

ObjectSet("Tr1"+time2, OBJPROP_STYLE,STYLE_SOLID);

coderMike

mql4coder@gmail.com

~providing quality EA programming services~

 

No sound by close Order

Hello !

How can i adjust in metatrader, that he play a sound if a order was taken from the market (because SL or TP or whatever)

I can not found the settings.

Also give it a possibility to loads indicatoren automatic if i open a Chart-Window

All time i close a Chart, and reopen, all indicater and settings(Candlesticks,...) are lost, and i must import again

Thanks for Help

Wolfgang

 

templates

Hello,

1- There's no sounds for SL/TP events in MetaTrader.

2- You can save all the indicators and the objects of a chart to a template then reload it when you need:

Right click the chart you want to save it as a template.

Choose Templates -> Save Template ..

Give it a name and save it.

To Load the template you saved:

Right click the chart you want to load the template on.

Choose Templates -> Load Template ..

Choose the template.

mausgambler:
Hello !

How can i adjust in metatrader, that he play a sound if a order was taken from the market (because SL or TP or whatever)

I can not found the settings.

Also give it a possibility to loads indicatoren automatic if i open a Chart-Window

All time i close a Chart, and reopen, all indicater and settings(Candlesticks,...) are lost, and i must import again

Thanks for Help

Wolfgang
 

Reversing Trades MQL

Hey,

I'm wondering if there is any simple way to reverse the trades an EA makes. I know a decent amount of MQL, but I'm not sure if there's an easier way to simply turn all buys into sells and sells into buys, reversing the logic of the trades other than editing every piece of logic. Is there any easier way of doing this?

Thanks

 
 

OrderSend Function

You will not need to change every piece of code.

Just OrderSend function you need to replace:

OP_BUY to OP_SELL and OP_SELL to OP_BUY

Ask to Bid and Bid to Ask

and of course change the stoploss and takeprofit in the OrderSend function.

Forex2k11:
Hey,

I'm wondering if there is any simple way to reverse the trades an EA makes. I know a decent amount of MQL, but I'm not sure if there's an easier way to simply turn all buys into sells and sells into buys, reversing the logic of the trades other than editing every piece of logic. Is there any easier way of doing this?

Thanks
 

Depending on how the EA is coded it might be even simpler than CG's solution.

If the EA calls functions to send the orders you could just change the calls.

For example..

Instead of

if(Signal()=="BUY")OpenBuy();

You would just change the call to the OpenSell function instead.

Hope that helps.

Lux

 

Hi all,

i have a question:

is possible to hold in foreground the " window of alarm" even when, for example, I navigate in web or in other platforms without window disappear each "clik"?

Thank you advance.

 

im a newbie and i want to understand MQL4..however some say excel is better..i have a basic knowledge in excel and i want to know if it would be better if i use excel instead of MQL4..tnx!