How to code? - page 263

 

Is it possible to drag a line up and down ... ??

Hello,

Is possible for a levels line (or an "effective" levels lines) in a separate indicator window to be movable (i.e. "dragged") manually and for the new settings value to be updated in an EA which uses these for initiating and exiting a trade?

I have read there are drag 'n drop scripts where you can move a line but don't know if it's possible to incorporate / splice such script in EA.

 
 
yourspace:
hi

maybe it is right,you can try it .

double upper_red = iCustom(NULL,0,"DDM",Nmbr_Bars,Order,Ecart,3,0);

Doesn't change a thing, but tanks for reaction anyway.

Maybe someone knows a look a like indicator?

edit: I have solved it, the indicator " i-Regr H&L" is almost the same, this one draws normally.

 

Quote Saver

Hi,

I want to save the actual tick data into a csv-file. Every week or month I want to save one csv-file.

So in my init-function I will open a new file and every tick I do a

FileWrite(handle_tick,TimeToStr(CurTime(),TIME_DATE|TIME_MINUTES|TIME_SECONDS),Bid,Ask);

Now I have a few problems / questions:

1.

When there is a problem with writing into the file the ea stopped for the hole (week/month) and can't open it again.

-Do I have to write FileOpen(...) every tick?? Or should I use FileFlush(..)?

2.

There also was a problem with the saved time. If I compared it with the chart-time, or the time from the history center, there was a big difference (not statical, sometimes e.g. 39minutes, or 87minutes).

Do I have to save the CurTime or what time??

3.

There are some breaks in my internet connection (e.g. 2-5 minutes, about 3 times a day).

How can I check my saved quotes automatically, so that the ea fetches the missing mintues-data from the history?

And how can I get my tick data if the internet connection was lost? Is there also a history center or a buffer for the last hours?

4.

Does anybody know a easy way to combine the single csv-quote files automatically?

5.

I also want to save tick and minute-data from cfd's like Ger30! If i save the .csv File monthly, but the new contract, which comes every 3 months does change during the month. Then the EA can't find the data because the actual underlying (contract "Juli" is not valid anymore, but now e.g its the september contract) doesn't work anymore.

Maybe there is already a reliable EA for that problem?

 

After every FileWrite, you should do a file flush to insure the data is written to disk after every write. If it flush is not used the file system stores the writes in a memory buffer and then writes all the records in the buffer to disk for efficiency. This may be why you are losing records; the ea stops and you lose the memory records. The file flush will write each record to disk, slower but insures you have them all. With file flush, you can open the file using Excel while the EA is running and examine it in read only mode.

In the deinit function, check if your file handle is > 0 and then close the file.

This will flush the memory buffer automatically

During opening there are options to either create a new file on disk or to append to an existing file. It sounds like you should use the append to an existing file method. This will solve your file merge automatically. You can open each CSV file in a separate instance of Excel and cut and paste, could use Notepad also. In Excel you can save the merged file as a CSV or use Excel as a database to store the merged info in an XLSX format. Or you could get VB express from MS, its free, learn VB and write a file merge in that language.

Best option is to search for other examples of saving ticks.

Cheers

 

I also have another question:

6.

Is it useful to save the bid, ask and the volumen in my tick-file?

7.

Does anybody have a tutorial how to backtest tickdata with metatrader 4 or/and 5?

Is there a expert out there who could help my?! You can also answer per private message...

Thank you!

julia

 

Especially what is about CFDs? They change the contract every three month! So how can I programm this in my tick-saver.mq4, that the change of the underlying happens automatically and I don't lose any ticks??

 

Hi everyone, I need help using 1 EA on multiple charts!!

summary of my question:

I have an EA which places just 1 order at a time using the variable total = OrdersTotal() . A new order will only open when that 1 order is closed.

How do I modify it so that two different currency pairs can each have 1 open order without the same currency pair having 2 open orders?

what I need are lines of code that allows me to do this:

place 1 order (say, with magic # 12345) if there is not already an order with that specific magic# open.

or, place 1 order if there is not already an order of the same ordersymbol open.

--------------------------

longer version of my problem:

So I recently modified a simple EA based on placing orders when the 10 and 5 SMA lines cross.

It works fine with my EURUSD chart and it places only one order at a time, either buy or sell, because I have these lines of code:

total = OrdersTotal();

if(total < 1)

--then it places an order

When I created a duplicate EA and applied it to the EURJPY chart however, I had to change the code to

total = OrdersTotal();

if(total < 2)

--so that it would place an order if an order was already opened on the EURUSD chart.

the problem is that when the EURUSD order closes, a second EURJPY order is allowed to open and the EURUSD EA will not place a new order since there is already an EURJPY order open.

I give the different pairs separate magic numbers. I had an order opened on my EURUSD chart with the magic# 22341 and I tried using a new variable for my EURJPY chart:

tott = OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderMagicNumber() == 22341) //22341 is the magic# for EURUSD orders

total = OrdersTotal();

if(total < 2 && tott == true)

--then an order is placed for EURJPY

but it gets complicated letting the EAs run on their own... especially if I add a third currency pair of USDJPY which I want my EA to run on.

any help is appreciated!!

edit:

i decided to go with magic numbers:

total= 0;

for(int i=0;i<OrdersTotal(); i++ )

{

if(OrderSelect(i, SELECT_BY_POS)==true)

{

if (OrderMagicNumber()==12341)

total++;

}

}

{

if(total < 1)

--then a trade will be made

 

Backtesting tickdata

Sunshineh,

"7. Does anybody have a tutorial how to backtest tickdata with metatrader 4 or/and 5?"

An old build - I think it was 208 - was the last one that would do tick data. It was posted somewhere, search TSD first.

If you get all this solved i would like to use it too. I also know of a thread where this is solved acceptably, though it may not be on TSD.

Big Be

 

How to get the EA to realise the previous bar has closed above the BB?

Hi everyone,

I'm trying to get the EA to record when a bar closes outside the bollingerbands, then initiate a trade if this happened in the previous bar

and the ema's cross or something. My code so far looks like this:

int bar, sll;

if( Close[0] > bollingerband ){

bar = Bars;}

if( bar+1 == Bars){

if(ema1>ema2){

sll = 1}

if ( bar+2 == Bars ){

bar = 0;}

Unfortunately this doesn't seem to work and Ive also tried making it a static as well as a global variable. So I would be most grateful if someone could point me in the right direction.

Cheers,

Sapere

Reason: