Would like to program a very simple EA but no skills yet

Hi there,

as mentioned in the subject, I am looking to program a simple EA based on Weekly Open Price -/+ a certain amount of pips which would trigger a buy/sell order with a fixed TP and SL.

I have gone through a lot of already existing EA as I thought I could adapt one but I didn’t find anything close to what I need and also I am a bit scared that without knowledge I would remove some crucial stuff from it.

Is anyone willing to give me a hand on this ? It should be very quick to do as the strategy is very straightforward.

Thanks in advance for your help,

Yves

This EA would look like this (in C):

function run()
{
	BarPeriod = 60;
	set(HEDGING+TICKS);
	
	Entry = 50*PIP;
	Stop = 50*PIP;
	TakeProfit = 50*PIP;
	TimeWait = 24;
	
	if(day() == MONDAY && hour() == 8) { 
		enterLong();
		enterShort();
	}	
}

The above version with all limits at 50 pips gets 13% annual return - not too impressive.

Thanks very much for that jcl365,

It’s probably because I have no clues with programming but I expected it to look different.
Would this buy at Weekly Open Price -50 pips and sell at Weekly Open Price +50 pips ?
Is it all what is needed ? Or can this be added to a main body that contains all the basic routines ?

As per the return, from what I tested, it’s not so good with only 50 pips but it gets a lot better with a 100 and even more with 150 pips. The SL being at 50 in all cases. I checked it on eur/usd throughout 2012 (until 19.11) and the return is around50% annually. Original account went from 10000 up to 15250 with 50K orders which is 2.5% risk on each trade but longest drawdown is 4 trades in a row (at least for this particular period). I would say it’s not exceptional but it could be used along with other EA’s

Feel free to comment on this, I am rather new and open to any feedback even if harsh.

Yves

This is all what is needed when you use a serious language, such as C in the Zorro software. In MQL4 you would need 10x more code and 20x more time.

It would buy at Weekly Open + 50 pips, not -50 pips. This is why it’s important to describe entry and exit as clearly as possible. Here is the version that buys at -50 pips and sells at +150 pips:

function run()
{
	BarPeriod = 60;
	set(HEDGING+TICKS);
	
	Entry = -50*PIP;
	Stop = 50*PIP;
	TakeProfit = 150*PIP;
	TimeWait = 24;
	
	if(day() == MONDAY && hour() == 8) { // start of the week
		enterLong();
		enterShort();
	}	
}

This version is not profitable anymore. On average it loses 131 pips per year with EUR/USD.

When you have such a system and think it has an edge, the next step would be finding parameters - such as entry, exit, open time and so on - that generate profit and are robust over a wide range. This is the real development work, not formulating the system in code. If you have a good trade software, it finds those parameters automatically for you, but you still have to know what you’re doing.

Piping Hot,

What he says is for a great part bull… You still need something else to use. I think he uses a program in which the functions that he is not adding now are included. His script will not run on its own.

C on its own does not know what to do with the instructions that jcl his script gives.

Call on me when you are in the chat again and I can help you out.

Piping,

I get where you get your idea from, but have you considered that the Low of the week is not always before the high of the week? What I mean is that the price can be Open+50 before it was Open-50. Meaning that your trade is triggered when it already had its high.

Maybe it is an idea to test it on D1 or H4 and to exclude the trades where Open+50 is reached before Open-50. Maybe that will improve performance of the system.

Sorry, Toekan,

What you say is for a great part bull… The question was whether this code is all what’s needed, and the answer is: Yes, it’s all what’s needed. You need not “add functions”, whatever that means. Of course you need a software program, in this case Zorro, where you enter the code for compiling and executing it.

There you go… So it is not the great language C…:slight_smile: Your extra code is hidden in Zorro, as is mine in my librabries when I use them. So it stays for a great part Bull what you…

You are also saying that it is not all Bull that I say, can you specify what is not true about what I said?

I have seen you making claims in your threads that aren’t true, such as MT4 cannot be used for automated trading. Among other things.

By the way, why do you think that his weekly bar will start on monday 8 o’clock? And why would you buy at week open + 50 pips… It is his system and you are advising something without proofing why. Why didn;t you use his entry and exit settings as he asked? Why the TP at 150 pip? And why include entryshort(); when he only trades longs…:slight_smile: And how much lots will it trade? Where is the other code or settings he needs to know?

You have no clue about what you say and make unjustified claims. You are just an enthousiast Zorro user with no (or maybe just a little) other coding experience.

As to your argument that the program uses “extra code that is hidden”: This is true for all programs, as all existing programs use libraries, for instance the Windows API. What you’re beginning here is just arguing for the argument’s sake. This does nothing to answer the OP’s question or help him code his system. As to why the TP is at 150 pips etc, just look at the system description.

I have the impression that you start to troll here a little. This thread is just about helping the OP to code his system, nothing else.

No this is trolling, this is about the way you promote the project that you are on and the software it offers. I am stating my opinion and I am free to do so, just as you. And I am free to reply to posts, just as you. So no trolling, just helping others out and warn about BS, as others will do on my posts and as is done throughout this forum.

