stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Need advise on this code
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3740
Page 3 of 5
Author:  fxcba [ Sat Jul 26, 2014 3:32 pm ]
Post subject:  Need advise on this code

Ok, here is
Author:  milanese [ Sat Jul 26, 2014 3:42 pm ]
Post subject:  Need advise on this code

here you go, now the magicnumber calculation code should work too..
UniversalMACrossEA_6xx.mq4
Cheers :)

Tommaso
Author:  fxcba [ Sat Jul 26, 2014 4:02 pm ]
Post subject:  Need advise on this code

Hey Tommaso, so all problem was the capital "m"? (I need to pay more atention :oops: )
Thank you
Author:  milanese [ Sat Jul 26, 2014 4:18 pm ]
Post subject:  Need advise on this code

fxcba » Sat Jul 26, 2014 4:02 pm wrote:Hey Tommaso, so all problem was the capital "m"? (I need to pay more atention :oops: )
Thank you
there were some minor thingies, like missing brackets, redefining a global variable and line 874 was incomplete..

Cheers :)

Tommaso
Author:  fxcba [ Sat Jul 26, 2014 4:32 pm ]
Post subject:  Need advise on this code

milanese » Sat Jul 26, 2014 1:18 pm wrote: there were some minor thingies, like missing brackets, redefining a global variable and line 874 was incomplete..

Cheers :)

Tommaso
yes, that was me doing trial and error untill I commented all
but I see that "MagicNumber" now is "magic_number", and "int isymbol=" is "int isymbol =0", so I think there were the main issue.
thank you again
cheers
Author:  fxcba [ Fri Sep 12, 2014 11:36 am ]
Post subject:  Need advise on this code

Hello, It's me again :) . Today I want to ask a couple of questions
I'm working on "iHigh" and "iLow" function and how it works, this line:
HiPrice = MathMax(HiPrice,iHigh(NULL,PERIOD_CURRENT,shift+1));
makes the EA jumps in trade when price equals previous high, so, first question, what should be written to add a buffer in order to wait price exceed some pips the high?
second question: there is also a several types of periods to choose instead "PERIOD_CURRENT", like "PERIOD_H2", in this case I asume Empty4 will read the high of the last 2 hours, Am I right?, taking this in acount my question is standard Empty4 charts starts at 0 h and ends 23:59 how to make script starts at 0 h reading 12 blocks of 2 hs, stop at 23hs and start again?
Regards and thank you in advance
Author:  SteveHopwood [ Fri Sep 12, 2014 12:00 pm ]
Post subject:  Need advise on this code

Hello, It's me again :) . Today I want to ask a couple of questions
I'm working on "iHigh" and "iLow" function and how it works, this line:
HiPrice = MathMax(HiPrice,iHigh(NULL,PERIOD_CURRENT,shift+1));
makes the EA jumps in trade when price equals previous high, so, first question, what should be written to add a buffer in order to wait price exceed some pips the high?
Declare a buffer that you can show as an extern or hard code to your chosen value:

Code: Select all

double BufferPips = 10;
HiPrice = MathMax(HiPrice,iHigh(NULL,PERIOD_CURRENT,shift+1));
HiPrice+= (BufferPips * Point);
You would be better off going into any of my ea's and borrowing Paul's pip factor code, so the code becomes

Code: Select all

HiPrice+= (BufferPips / factor);
but you might not be ready for that yet.
second question: there is also a several types of periods to choose instead "PERIOD_CURRENT", like "PERIOD_H2", in this case I asume Empty4 will read the high of the last 2 hours, Am I right?, taking this in acount my question is standard Empty4 charts starts at 0 h and ends 23:59 how to make script starts at 0 h reading 12 blocks of 2 hs, stop at 23hs and start again?
Regards and thank you in advance
Over to someone else for that one.

:xm:
Author:  fxcba [ Fri Sep 12, 2014 12:27 pm ]
Post subject:  Need advise on this code

Hello Steve, thank you for your answer.
Regarding second question I've be reading some ea's code and I think this can be done with a start day and hour I'll keep searching
cheers
Author:  fxcba [ Fri Sep 12, 2014 3:15 pm ]
Post subject:  Need advise on this code

Thank you again, it's working fine :clap:, next week I'll do some forward test to see how Empty4 counts the hours starting on monday at 0 hs.
Where can I find some info about closing the trade on opposite signal?, so far this ea trades one direction untill takes profit or is stopped.
Sorry for ask this way but I only devote a couple of hours a week to coding, so I'm trying to save some research time.
Thank you
Author:  SteveHopwood [ Fri Sep 12, 2014 6:23 pm ]
Post subject:  Need advise on this code

fxcba » Fri Sep 12, 2014 3:15 pm wrote: Where can I find some info about closing the trade on opposite signal?, so far this ea trades one direction untill takes profit or is stopped.
Download one of my shells from http://www.stevehopwoodforex.com/phpBB3 ... ?f=15&t=79.

Go to void CountOpenTrades() and see how the function builds up a picture of trades belonging to the ea. Find this line of code:
TradeWasClosed=LookForTradeClosure(OrderTicket()); to see how the closure function is called and what to do with the loop in the event of a trade being closed.

Then look at bool LookForTradeClosure(int ticket) and see how you can set CloseThisTrade to true if your system has generated an opposite direction signal.

I am not saying this is the only way, or even the best way to do this. I can say that it has worked time and time and time again for me.

:xm:
All times are UTC Page 3 of 5