Some help for a newbie

User avatar
Nufty
Trader
Posts: 39
Joined: Fri Feb 15, 2013 9:21 pm

Some help for a newbie

Post by Nufty »

So, I think I can dance

Umm... I mean code!

I have been thinking about learning this coding game for a while, and when a friend was quoted by one of those Russian online coders over $500 to code a very simple system I told him I would give it a go.

and I failed...

(Wife would have added "naturally" at the end of that line)

I have created an EA from one I have been using for a while (may have saved me a hundred hours if I used the template Steve posted here) and it compiled for me (after a million errors)

But it wont take trades

Which I assume means my logic is wrond.

this is what I have at the moment

Code: Select all

// Open a BUY when the price is above ALL 3 SMAs, and the two most recent completed bars have an open below their close, and the current bar has 2 pip movement from open in the LONG direction. 

// My attempt to show BUY

   if(Open[2] < Close[2] && Open[1] < Close[1] && Open[0] < (Open[0] + 2) && SMA1_Period < Open[2] && SMA2_Period < Open[2]   &&  SMA3_Period < Open[2])
   {
      ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask-StopLossPips,Ask+TakeProfitPips,"Viks_Three_Little_Ducks",MagicNumber,0,Green);
     if(ticket<0)
       {


it reads like I would think it

but that doesnt mean the Empty4 platform has a clue what I mean

Someone want to show me the errors of my ways

Appreciate any help

Thanks

Nufty
User avatar
mjws00
Trader
Posts: 609
Joined: Fri Jan 04, 2013 10:17 pm
Location: Victoria

Re: Some help for a newbie

Post by mjws00 »

Here is a way to test and check your work. Unfortunately Empty4 throws us back to the stoneage.

Code: Select all

//Here is an easy way to troubleshoot these nested Conditions...

if(Open[2] < Close[2])
{
	Print("3rd Candle Open < Close");
	if( Open[1] < Close[1])
	{
		Print("Second Candle Open < Close");
		if(Open[0] < (Open[0] + 2 * Point ) //You need to get the pip value. This will depend on pair.
		{
			Print("Open was " + 2* Point+ " pips away from open");
			if(SMA1_Period < Open[2]) //SMA1 Value must be calculated somewhere else
			{
				Print("Next condition met");
				if(adnauseaum...............)
				{
					Print("All conditions met sending order here.");
					ticket= OrderSendFunction();
				}
			}
		}
	}
}

//Alternate
if(Open[2] < Close[2]) Print("3rd Candle Open < Close");
if( Open[1] < Close[1]) Print("Second Candle Open < Close");
//Troubleshooting is stoneage on this platform
//But you need to make sure there is no logic error in your conditions
Good Luck
Reading the dark heart.
User avatar
Nufty
Trader
Posts: 39
Joined: Fri Feb 15, 2013 9:21 pm

Re: Some help for a newbie

Post by Nufty »

mjws00 wrote:Here is a way to test and check your work. Unfortunately Empty4 throws us back to the stoneage.

Code: Select all

//Here is an easy way to troubleshoot these nested Conditions...

if(Open[2] < Close[2])
{
	Print("3rd Candle Open < Close");
	if( Open[1] < Close[1])
	{
		Print("Second Candle Open < Close");
		if(Open[0] < (Open[0] + 2 * Point ) //You need to get the pip value. This will depend on pair.
		{
			Print("Open was " + 2* Point+ " pips away from open");
			if(SMA1_Period < Open[2]) //SMA1 Value must be calculated somewhere else
			{
				Print("Next condition met");
				if(adnauseaum...............)
				{
					Print("All conditions met sending order here.");
					ticket= OrderSendFunction();
				}
			}
		}
	}
}

//Alternate
if(Open[2] < Close[2]) Print("3rd Candle Open < Close");
if( Open[1] < Close[1]) Print("Second Candle Open < Close");
//Troubleshooting is stoneage on this platform
//But you need to make sure there is no logic error in your conditions
Good Luck
Thanks for the reply

I was trying to think of a way to use Print to bug check, so I really do appreciate the assistance

I will see how it goes!

N
User avatar
Nufty
Trader
Posts: 39
Joined: Fri Feb 15, 2013 9:21 pm

Re: Some help for a newbie

Post by Nufty »

Nufty wrote:
mjws00 wrote:Here is a way to test and check your work. Unfortunately Empty4 throws us back to the stoneage.

Code: Select all

//Here is an easy way to troubleshoot these nested Conditions...

if(Open[2] < Close[2])
{
	Print("3rd Candle Open < Close");
	if( Open[1] < Close[1])
	{
		Print("Second Candle Open < Close");
		if(Open[0] < (Open[0] + 2 * Point ) //You need to get the pip value. This will depend on pair.
		{
			Print("Open was " + 2* Point+ " pips away from open");
			if(SMA1_Period < Open[2]) //SMA1 Value must be calculated somewhere else
			{
				Print("Next condition met");
				if(adnauseaum...............)
				{
					Print("All conditions met sending order here.");
					ticket= OrderSendFunction();
				}
			}
		}
	}
}

//Alternate
if(Open[2] < Close[2]) Print("3rd Candle Open < Close");
if( Open[1] < Close[1]) Print("Second Candle Open < Close");
//Troubleshooting is stoneage on this platform
//But you need to make sure there is no logic error in your conditions
Good Luck
Thanks for the reply

I was trying to think of a way to use Print to bug check, so I really do appreciate the assistance

I will see how it goes!

N
Thanks for the advice

I have some work to do on my variables

First problem is to get the SMA values to be recognised

Back to the drawing board!!!
You do not have the required permissions to view the files attached to this post.
User avatar
Nufty
Trader
Posts: 39
Joined: Fri Feb 15, 2013 9:21 pm

Re: Some help for a newbie

Post by Nufty »

Ok - I have made the EA take trades - but there are a lot of problems with stop loss, and money management

SO

I am starting again with Steves "shell" code to see if this helps

Wish me luck!

Nufty
User avatar
Nufty
Trader
Posts: 39
Joined: Fri Feb 15, 2013 9:21 pm

Re: Some help for a newbie

Post by Nufty »

Steves shell code was far too advanced for me

When I deleted things I didnt need it caused me too much grief on compiling

So I am back to the drawing board...using bits and pieces from others codes (Steves included)

I feel I am close

I am down to one last error


I have spent too many hours on this now so I need a little help - I have attached my file

What I do understand is I have taken the problematice snippet of code from a fully working and compiled EA - but it is giving me compile errors

Can anyone let me know why???

Error is

'error' - internal error and points to line 484

this snippet

Code: Select all

//+------------------------------------------------------------------+
bool IsCriticalError( int error)
   {
	switch( error)
	{
		case 4:	Print("Server is busy, will try again");
					return(false);  
		case 135:Print("Price has changed, will try again");
					return(false);  
		case 136:Print("No prices, will try again");
					return(false);  
		case 137:Print("Broker is busy, will try again");
					return(false);  
		case 146:Print("Terminal is busy, will try again");
					return(false);  
      case  2: Print("General error. No trades will be made");
					return(true);  
		case  5: Print("Old version. No trades will be made");
					return(true);  
		case 64: Print("Account is blocked. No trades will be made");
					return(true);  
		case 133:Print("Trade is prohibited. No trades will be made");
					return(true);  
		case 134:Print("Insufficient funds. No trades will be made");
					return(true);  
		default: 
			break;
   }
   
   Print("Error ", ErrorDescription( error), ". No trades will be made"); 
	return(true);  
}
Any help is appreciated

I have attached the EA as well (its a work in progress - more for learning - not a serious bot)
You do not have the required permissions to view the files attached to this post.
User avatar
mjws00
Trader
Posts: 609
Joined: Fri Jan 04, 2013 10:17 pm
Location: Victoria

Re: Some help for a newbie

Post by mjws00 »

void DisplayUserFeedBack() is not defined. Your first function. Just the braces {} are there
Reading the dark heart.
User avatar
Nufty
Trader
Posts: 39
Joined: Fri Feb 15, 2013 9:21 pm

Re: Some help for a newbie

Post by Nufty »

mjws00 wrote:void DisplayUserFeedBack() is not defined. Your first function. Just the braces {} are there
thanks for the assistance mjws00.

I am searching the mql4 site now to assist me with defining it

Appreciate the assistance

Nufty
User avatar
mjws00
Trader
Posts: 609
Joined: Fri Jan 04, 2013 10:17 pm
Location: Victoria

Re: Some help for a newbie

Post by mjws00 »

Sorry man, here is the code. No need to look things up. Just this line: void DisplayUserFeedback() context around it so you can see where.

Code: Select all

//Code Snippet from Steve Hopwoods shell EA code - Thanks Steve
void DisplayUserFeedback()
{
   if (IsTesting() && !IsVisualMode()) return;
Reading the dark heart.
User avatar
NeoTrader
Trader
Posts: 436
Joined: Wed Apr 04, 2012 2:52 pm
Location: small Village at Lake Chiemsee, Bavaria, Germany

Re: Some help for a newbie

Post by NeoTrader »

hi nufty,
Nufty wrote:I am searching the mql4 site now to assist me with defining it
This function is present in almost all of Steve's EAs. Just copy and paste it from there and adapt it to your needs. Alternatively if you don't want or need this function just comment it out (//).

happy weekend,

Robert

-
Post Reply

Return to “Coders Hangout”