But you think don’t agree that that is done with you? I was not aware that you require a special treatment.

I promote informed automated trading. This is my intention. I do not care what software is used, as long as it helps automated trading and does not hamper it.

I take back my remark about trolling.

To be honest, I like it that there are more alternatives to trade, and I think that the project has a good intention. If it works, excellent… Really. Just the claims made by you were, in my opinion, unfair.

That is okay. I can understand that I annoyed you in my responses. But they were also made with the right intention and for the good of the others.

Good luck with the project!

Ok guys,

Thanks both very much for your help anyway. I can see you are both doing your best and it feels great to be nicely taken care of.

So to summarize, jcl 365, your code is complete and can be used directly in Zorro, but it is not a valid code for MT4 which is what I am using. I wouldn’t mind changing to Zorro though if it is that easier.

There is just a bit of misunderstanding when it comes to my system so I will give you more details:

The idea is that when the market has moved 150 pips away from weekly open price (which is previous week closing price as well, maybe that’s easier because no need to worry about sunday or Monday first candle) it more often than not returns all the way back to it. It works in both direction so I would like to buy at WOP -150 pips and to sell at WOP +150 pips. Target being WOP which means 150 pips TP and as it unfortunately isn’t always the case, SL set at 50 pips to keep a good risk/reward ratio as this can be considered rather long time trading. Trade should be closed before the last candle of the week if it hasn’t reached either TP or SL. I have backtested it manually on eurusd throughout 2012 and the results are looking good. I would like to test it on several pairs to get a better idea but even if it’s quite simple to set up manually, I am a bit lazy to do this every week and also, I would like to backtest it for longer periods on all major pairs.

I agree that it doesn’t sound like the most profitable system on earth but it can be improved with a bit of pre-thinking. For example, I wouldn’t use it if a pair is trending strongly like usdjpy is at the moment.

Again, I am very open to any comments if you think that this system is not viable but I really think it is worth trying. There is definitely something going on with WOP, the market really likes this point and it makes sense when you think that it is ranging most of the time.

Yves

The idea is that when the market has moved 150 pips away from weekly open price (which is previous week closing price as well, maybe that’s easier because no need to worry about sunday or Monday first candle) it more often than not returns all the way back to it.

This is a valid theory on which you can base a trade system, but you must first test the theory. A “manual backtest” won’t do. This is a simple lite-C script that can test weekly seasonality:

function run()
{
	BarPeriod = 60;
	int h = hour() + 24*(dow()-1);

	var value = (price(0)-price(h))/PIP;
	plotBar("Price",h,hour(0),value,AVG|BARS,RED);	
	plotBar("StdDev",h,hour(0),value,DEV|BARS,BLUE);
}

This script plots a week statistic with the hourly mean and standard deviation of the difference of the current price to the price of the begin of the week. This is the result for EUR/USD:

The red bars are the price, the blue bars are the standard deviation. You can see that there’s indeed a weak seasonal effect Monday and Tuesday, so your theory has some merits. The price tends to go down Monday, then tends to go all the way back and moves in opposite direction by Tuesday. However the standard deviation is much higher than the price difference, so it would be not easy to exploit this effect in a strategy.

Hi jcl365,

Thanks very much for that once again,

I get a little bit confused with your graph and the standard deviation thing. I did spot the Monday Tuesday thing, it happens even more often and in both directions but the amount of pip is usually low if you consider only these 2 days and it’s hard to define a system as you said. When you consider the whole week though, the 150 pips target makes a lot more sense. It would work with 50 pips or 100 pips but it is less profitable than 150 pips at least on eurusd throughout 2012. Of course given the fairly long distance between the buy/sell price and the Weekly Open Price, it sometimes never returns back to original point but that wouldn’t necessarily mean a lost trade as I close it before friday end of market time anyway so it would be somewhere between +150pips and -50pips.

I definitely need to test this further and that’s what I am doing on several pairs at the moment. The reason why I need an EA is not much for live trading as it is quite simple to manually place every week end once you know the weekly closing price but it is more to get a chance to backtest it. Sorry but I do believe in long frame backtesting.

Apparently, you seem to promote Zorro and its easy C language programming, fair enough, but I would like to get back to my original question: Can someone give me the code in order to use it as an EA in MQ4 ? The reason I dare to ask this for free is because I am pretty sure it should be a very short one to write.

Maybe I am completely wrong but I expect to see a line with something like :

If Weekly Open Price - Market Price = -150 place sell order TP150 SL50
If Weekly Open Price - Market Price = +150 place buy order TP150 SL50

I would then be able to change the numbers to finetune the strategy. As I did it manually, I only tried 50, 100 and 150 but it could well be that optimal distance is 139 or whatever…

Using Zorro would mean that I need to change everything and I just start feeling confident with MT4 and EA’s testing and using. Also, I have already a live account setup with Oanda so it’s all very convenient for me.

Let me know if you can give me the code to be used in MT4.

Yves

I code for all platforms, but MT4 code is usually complicated and time consuming, so I can’t do it free. But maybe someone else is willing to help?

Ok, thanks anyway.

I will get back to you if I find the time and the courage to study Zorro. :slight_smile: