Forum

Code For Non Farm Payroll

Another attempt at coding to miss out days prior to NFP. The code compiles and the logic seems sound but if i set the tester to run this bit of the code it does not trade at all rather than missing the days tested for. Is there an obvious error anyone can see. // Code to exclude Days Before NFP if

Find the 4 trading days prior to Non Farm Payroll

I am attempting to have another shot at detecting the 4 trading days prior to NFP for any month. Using the built in functions and the DaysOfMonth() available on the forum I have an idea. I have an external variable ExcludeDaysBeforeNFP() that can be set from 1 to 4. with 4 meaning it should not

Help with simple function

Can anyone help me to create a function to test for first day of the month? I have code below but i can not seem to get it to compile. // IsFirstOfMonth // bool IsfirstOfMonth() { datetime now.srv = TimeCurrent (); int now.dom = TimeDay(now.srv); if (now.dom == 1 ) // First day of the

Avoid trading days either side of Non Farm Payroll subject to what day of the month Non Farm Payroll lands on

Hi I am trying to code a method to avoid volatility either side of Non Farm Payrol (NFP). I would like to be able to select to trade or not trade the following. 1. Trade or not Trade NFP. I have this code that seems to work extern bool NFP_Friday = true; if (DayOfWeek() == 5 && Day() < 8 &&

Trading certain days of the week

Hi I am trying to allow my EA to have the ability to trade on either Monday, Midweek (tu,we,th) or Friday. Or possibly a combination I created 3 boolean values with midweek set as true as a default:- extern bool Mon = false ; extern bool Midweek = true ; extern bool

Init() starting program logic.

Hi i am after some simple help in coding some starting logic in MQl4 I am trying to ensure that if a value is set to true then a bit of code runs to exclude certain values from being run through the EA code. If it is not set to tru then the normal program execution would take place. My problem is

Help With Parentheses

Hi I am having trouble with Parentheses. I know i should'nt but i can not figure out how to add a simple extra if statement. This code works int init() { if ( 60 *EndHr+EndMn<=( 60 *StartHr+(StartMn+ 15 ))) { Print ( "invalid trading time" ); return INIT_PARAMETERS_INCORRECT ; } But this

How best to skip code on if thn clause.

Hi I have an EA where i want to tell the code (including the Strategy Tester , if that acts differently) to skip a test if a condition is not met. I am new to MQL4 so i chaecked the web and found i could possibly use "break" is this correct and if so would strategy tester stop or just ignore one

Problem converting integer to string and concatenation

Hi I am trying to allow an EA to accept some external integer values as string times "HH;MM". I have the following code which compiles and runs but an error occurs and it says the time is formatted incorrectly. I suspect it may be my concatenation method but can anyone advise? extern int StartHr

Using MT4 Strategy Tester to evaluate Trading a time slot

Hi I have an EA (written some years back). In the EA is a start time and end time for trading each day. In Strategy Tester it does not allow you to increment either the start time or end time to evaluate results. It is greyed out. When i look in the code the "time" is entered as a string and then