Expert Advisors - time scale. - page 2

 
 

Thanks, I note what you're both saying about having to keep track of trades with the "magic" number and will deal with that once I can get this holding onto a position for any length of time.

But I still can't see what's causing the first trade to close out immediately, and for no further trades to be executed.

The full Buy criteria are MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDOpenLevel*Point) && MaCurrent>MaPrevious

and the Buy close criteria is MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious && MacdCurrent>(MACDCloseLevel*Point)

So to buy MACD must be negative and to close out a buy MACD must be positive. These can't be the case at the same time. I'm assuming that && means AND in this language so trades should not be being opened and closed on the same tick because of the condition that you've selected, WHRoeder.

I've checked the value of Point for Brent Crude and it is 0.01. (I inserted the line

Print(MacdCurrent," ", Point);

for this purpose). So my trailing stop at 30*Point will be 30 pips below the current price, much wider than the 5 pips spread on my platform.

So I'm still stumped.

 

Thanks, Ill put some time into reading that tomorrow. Maybe I'm trying to jump into this before fully understanding it.
 

The article was not very helpful tbh.

So let's get this down to basics. Here's the code for an ultra simple advisor I've written:

int start()
{int ticket;
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask- 2000*Point,Ask+2000*Point,"macd sample",16384,0,Green);
  
   return(0);
  
  }
// the end.

This should simply buy on every tick. Again of course it simply makes one trade, closes it, then stops. Here's the result from the Journal:

2011.01.27 09:49:04 2011.01.03 00:00 Tester: order #1 is closed

2011.01.27 09:49:04 2011.01.03 00:00 Ultrabasic GBPUSDSB,M15: open #1 buy 1.00 GBPUSDSB at 1.55428 sl: 1.53428 tp: 1.57428 ok

the Results tab says that the trade was closed at the Stop. My stop was at 1.53428 which the price certainly wasn't at. What is the problem?

 
I phoned up the broker and found out the answer. My account is in GBP and you have to set the currency under Expert Properties/Testing to GBP. Previously it had been in USD. Now it works as expected.
Reason: