How to code? - page 222

 

Thanks Roger09

Originally Posted by ForExTyro

I am trying to add code to an EA that will restrict the number of trades it makes per day to only two(2). Only ONE long trade and ONE short trade per day. This is the code I have so far, but on a back test it is not working.

Can you help me!?

Reply Posted by Roger09

Replace

datetime LongTrade=0;

datetime ShortTrade=0;

to

static datetime LongTrade=0;

static datetime ShortTrade=0;

That's it?

That IS it!

THANK YOU Roger09

 

Hello,

This is nice example how is looking decompiled EA & Ind.

b.

 
Kalenzo:
There you go! Enjoy!

Hi Kalenzo,

I need your help again, can you code for me an additional

info like you did before, I would like to put LSMA Bar information.

When LSMA Woodie Bar Green it show Word LONG (green colour),

and when Woodie Bar Red it show Word Short (red colour).

view the attached pic..

http://i98.photobucket.com/albums/l277/compobey/CCIinfo.jpg

Regards,

compobey

 

Help request

Hi everybody

I've been using very simple system that makes about +100 pips per month.

I would like to put it into EA but I'm very new to coding and I feel so lost . Maybe you guys/ladies could help me to creat this EA and we all could use it?

Please let me know if you are interested and I will post the details what the EA needs to do.

Thank you

 

Kalenzo

Kalenzo:
There you go! Enjoy!

Hi again Kalenzo,

I have been observing the indi you fixed for me.

Generally it works fine, but occassionally it happens to put wrong color on the line.

As you can see in the picture, there are places where it should be Tomato or Red, but turns out DodgerBlue instead.

The rules were;

When value (at close of bar) > than previous close of bar (going up) =

DodgerBlue when the value is < 0

Blue when the value is > 0

When value (at close of bar < than previous close of bar (going down) =

Tomato when the value is > 0

Red when the value is < 0

I have marked with red arrows where the errors accur.

Can you have a look at the code, please.

I have tried to explain as good as I can, but let me know if you need more info.

Thanks.

 
Klondyke:
Hi again Kalenzo,

I have been observing the indi you fixed for me.

Generally it works fine, but occassionally it happens to put wrong color on the line.

As you can see in the picture, there are places where it should be Tomato or Red, but turns out DodgerBlue instead.

The rules were;

When value (at close of bar) > than previous close of bar (going up) =

DodgerBlue when the value is < 0

Blue when the value is > 0

When value (at close of bar < than previous close of bar (going down) =

Tomato when the value is > 0

Red when the value is < 0

I have marked with red arrows where the errors accur.

Can you have a look at the code, please.

I have tried to explain as good as I can, but let me know if you need more info.

Thanks.

Sorry, I forgott the file.

 

how to go to line label?

How would I goto a line label in Metatrader 4

something like

if(a > b) goto fred

if(c > d) goto jim

:fred

do some some more code here

:jim

do some code here

I got an answer but I need a little more clarification

You can write some code in functons instead. Something like this:

if(a > b) ReturnValue = fred();

if(c > d) ReturnValue = jim();

int fred()

{

do some some more code here

}

int jim()

{

do some code here

}

what is ReturnValue ? not a function, how do I actually write it

 

In the example you posted 'ReturnValue' is just a variable. It could have been called anything but whoever gave you that code used 'ReturnValue'.

To be honest that format doesn't make much sense unless you intend to actually do something with the value that is returned from the two functions. You can't use the concept of goto like you could in VB (or was it Basic - it's so far back I can't recall!).

Just something like...

if(a>b)DoThisFunction();

if(a<b)DoAnotherFunction();

Then whatever you intended to do when the program would have jumped using goto you would instead do it in the two respective functions.

Hope that make some sense.

Regards

Lux

 
luxinterior:
In the example you posted 'ReturnValue' is just a variable. It could have been called anything but whoever gave you that code used 'ReturnValue'.

To be honest that format doesn't make much sense unless you intend to actually do something with the value that is returned from the two functions. You can't use the concept of goto like you could in VB (or was it Basic - it's so far back I can't recall!).

Just something like...

if(a>b)DoThisFunction();

if(a<b)DoAnotherFunction();

Then whatever you intended to do when the program would have jumped using goto you would instead do it in the two respective functions.

Hope that make some sense.

Regards

Lux

Thanks for the answer, what I am trying to do is get the EA to choose between two conditions, but choose whichever one changes first.

So in your example

if(a>b)DoThisFunction();

if(a<b)DoAnotherFunction();

it needs more than if do this, or if do that, because the other condition is has c & d changed before a & b if so do this and ignore a & b. That is why I was trying to go to a line because I cannot get it to choose with if then else

because in reality I have

if(a>b && c>d) // do a buy here

else

if(a>b && c<d) // do a close buy here

else

reverse do a sell or a close sell

but if c & d has changed first, before a & b, then ignore the above code and do the above tests on c & d instead

Sorry it is as clear as mud

 

Working with CSV-Files --I am going crazy

Hi,

I am writing an EA which is working with CSV-Files.

For testing I put my CSV Files in the following folder:

/tester/files

Here is only a small part from my EA:

int handle = 0;

int Long = 0;

handle=FileOpen("LongMarket.csv",FILE_CSV|FILE_READ,';');

if (handle > 0)

{

Long= FileReadNumber(handle);

FileClose(handle);

}

Print("LongMarket = ", Long);

Print("Long handle = ", handle);

In my EA I read the CSV-Files and then I write some integers down.

Now when I do my test and read in the journal the "Print"-messages, I often get old integers which aren't writen in the CSV-Files anymore!!

For example:

First there is written 3 and my EA ist working and writes the 0 into the file,

I can only see the 3 in that CSV-File!!

When I clear that CSV-File and put a new CSV-File with 3 in that " /tester/files"-Folder, I can only read the 0 from the test before!!!! But I can't find, where the EA reads the 0!!!

I am going crazy!!!!!

I hope you can understand my question and give me a tipp!!

Reason: