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

Some help for a newbie
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=1527
Page 1 of 2
Author:  Nufty [ Sat Feb 23, 2013 2:58 am ]
Post subject:  Some help for a newbie

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
Author:  mjws00 [ Sat Feb 23, 2013 7:27 am ]
Post subject:  Re: Some help for a newbie

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
Author:  Nufty [ Sun Feb 24, 2013 2:21 am ]
Post subject:  Re: Some help for a newbie

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
Author:  Nufty [ Sun Feb 24, 2013 10:14 am ]
Post subject:  Re: Some help for a newbie

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!!!
Author:  Nufty [ Sun Feb 24, 2013 11:40 am ]
Post subject:  Re: Some help for a newbie

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
Author:  Nufty [ Sun Mar 03, 2013 12:09 am ]
Post subject:  Re: Some help for a newbie

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)
Author:  mjws00 [ Sun Mar 03, 2013 1:25 am ]
Post subject:  Re: Some help for a newbie

void DisplayUserFeedBack() is not defined. Your first function. Just the braces {} are there
Author:  Nufty [ Sun Mar 03, 2013 2:08 am ]
Post subject:  Re: Some help for a newbie

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
Author:  mjws00 [ Sun Mar 03, 2013 3:01 am ]
Post subject:  Re: Some help for a newbie

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;
Author:  NeoTrader [ Sun Mar 03, 2013 9:12 am ]
Post subject:  Re: Some help for a newbie

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

-
All times are UTC Page 1 of 2