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

Gday: a D1 Stochastic OB/OS trading robot
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=168
Page 68 of 71
Author:  Caillou [ Wed Oct 10, 2012 9:14 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

MultiGday is not closing trades correctly: AUD/USD closed this morning 1/3 at 50 pips (ok) but AUD/CAD just closed 3/3 (0.03 lot) at 50 pips......
Anyway I will go on with MultiGday waiting for Steve's new bot.

Cheers
Author:  garyfritz [ Wed Oct 10, 2012 9:33 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

gaheitman wrote:
garyfritz wrote:If so, then you wouldn't need to check every minute to get the "highest stoch." Just use the daily High in the calculation.
Sure, but then you'd have to write your own stochastics code instead of just calling iStochastics() 1440 times a day.
You could do that. It doesn't fit in well with how I've been implementing this. I have indeed been writing my own stochastics code.
It's too late in the day to be sure, but I think there could also be an issue using just the high in the cases where the bar in question is contributing to the high or the low of the 8-day range. I'll let you work out the math, since you have more hours left in your day :>
No, I'm sure -- the highest stoch yesterday is (YestHigh-8DayLow) / (8DayHigh-8DayLow). If YestHigh happens to be the high of the 8-day range, you'll have a stoch of 100, which is what you want. If yesterday's bar contributes to the 8-day high/low, that gets included in 8DayHigh or 8DayLow.

...oh wait. That gives you the highest RAW stoch today. Presumably we want the highest SMOOTHED stoch value, which for a 7,2,2 stoch is run through two 2-bar SMAs. Crud. I may have to resort to calling the Stochastics code every minute after all. I've already been cheating by calculating EMAs instead of using SMAs.

Tradestation calculates EMAs/SMAs on a bar-by-bar basis. E.g. the average(X,N) function calculates SMA of X for the last N bars. But I've been running this on intraday bars so I have good resolution of when it hits which stops, I can move stops to BE as soon as it hits the key levels, etc. So I'm not running daily bars so I can't easily calculate an SMA on my stoch values. Having watched it for a while, that may be unnecessary. Maybe I'll just rewrite the silly thing to run on daily bars and be done with it...
Author:  w633 [ Wed Oct 10, 2012 10:36 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

Caillou wrote:MultiGday is not closing trades correctly: AUD/USD closed this morning 1/3 at 50 pips (ok) but AUD/CAD just closed 3/3 (0.03 lot) at 50 pips......
Anyway I will go on with MultiGday waiting for Steve's new bot.

Cheers
never seen this happen before, but it could be due to volatility TP / SL, you can either set VolatilityPeriod to be zero or set StaticTakeProfit to disable volatility TP.
Author:  MiTija [ Wed Oct 10, 2012 10:59 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

garyfritz wrote:
gaheitman wrote:
garyfritz wrote:
<snip>

...oh wait. That gives you the highest RAW stoch today. Presumably we want the highest SMOOTHED stoch value, which for a 7,2,2 stoch is run through two 2-bar SMAs. Crud. I may have to resort to calling the Stochastics code every minute after all. I've already been cheating by calculating EMAs instead of using SMAs.

Tradestation calculates EMAs/SMAs on a bar-by-bar basis. E.g. the average(X,N) function calculates SMA of X for the last N bars. But I've been running this on intraday bars so I have good resolution of when it hits which stops, I can move stops to BE as soon as it hits the key levels, etc. So I'm not running daily bars so I can't easily calculate an SMA on my stoch values. Having watched it for a while, that may be unnecessary. Maybe I'll just rewrite the silly thing to run on daily bars and be done with it...
I know that programming anything other than end of bar style code in tradestation has been an issue since it was created. I suggest either:

1) you abandon easylanguage and write your own dll for tradestation.

or

2) get a platform like NinjaTrader that interfaces to tradestation, but is more flexible with intra-bar coding.

I suspect it is the only way you are going to create a precise and exact copy of how the Empty4 code executes. It is probably the only way to get a fair set of backtest.

Best Regards,


MiTija
Author:  garyfritz [ Wed Oct 10, 2012 11:44 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

Oh, it's not THAT difficult. Worst case I can set it to an "every tick" mode and it will run more like Empty4. But that's very high-overhead for long backtests.

Or I could write it to run every minute, like George suggests.

Or I could just get sneaky and do what I did -- use a little trick to refer to "open of next bar." :twisted: If you set it up right, you can access the opening tick of the next bar at the close of the previous. I can use that to run at the close of the day, calculate today's high/low stoch, calculate "tomorrow's" opening stoch, and decide if I want to "enter at open of next bar." Pretty simple really...
Author:  garyfritz [ Thu Oct 11, 2012 2:59 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

@#%!! I'm still not sure how to express this entry rule. This logic is simple if I only look at the closing stoch. But I can't seem to figure out how to define a long or short entry rule using both open AND close/midday stoch.

According to TS, in EURUSD "yesterday's high stoch" was >= 80 and "today's open stoch" was < 80 on every day from August 31 through Sept. 7. The "high stoch" stayed high while the "open stoch" kept trying to go down. It was giving a "sell" signal every day while the market was running up 150 pips. And on e.g. 8/31 and 9/1 it gave both buy AND sell signals!!

Obviously that's not a good signal on its own. I think the "high/low stoch" idea doesn't work, if it can give long and short signals at the same time.

How about if we look just at the open stoch? If open stoch goes >= 80 and then < 80, sell? Or maybe if yesterday's open stoch OR yesterday's close stoch was >= 80? Neither seems to work very well...

I give up for now. I've spent way too many hours on this and so far it's working a lot worse than the "close stoch to close stoch" model I was using before. :(
Author:  gaheitman [ Thu Oct 11, 2012 4:00 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

garyfritz wrote:@#%!! I'm still not sure how to express this entry rule. This logic is simple if I only look at the closing stoch. But I can't seem to figure out how to define a long or short entry rule using both open AND close/midday stoch.

According to TS, in EURUSD "yesterday's high stoch" was >= 80 and "today's open stoch" was < 80 on every day from August 31 through Sept. 7. The "high stoch" stayed high while the "open stoch" kept trying to go down. It was giving a "sell" signal every day while the market was running up 150 pips. And on e.g. 8/31 and 9/1 it gave both buy AND sell signals!!

Obviously that's not a good signal on its own. I think the "high/low stoch" idea doesn't work, if it can give long and short signals at the same time.

How about if we look just at the open stoch? If open stoch goes >= 80 and then < 80, sell? Or maybe if yesterday's open stoch OR yesterday's close stoch was >= 80? Neither seems to work very well...

I give up for now. I've spent way too many hours on this and so far it's working a lot worse than the "close stoch to close stoch" model I was using before. :(
You had me convinced with your confidence, but I don't think you can use the high and low of the previous bar to get the highest/lowest stoch value. :)

Take the case where the initial stoch is around 40 in real-time and price goes down a bit to print a stoch of 30. Then price goes up and breaks out of the overall stoch period's range. With a higher overall range, the low that hit a stoch of 30 based on the smaller range will be pushed lower as you extend the range higher. Using the low after the fact will cause the calculated stoch to be less than the real stoch was at the time the low was reached.

For example, with an existing range of 100 pips, if we are around 30 pips from the bottom of that range, we are around 30 stoch. If we shoot up 170 pips from there, our range is now 200 pips, so that low is now around a 15 stoch when you calculate it after the fact.

This sort of thing is why I never look at anything with shift = 0. :D

George
Author:  garyfritz [ Thu Oct 11, 2012 4:36 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

gaheitman wrote:For example, with an existing range of 100 pips, if we are around 30 pips from the bottom of that range, we are around 30 stoch. If we shoot up 170 pips from there, our range is now 200 pips, so that low is now around a 15 stoch when you calculate it after the fact.
I see your point. I was only thinking of one direction, e.g. just high or low. Didn't think about what would happen in a case like you're describing.

In any case I gave up on that and tried for simpler definitions and they still didn't work worth a darn. :?
Author:  Caillou [ Thu Oct 11, 2012 7:07 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

w633 wrote:
Caillou wrote:MultiGday is not closing trades correctly: AUD/USD closed this morning 1/3 at 50 pips (ok) but AUD/CAD just closed 3/3 (0.03 lot) at 50 pips......
Anyway I will go on with MultiGday waiting for Steve's new bot.

Cheers
never seen this happen before, but it could be due to volatility TP / SL, you can either set VolatilityPeriod to be zero or set StaticTakeProfit to disable volatility TP.
VolatilityPeriod was already set to 0. Anyway it's closing trades correctly now.

Thank you Will
Author:  acostafulano [ Fri Oct 12, 2012 2:02 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

Hi guys, for whatever reason I'm getting a zerodivide error when setting up MultiGDay... I'm using lot size 0.03 already, no clue what else I need to change.

Any help is greatly appreciated :)
All times are UTC Page 68 of 71