iADX scripting question

 
I'm just starting to learn writing EA script. So, forgive me for such a newbie question.

I'm using iADX. And part of my code:

[script]
CurrentADX = iADX(NULL, 15, PeriodADX, PRICE_CLOSE, MODE_MAIN, 0);
PreviousADX = iADX(NULL, 15, PeriodADX, PRICE_CLOSE, MODE_MAIN, 1);

// BUY
if (CurrentADX > 25 && PreviousADX < 25) {
// other script
}
[/script]

Image attached is created after I run the script tester. You can see that BUY order opened on 2008.05.08 03:18 at price 204.80 (#1), and it was closed by 30 stop loss at 204.50 (#2) -- Highlited.

My question is:
Vertical Navy dashed line marked 03:18, when the order placed. And horizontal navy dashed line is the price when order opened.

1. My condition is to open an order when CurrentADX (LightSeaGreen line) is more than 25 level. But, in the image we can see that ADX line never crossed 25 level. How could this happened?

2. The highest price at that bar is 204.73. Why order opened at the 204.80?

Thanks in advance.


Regards,

bgrtz

 
CurrentADX = iADX(NULL, 15, PeriodADX, PRICE_CLOSE, MODE_MAIN, 0);
PreviousADX = iADX(NULL, 15, PeriodADX, PRICE_CLOSE, MODE_MAIN, 1);

// BUY
if (CurrentADX > 25 && PreviousADX < 25) {
  // other script

}

a little DIY for you:

1. use the Print() function to discover exactly what values are being returned from iADX()

2. as 1, but for all values given to OrderSend()


The Print() function is great way to actually 'see' what the program is calculating and also passing into called functions.


To do testing like above, is not actually required to make call to a trading operation function - just do the print stuff and then return(0); before call

Why? your real aim is to 'see' that o/p in the Terminal window > Expert tab, not actually make the order. Is already established that something is at issue in this code area - what's needed is as much data as can be obtained at this area at time of code execution. Then your job is in effect so much easier because all live data printed...


Print anything can think of - after all, the program always does exactly what coder codes. Is just not good enough to look at code and assume that it is OK. Again, the program does exactly what one tells it to do and it's our job to fully embrace this idea - then locating code issues becomes a lot more fun/lessStressful:) and loads easier!


Unless one prints/displays/whatever ALL datums that are used in identified suspect code area - just how can one be 100% positive that at code execution time what one assumes is exactly what gets computed?


MQL4 or any programming language for that matter, is the last place to end search for where to point the angry finger of blame! :)


I assure you that your efforts will be rewarded...


:o)

Reason: