Coding for beginners - this is how Steve started

The forum for experienced coders to upload their helpful hints, tips and lessons.
Post Reply
User avatar
traderduke
Trader
Posts: 306
Joined: Mon Nov 28, 2011 7:30 pm
Location: East Coast USA

Re: Coding for beginners - this is how Steve started

Post by traderduke »

NT
thanks for the suggestion, I'll give it a try.
NeoTrader wrote:hi traderduke,
traderduke wrote:What is the code for limiting one trade per candle??
Maybe you can make use of the following function...

Code: Select all

bool isNewBar() {
	static int prevTime;
	bool newBar=false;
	
	if(Time[0]!=prevTime) {
		newBar=true;
		prevTime=Time[0];
	}
	
	return(newBar);
}
usage:

Code: Select all

if ( isNewBar ) {
    your trading logic;
}
happy weekend,

NeoTrader

-
Big Be
Trader
Posts: 52
Joined: Thu Nov 01, 2012 6:12 pm

Re: Coding for beginners - this is how Steve started

Post by Big Be »

More Programming Student Tips

I started several years ago as Steve did, with Coders' Guru lessons.
I started a thread on TSD a while ago to further help programming students:

Things Coders' Guru Never Taught Me
http://www.forex-tsd.com/lessons/23721- ... ht-me.html

Big Be
"Big Be"
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Re: Coding for beginners - this is how Steve started

Post by SteveHopwood »

Big Be wrote:More Programming Student Tips

I started several years ago as Steve did, with Coders' Guru lessons.
I started a thread on TSD a while ago to further help programming students:

Things Coders' Guru Never Taught Me
http://www.forex-tsd.com/lessons/23721- ... ht-me.html

Big Be
Nice on Big Be. I have linked this in post 1.

:D
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
User avatar
traderduke
Trader
Posts: 306
Joined: Mon Nov 28, 2011 7:30 pm
Location: East Coast USA

Re: Coding for beginners - this is how Steve started

Post by traderduke »

NT or big be
Is this the proper order for this current bar check???
Thanks for your help

//---------------------------------
// Verify that a new bar appeared.|
//---------------------------------
bool NewBar()
{
static int lastBars;
if (lastBars != Bars)
{
lastBars = Bars;
return(true);
}
else
{
return(false);
}
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//return if not a new bar
if (!NewBar()) return(0);

the rest of the EA code???

traderduke wrote:NT
thanks for the suggestion, I'll give it a try.

NeoTrader

-
[/quote]
Big Be
Trader
Posts: 52
Joined: Thu Nov 01, 2012 6:12 pm

Re: Coding for beginners - this is how Steve started

Post by Big Be »

New Bar Check

traderduke,
That seems kind of complicated to me.
I use this:

datetime BarTime = 0;

Start()
{
//Code//

if(BarTime != Time[0])
{

//Code to only run once at new bar//

BarTime = Time[0];
}

//Code//

}

It will work in any function.

Big Be
"Big Be"
jjasper7
Trader
Posts: 87
Joined: Mon Mar 19, 2012 11:44 pm
Location: Mesa,AZ (near Phoenix)

Coding for beginners - this is how Steve started

Post by jjasper7 »

does anyone know of a code 'debuger' that is available to help follow down thru a program, perhaps stopping at set breakpoints, and allowing me to interrogate variables. it would sure help to be able to check 0ut new code, and follow the logic step by step.
jjasper7
Trader
Posts: 87
Joined: Mon Mar 19, 2012 11:44 pm
Location: Mesa,AZ (near Phoenix)

Coding for beginners - this is how Steve started

Post by jjasper7 »

another stupid question... i have forgotten how to download a program. j just went to 'just made an ide for mql4' and i do not see the file(s) to download or instructions to activate the 'ide'. please guide me.
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Coding for beginners - this is how Steve started

Post by SteveHopwood »

What a trip down memory lane reading this thread has been - I was minded to do so after sending a link to a member interested in getting started in coding.

To think that I have been using Gary's CloseEnough() function for over three years. It only feels like yesterday that he introduced me to it. My memory tells me that I did not understand first time around as well. :xm:

I see there have been a fair few downloads of the various zips around here. It would be great if people happily coding away for themselves these days got their start via CodersGuru here.

:xm:
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
Lotuscode
Posts: 3
Joined: Sat Dec 26, 2015 6:18 pm
Location: Belgium

Coding for beginners - this is how Steve started

Post by Lotuscode »

Perfect info for a beginner. Thanks for sharing guys.
mcbusrider
Trader
Posts: 23
Joined: Sun Mar 15, 2015 4:37 pm

Coding for beginners - this is how Steve started

Post by mcbusrider »

Great resource for just starting out in MQL4 coding - thanks everyone! :clap:

My background is amateur coder, coming to MQL4 from Python.

I'd probably pitch myself at beginner to intermediate level nowadays.

I've been messing around with the Oanda REST API for a couple of years and wrote a couple of scripts using the Oandapy Python wrapper module - here's the thread:

http://www.stevehopwoodforex.com/phpBB3 ... =64&t=4286

Looking forward to getting stuck into MQL4! I'm wading through a JavaScript Full Stack course on Treehouse at the moment, this little baby is next on the list.

The fog of confusion has been lifting of late, but by all accounts MQL4 should plunge me straight back into the mist... :arrrg:

Happy coding!

Nige
Post Reply

Return to “Coding Lessons - info for all”