Coding help - page 40

 

Thanks mladen,

I've finished my code now (thanks to your help) and it works really well. Ive done the code based on my manual trading of H4 and D1 charts over the last couple of years. I'm thinking about diversifying my risk and having two accounts, one trading the longer term charts, the other the shorter term charts with seperate accounts. So I am looking to adapt this code to suit, say for M5 and M15 charts. I know that strategies can work on one timeframe but not another, and something I have noticed about the shorter term charts is that they are much more random, dont respect S/R very much and prone to long periods of consolidation.

I was wondering whether you have any tips in respect of shorter term strategies- some things I am considering is to have the EA check multiple symbols for the best opportunities rather than just one, and also possibly adding an MVA creating a total of 3 for stregth of trend on higher timeframe, and maybe adding a section of code to stop trading if in an area of consolidation (say if the last 50 bars are between a 50 pip range). Also perhaps only trading if price is below/ over the middle line of a donchian channel and even checking wick heights.

 

...

Off all, just one "warning" : there is no way to back-test multi symbol trading EAs in metatrader. So, if you are planing that, the only way you are going to get to some reliable results is through lengthy forward testing.

Even in normal testing forward testing is the only really acceptable form (due to some problems with metatrader back-testing : total lack of historical Bid, Ask and implicitly spread, the lack of swaps, commisions and all related to similar stuff, ticks simulated in a rather strange way, ... and so om , and so on ... ) but people rarely do it since it requires time and dedication. If you really are trying to develop a system that you want to depend on only forward testing can be considered

So that would be the only tip. Of strategies : people trade 1000s of ways and a lot of people are living form it, so there is no "just one" way of doing it. Try your own ways and with forward testing you might even discover that you already have a wining system

crsnape@btinternet.com:
Thanks mladen,

I've finished my code now (thanks to your help) and it works really well. Ive done the code based on my manual trading of H4 and D1 charts over the last couple of years. I'm thinking about diversifying my risk and having two accounts, one trading the longer term charts, the other the shorter term charts with seperate accounts. So I am looking to adapt this code to suit, say for M5 and M15 charts. I know that strategies can work on one timeframe but not another, and something I have noticed about the shorter term charts is that they are much more random, dont respect S/R very much and prone to long periods of consolidation.

I was wondering whether you have any tips in respect of shorter term strategies- some things I am considering is to have the EA check multiple symbols for the best opportunities rather than just one, and also possibly adding an MVA creating a total of 3 for stregth of trend on higher timeframe, and maybe adding a section of code to stop trading if in an area of consolidation (say if the last 50 bars are between a 50 pip range). Also perhaps only trading if price is below/ over the middle line of a donchian channel and even checking wick heights.
 

Thanks mladen for the advice.

I have a strange issue with my EA. When I backtest it on H4 chart it does so as it should. However when I backtest it on H1 it loads the inputs (TimingChart = 240 and TrendChart 1440) as seen in the journal instead of TimingChart 60 and TrendChart 240 (I have changed the external variables in the code and also made sure the inputs are correct when attaching the EA to the chart. Yet it continues to load the wrong timeframes). A whole host of issues get raised in the journal including OrderModify error 1 and ordersend error 130, zero divides, that arent there when I test on the H4 chart. I have not changed the code at between tests except for changing the external variables and I can only presume it is the inputs that are creating the errors. PS (for error 130 my broker has SL minimum 0).

Just to clarify also, that I attach my EA to the H1 chart just to make sure and also select H1 on the drop down menu on strategy tester. I have also closed MT4 and reloaded it to see if this solved the problem but unfortunately not.

Any ideas?

 

Hi could someone tell me if I am processing an ordersend and I dont want to input a takeprofit level (or any other parameter for that matter), do I simply insert 0?

Also what about OrderModify() if I dont want to change one of the inputs do I put OrderStopLoss() for instance? What about if no stoploss level was inputted in the ordersend, does it still remain OrderStopLoss() or is something else inserted?

Thanks.

 

...

As far as take profit, stop loss, slippage and magic number parameters are concerned, yes

Some parameters have different ways of avoiding : color 0 for example is black so instead you have to use CLR_NONEin that place. Also, if string is required, use NULL (easier to spot and is a usual way of doing it in metatrader)

crsnape@btinternet.com:
Hi could someone tell me if I am processing an ordersend and I dont want to input a takeprofit level (or any other parameter for that matter), do I simply insert 0?
 

Hi mladen, with OrderModify, if I want to keep the original input as per the OrderSend do I input, for instance with stoploss, OrderStopLoss()? What about if no stoploss was inputted in OrderSend, do I insert 0 or still OrderStopLoss()?

Thanks

 

If there was no order stop loss initially the OrderStopLoss() will return 0, so it comes to same thing

crsnape@btinternet.com:
Hi mladen, with OrderModify, if I want to keep the original input as per the OrderSend do I input, for instance with stoploss, OrderStopLoss()? What about if no stoploss was inputted in OrderSend, do I insert 0 or still OrderStopLoss()? Thanks
 

Is slippage in the context of ordersend the spread value?

 

I notice slippage is maximum slippage allowed in MQL4 book. Is a maximum spread code written seperately?

 

...

No

It is a maximal slippage in price that you (the user) will accept from broker in order opening execution

An example :

price 1.0000, allowed slippage 0, order must be opened at 1.0000 or, if it can not be opened at that exact price, you will get a requote

price 1.0000, allowed slippage 3, order can be opened anywhere between 0.9997 and 1.0003

crsnape@btinternet.com:
Is slippage in the context of ordersend the spread value?