Download MetaTrader 5
To add comments, please log in or register
Develop trading robots to order. Make profit with Freelance service!
Tim
128
Tim 2014.04.21 21:01 

Hi I'm trying to get started building my own EA, I have a trading system that I would like to automate, but its different to the typical MA cross over systems. Its a day trading system built around the highs and lows of a series of preceding candles. The basic building block of the trading system requires at the start of each tarding day the highest 30min candle FX price of a symbol that occured during the night (22:00-07:00AM GMT) and the lowest FX price of the same symbol that occured during the night (22:00-07:00AM GMT) to be posted to a variable to be available in the 'start' section of the EA till the whole range is redefined from 10pm that day for the next days trading.

This will effectively derive the days trading range, like drawing two horizontal lines on the chart for the high and low.

Appreciate I may have explained this is a long winded way so apologies, i believe what I'm asking may require the use of the iHighest and iLowest command, if this could be explained in a simple EA or Indicator that would be great.

Hope someone can help or point me in the direction of a similar example....

Cheers

Tim

Tjipke de Vries
6299
Tjipke de Vries 2014.04.21 21:31  

Do we know your coding skills, by this message...

Show your attempt making it, then it might be someone can help

Simple EA's and simple indicators you can find yourself searching in Code Base

might you find there a similar example

Tim
128
Tim 2014.04.22 11:27  

Thankyou deVries for your response, to give you a bit of background I've been FX trading for the past 18months an reached a point where I have honed a trading strategy that over the past 5 years tested data has made approximately 10,000pips, this takes into consideration spread deductions and is calculated using the candle data provided by GFT. I've built a tester in Excel that uses the raw open close high low data and applys my trading system to obtain the results. From fwd trading is get excellent correlation between my back tested results and my fwd testing.

Due to work commitments and time I have now realised i need to automate the trading system in order to continue to place the trades. I am able to describe the trading system usinf excel FOR,AND, IF statements but need to implement this within an MQL file...which is the point at which I get stuck!!!

I have been reading books and looking at existing examples and have reached the point where I understand and have coded a basic MA crossover EA, but this is not like my system and so I now need to expand to incorporate the elements from my system. The system essentially trades above and below the overnight asian range, hence my first question and from that building block the system gets more complicated. I have yet to find in the code base a similar system, this could be because either its too complicated to code (I don't believe this is the case because I achieved it in excel) or people deem it to be not profitable, but my own testing doesn't back this up either. So this is now where I am at, any advice??

Regards

tim

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.04.22 11:29  
Yes. Show us your code.
Tim
128
Tim 2014.04.22 12:18  

Hi deysmacro,

I've not started the code for the system described above, as it is different from a the simple MA cross that is the level that I'm currently at. What I am trying to do is establish the basic building blocks in order to start the new code and the most basic of these is described above and now below:-

The basic building block of the trading system requires at the start of each trading day the highest 30min candle FX price of a symbol that occured during the night (22:00-07:00AM GMT) and the lowest FX price of the same symbol that occured during the night (22:00-07:00AM GMT) to be posted to a variable to be available in the 'start' section of the EA till the whole range is redefined from 10pm that day for the next days trading.

The output from this would be

double nightHigh

double nightLow

These values would be recalculated daily at 7am and used for the days trading.

Then I can start describing within the code when to place the orders and the rules than need to be applied, I'm sure at that point once the code starts to take shape (and no doubt will produce errors) I will be in a position to post something.

Regards

Tim

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.04.22 12:28  
We want to see your coding attempt first. Not from zero.
Tim
128
Tim 2014.04.22 14:21  
ok, well I'm going to need to get started tonight, I had hoped for some initial ideas on how to incorporated the nightHigh and nightLow into the EA, I will just have to wing it...
Tim
128
Tim 2014.04.22 14:31  

It would help if you could answer whether the iHighest command should be used within the 'init' function or whether it needs to be in the 'start' section?? I only want to use the ihighest and iLowest commands once a day at 7am, not for each tick and I need to output the result to the nightHigh and nightLow 'global' variable for use each time the 'start' function runs......I'm guessing??

Once I have this bit positioned in the code, I think the rest will follow on....

I am sorry if this is to basic a question, but consider it like writing a story, I'm struggling with how to start it.

Regards

Tim

qjol
3243
qjol 2014.04.22 15:39  
timdchambers:

It would help if you could answer whether the iHighest command should be used within the 'init' function or whether it needs to be in the 'start' section??


in the start section


if you put it in the init section you probably can get (sometimes) array out of range error or zero divide error

Tim
128
Tim 2014.04.22 16:48  

Great thankyou qjol, that helps, I know i'm going to have problems getting my " ; { " in the wrong place, so want to at least get the right commands in there.

When I position the iHighest command in the 'start function, its going to need to do something like:-

start section

{

IF(Time = 7am, nightHigh= iHighest(NULL,0,MODE_HIGH,36,1) AND ( iLowest(NULL,0,MODE_HIGH,36,1))

ELSE

Return(0)

}

The next bit will need to evaluate

{

IF(iHigh>nightHigh, post the result to zeroH) AND (iLow>nightLow, post the result to zeroL)

ELSE

Return(0)

}

Where zeroH and zeroL are declared numbers 'double zeroH and double zeroL' at the 'init' stage used to ultimately define the start of a reversal, with the intention of placing a trade targeting the nightH or nightL depending on whether it is a BUY or SELL...........

If anyone feels able to join in or add to this discussion topic that would be great, I will then pull these elements together into an EA, no doubt full of bugs, but heading in the right direction.

cheers

tim

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.04.22 16:56  
Please edit and use SRC when posting codes so that it is easier to read.
/ /123
To add comments, please log in or register