Hi,
I have been working on a strategy that opens an order when Close(0) crosses up at least 6 points above a moving average, but the high seems to be triggering the order.
I printed out the Open, High, Low and Close and noticed that the Close(0) always equals the High(0). Is that normal?
Thanks,
Carl
PS On further testing I've noticed that the current bar's Close(0) is the same as the current bar's High(0), but on the next bar when it becomes the previous bar, its Close(1) is now accurate.
Think I can fix this by using a simple moving average of 1 period instead of the Close(0).
Thanks again...
Open-High-Low-Close
- Terranin
- Site Admin
- Posts: 833
- Joined: Sat Oct 21, 2006 4:39 pm
Re: Open-High-Low-Close
carlphillips wrote:Hi,
I have been working on a strategy that opens an order when Close(0) crosses up at least 6 points above a moving average, but the high seems to be triggering the order.
I printed out the Open, High, Low and Close and noticed that the Close(0) always equals the High(0). Is that normal?
Thanks,
Carl
PS On further testing I've noticed that the current bar's Close(0) is the same as the current bar's High(0), but on the next bar when it becomes the previous bar, its Close(1) is now accurate.
Think I can fix this by using a simple moving average of 1 period instead of the Close(0).
Thanks again...
It is something wrong, can you provide your code? Because for me it was not equal, though it could be equal if you use some generation mode when bar goes up tick by tick - then it is possible. But if you generate ticks by o/h/l/c it should not.
Hasta la vista
Mike
Mike
-
- Posts: 7
- Joined: Mon Jan 07, 2008 9:00 am
Re: Open-High-Low-Close
Terranin wrote:carlphillips wrote:Hi,
I have been working on a strategy that opens an order when Close(0) crosses up at least 6 points above a moving average, but the high seems to be triggering the order.
I printed out the Open, High, Low and Close and noticed that the Close(0) always equals the High(0). Is that normal?
Thanks,
Carl
PS On further testing I've noticed that the current bar's Close(0) is the same as the current bar's High(0), but on the next bar when it becomes the previous bar, its Close(1) is now accurate.
Think I can fix this by using a simple moving average of 1 period instead of the Close(0).
Thanks again...
It is something wrong, can you provide your code? Because for me it was not equal, though it could be equal if you use some generation mode when bar goes up tick by tick - then it is possible. But if you generate ticks by o/h/l/c it should not.
I've included a screen snapshot. If you look at the far right you'll see an example. The buy is 3 pips (normal spread) above the high, but the close is below the SMA so it shouldn't have triggered. Also, you can see the order below at the top of the journal. I printed out the open/high/low/close for (0) and (1). You can see that Close(0) is the same as High(0), but Close(1) is not the same as High(1).
I've also included TestStrategy.zip that contains the dpr file of the strategy. It does a fairly simple Close(0) crossing up through a 50 period SMA +6pips to trigger the buy.
I'm importing data from GFT Forex using a converter that I wrote in Java. The following is a few lines of the unconverted GFT Forex data:
---------------------
Chart data: EUR/USD, Aggregate list (1 min) at 03.03.2008 01:54:51.872
Time Open High Low Close
30.12.2007 16:00:00.000 1.4715 1.4716 1.4715 1.4715
30.12.2007 16:01:00.000 1.4714 1.4715 1.4711 1.4711
30.12.2007 16:02:00.000 1.4710 1.4710 1.4709 1.4709
30.12.2007 16:03:00.000 1.4709 1.4710 1.4709 1.4710
---------------------
The following are a few lines of the same file converted for ForexTester:
---------------------
30122007 16:00 1.4715 1.4716 1.4715 1.4715
30122007 16:01 1.4714 1.4715 1.4711 1.4711
30122007 16:02 1.4710 1.4710 1.4709 1.4709
30122007 16:03 1.4709 1.4710 1.4709 1.4710
=============
I'm just removing the top header lines and converting the date and time format.
You'll notice that there is no volume data. GFT Forex doesn't supply that when exporting. Is this a problem in ForexTester? I can always make up some volume data during the conversion.
Thanks,
Carl...
- Attachments
-
- TestStrategy.zip
- Strategy code
- (1.42 KiB) Downloaded 893 times
-
- Screen shot
- screen.jpg (285.5 KiB) Viewed 10726 times
- Terranin
- Site Admin
- Posts: 833
- Joined: Sat Oct 21, 2006 4:39 pm
This situation could be possible because of your condition
if (OrderHandle = -1) and
(crossup = True) and
(Close(0) >= (smaSlow0 + 0.0006)) and
(Close(0) > smaFast) then
begin
you print your values when bar goes up, so in this case close should be equal to high or somewhere there, because bar is growing. If you print your values just after
// set currency and timeframe
SetCurrencyAndTimeframe(Symbol, TimeFrame);
you will get different situation (but be careful, so many messages could overflow the Journal).
if (OrderHandle = -1) and
(crossup = True) and
(Close(0) >= (smaSlow0 + 0.0006)) and
(Close(0) > smaFast) then
begin
you print your values when bar goes up, so in this case close should be equal to high or somewhere there, because bar is growing. If you print your values just after
// set currency and timeframe
SetCurrencyAndTimeframe(Symbol, TimeFrame);
you will get different situation (but be careful, so many messages could overflow the Journal).
Hasta la vista
Mike
Mike
-
- Posts: 7
- Joined: Mon Jan 07, 2008 9:00 am
This makes perfect sense (really), now that I think about it. The close, in the classic form, won’t exist until the current bar closes. So, I shouldn’t test the close until the first tick of the next bar. I should be using Close(1) within the GetSingleTick loop.
Don't worry about the print statements. Just debugging over a very short time frame without a runtime debugger.
Thanks again,
Carl...
PS Now all I need to do is calculate the slope of a single point on a curved line (SMA).
Don't worry about the print statements. Just debugging over a very short time frame without a runtime debugger.
Thanks again,
Carl...
PS Now all I need to do is calculate the slope of a single point on a curved line (SMA).
Who is online
Users browsing this forum: No registered users and 31 guests