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

Please help with utility ea
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4332
Page 1 of 1
Author:  jcs [ Wed Jul 01, 2015 9:58 am ]
Post subject:  Please help with utility ea

Hi all

I am a total coding virgin

I have a very useful utility ea ( for me anyway ) that simply places an order in the selected diretion at the open of the next candle ( every candle )
I have looked everywhere on the web for a revised version that meets my requirements, with no luck
I have also tried my hamfisted cut and paste coding from other ea's but can not get the darn thing to work as I need

I would like the ea to place orders as follows :-

If OpenShort is selected - only place order if the previous candle was a BULL candle
If OpenLong is selected - only place order if the previous candle was a BEAR candle

Can some kind soul help me please
Thank you

Code: Select all

extern double LotSize    = 0.5;
extern bool   OpenShort  = true;
extern bool   OpenLong   = true;
extern int    Slippage   = 3;
extern double StopLoss   = 100;
extern double TakeProfit = 100;

int init()   { return(0); }
int deinit() { return(0); }
int start()
{
   static datetime prevTime = 0;
      if (prevTime==Time[0] || prevTime==0) 
      {
         prevTime=Time[0]; 
         return(0); 
      }
   double point = Point*MathPow(10,MathMod(Digits,2));
      if (OpenLong)  OrderSend(Symbol(),OP_BUY ,LotSize,Ask,Slippage,Ask-StopLoss*point,Ask+TakeProfit*point,"",0,0,CLR_NONE);
      if (OpenShort) OrderSend(Symbol(),OP_SELL,LotSize,Bid,Slippage,Bid+StopLoss*point,Bid-TakeProfit*point,"",0,0,CLR_NONE);
   prevTime=Time[0]; 
   return(0);
}
Author:  AnotherBrian [ Wed Jul 01, 2015 3:45 pm ]
Post subject:  Please help with utility ea

If your broker is ECN then you need to place the order in 2 steps. First place the order without stops or targets. The use ordermodify to modify the order with target and stop (at same time)

Look in Steve's code where he uses IsECNorGlobalPrime and you will see the code for that. Cheers for trying!!
Keep it up.
Author:  SteveHopwood [ Wed Jul 01, 2015 4:31 pm ]
Post subject:  Please help with utility ea

Here you are - took a couple of minutes using one of my shells so most of the usual stuff is there.

MaxTradesAllowed allows you to limit the number of trades the ea sends, so set it ridiculously high to disable the feature.

TradeLong/Short tells the bot which way to trade.

I haven't bothered to test this, so sing out if it doesn't work as expected.

:xm:
Author:  jcs [ Wed Jul 01, 2015 8:19 pm ]
Post subject:  Please help with utility ea

SteveHopwood » Wed Jul 01, 2015 4:31 pm wrote:Here you are - took a couple of minutes using one of my shells so most of the usual stuff is there.

MaxTradesAllowed allows you to limit the number of trades the ea sends, so set it ridiculously high to disable the feature.

TradeLong/Short tells the bot which way to trade.

I haven't bothered to test this, so sing out if it doesn't work as expected.

:xm:
Steve
Thanks for looking at this for me
The ea is not placing any trades
It loads ok and there are no error messages or any other messages in tabs other than confirmation the ea has initialized ... just no trades
Looks like it is not attempting to place trades ?
Author:  SteveHopwood [ Wed Jul 01, 2015 9:24 pm ]
Post subject:  Please help with utility ea

Oops.

Thee is a line of code in my shell that stops the trade sending function whilst I am developing my code. It's comment is "REMEMBER TO DELETE THIS".

I forgot to delete it. :arrrg:

This one should send trades.

:xm:
Author:  jcs [ Thu Jul 02, 2015 1:05 am ]
Post subject:  Please help with utility ea

SteveHopwood » Wed Jul 01, 2015 9:24 pm wrote:Oops.

Thee is a line of code in my shell that stops the trade sending function whilst I am developing my code. It's comment is "REMEMBER TO DELETE THIS".

I forgot to delete it. :arrrg:

This one should send trades.

:xm:

Thankyou Steve

For the purposes of testing I have upped slippage to 10 to take this out of the equation
I have max trades at 100
All filters set to false

On 15 min timeframe the logic and trade entry seem to be perfect, so presumably this will be the same on higher timeframes
On the 5 minute timeframe trades are placed erratically, with many bars not having any trade as per the logic

As for me I will be unlikely to use this below 15 minutes, so all ok as is
Others are downloading the ea, so maybe you would want to try and resolve this for all ?

There is one issue I do need to resolve
As part of my standard set up I have an indicator called " ConPro "
If you are not familiar with it, what it does is show with a dynamic horizontal line the Buy average and Sell average positions seperately ( not summed as per Bob's 10.7 Line Of Zero ), together with a text display of profit and loss for buy and sell trades
This is very important to me

When I use the original ea with this indicator all works fine
But when I use the jcs utilty ea the Con Pro indicator does not function at all
I asume there must be something in the extensive ea code conflicting with the indicator code

Any Ideas what this could be ?
I am attaching the Con Pro indicator so you can have a look at the code, if you would be so kind

Really appreciate your help Steve
Author:  SteveHopwood [ Thu Jul 02, 2015 6:14 pm ]
Post subject:  Please help with utility ea

You will need to go into the ea's DisplayUserFeedback() function and turn off the chart feedback with return; right at the start of the function.

:xm:
Author:  jcs [ Fri Jul 03, 2015 12:54 am ]
Post subject:  Please help with utility ea

SteveHopwood » Thu Jul 02, 2015 6:14 pm wrote:You will need to go into the ea's DisplayUserFeedback() function and turn off the chart feedback with return; right at the start of the function.

:xm:
OK, many thanks
All times are UTC Page 1 of 1