MA cross PRICE level ... EA

 

Hi everyone !

In the attachement below there is an idea of simple Expert Advisor I'm looking for. Have You seen sth like that ?? I think it's very similar to "MA cross EA" but I'm not a programist and I can't modify the code Can You help me ?

THANKS for reply ...

Michał

Files:
 

What is 1.2560?

Why 1.2560?

Because MA is crossing this line ...

 
 

Seems I did it: MA crossing price level EA.

Explanation of the settings:

#define MAGIC 324430 //magic number, change it inside the code if you will use this EA with many pairs with one MetaTrader.

PARAMETERS_EXPERT = "PARAMETERS EXPERT";

sNameExpert = "MAprzebijaCeny_EA_v1";

colorOpenBuy = Blue;

colorCloseBuy = Aqua;

colorOpenSell = Red;

colorCloseSell = Aqua;

int nAccount =0; // 0 - use this EA with any account.

lFlagUseSound = True;

sSoundFileName = "alert.wav";

PARAMETERS_FILTER = "PARAMETERS FILTER";

lFlagUseHourTrade = False; //timefilter

nFromHourTrade = 8; //trade since 8

nToHourTrade = 17; //till 17:59

PARAMETERS_TRADE = "PARAMETERS TRADE";

double dLots = 0.10;

nSlippage = 5;

dBuyStopLossPoint = 60; //stop loss for buy order

dSellStopLossPoint = 60; //stop loss for sell order

dBuyTakeProfitPoint = 100; //profit for buy

dSellTakeProfitPoint = 100; //profit level for sell

dBuyTrailingStopPoint = 25; //trailing stop for buy

dSellTrailingStopPoint = 25; //trailing stop for sell

PARAMETERS_INDICATOR_ONE = "Moving Average";

extern double MAbig = 12; //period of MA indicator

MAbigMode = 1; //0=sma, 1=ema, 2=smma, 3=lwma

PARAMETERS_INDICATOR_TWO = "Price";

extern double Close0buy = 1.2340; // price level for buy order

extern double Close2sell = 1.2250; // price level for sell order

Files:
 

I've found a problem ... It looks like on the pic. below.

system opened LONG ... but when market went in other direction it didn't open SHORT ... why ?

thx for anwser

Files:
expl_jpeg.jpg  73 kb
 

settings of tester ....

SL - 50

TP - 0

TS - 0

MA - 5 - linear

price - 1.3230

all others default

 
mistrz-swiata:
I've found a problem ... It looks like on the pic. below.

system opened LONG ... but when market went in other direction it didn't open SHORT ... why ?

thx for anwser

It is MA-crossing-price-level EA. And this EA was coded to have one order at the time per chart. Most of EAs were coded to have one order at the time per chart. It means that new order will not be opened untill the old one will be closed. This crossing for short was when the long order was opened already. Because it should be one order only.

Seems you need to have many orders at the time per chart in EA (MaxOrder option for example).

I will try to modify this EA tomorrow. Please send the message to me (by PM) tomorrow to re-mind (sorry - too much busy).

Or, may be, some other people can do that.

 

I added Maximum Order options.

Now EA will open the order on every MA-crossing-the-price-level and all the orders are pricessing separatedly from each other by stop loss, take profit and trailing stop.

MaxOrders = 3 by default (3 order per chart).

Files:
 

with this modyfication system opened 3 positions when MA crosses price level. (in my example above 3xLONG) And It did;t close them when price moved in other direction

Could You modyfi it to close old position when price moves in other direction ?? It should reverse position each time MAcrosses price level. with a loss that has occured.

 
mistrz-swiata:
with this modyfication system opened 3 positions when MA crosses price level. (in my example above 3xLONG) And It did;t close them when price moved in other direction Could You modyfi it to close old position when price moves in other direction ?? It should reverse position each time MAcrosses price level. with a loss that has occured.

Hi mistrz-swiata,

I tried to figure it out and it is my last version. I spend more than 2 days creating this. Sorry.

If the levels for open buy/sell are the same so it will not work.

I mean if:

condition for buy = condition for to close sell (the same value, the same MA, the same price level and everything is the same);

so it does not work.

Sorry. I could not.

It will work with different levels (see default settings): one level for open buy/sell, the other level to close buy and diferent level to close sell. Do you use stop loss? So it may be as stop loss levels for you.

Sorry I did my best.

Files:
 

Why this:

PARAMETERS_INDICATOR_TWO = "Price";

extern double Close0buy = 1.2340; // price level for buy order

extern double Close2sell = 1.2250; // price level for sell order

Do you have to set trigger prices ??

Please explain.

Reason: