Gday: a D1 Stochastic OB/OS trading robot

Locked
User avatar
snowy
Trader
Posts: 37
Joined: Mon Feb 20, 2012 11:58 pm

Re: Gday: a D1 Stochastic OB/OS trading robot

Post by snowy »

acostafulano wrote:Once some trades are missed due to trade context busy errors, does the code manage to pick up the signals again and enter the trades after, making the bot trade "as it was supposed to"? Or are those trades simply missed forever?
steve's version: no, sadly those trades are not taken again. after a few retries the script gives up.
multi-version: no problems with trade context busy so far. the handling with orderreliable is very good.
garyfritz wrote: I suspect that it may be better to exit at on TP at 150 pips anyway. I've seen very few trades that took the JS past 150 -- maybe 1 trade in 10, probably less -- but MANY trades that got to 150+ and then fell back to 100. Every once in a while (like maybe 1% of the time) you get a whopper win with the jumping stop, but I doubt it comes out ahead of a 150pip TP.
yes i think you're right, shelley's expired demo confirms that. maybe it could be a good idea to setup the implemented trailingstop to trigger at +165 pips and trail with 15 pips? should be tested..
User avatar
alex_forex
Trader
Posts: 438
Joined: Tue Nov 15, 2011 5:46 pm
Location: F R A N C E

Re: Gday: a D1 Stochastic OB/OS trading robot

Post by alex_forex »

snowy wrote:
alex_forex wrote:
Hi Snowy,

Not sure about the settings to trade only at 00:00 // new D1 candle

Can you explain me how you done that :mrgreen:

Thanks

Kind regards
Alex
i just put it on a D1 chart ;)
:lol:
It was just a little too simple :mrgreen:

Cheers Snowy

Alex
garyfritz

Re: Gday: a D1 Stochastic OB/OS trading robot

Post by garyfritz »

Shelley, MiTija has pointed out that I may have misunderstood the way Gday is supposed to work.

Tradestation systems run on the close of the bar. I've been using the stoch of the **CLOSE** of the daily bar, and looking to see if that's crossed 80 or 20. So e.g. I look to see if the stoch at yesterday's close was > 80 and the stoch at today's close is < 80. I figured looking at the close-to-close change in stoch was going to be nearly identical to the open-to-open change in stoch.

MiTija says no, you're looking and the stoch of the OPEN of a daily bar, and comparing to the stoch at the CLOSE of yesterday's bar. So if stoch-at-yesterday's-CLOSE is > 80 and stoch-at-today's-OPEN is < 80, THEN you enter. When he explain this to me, I vaguely remembered you mentioning it waaayy back when you first presented Gday.

Is that right? Or do you look at the OPEN of yesterday vs. the OPEN of today?

If I understand Steve's code right, he acts on the first tick of a new D1 bar. On that first tick he calls:

Code: Select all

   StochMain = iStochastic(NULL, StochTimeFrame,K_Period,D_Period,Slowing,MODE_SMA,0,MODE_MAIN,0);
   StochSignal = iStochastic(NULL, StochTimeFrame,K_Period,D_Period,Slowing,MODE_SMA,0,MODE_SIGNAL,0);
	
   PrevStochMain = iStochastic(NULL, StochTimeFrame,K_Period,D_Period,Slowing,MODE_SMA,0,MODE_MAIN,shift);
   PrevStochSignal = iStochastic(NULL, StochTimeFrame,K_Period,D_Period,Slowing,MODE_SMA,0,MODE_SIGNAL,shift);
So presumably StochSignal gets the stoch of the OPEN of the current bar, and PrevStochSignal gets the stoch as of the CLOSE of the PREVIOUS bar. Then if PrevStochSignal >= 80 and StochSignal < 80, he enters a trade.

I'm not even quite sure what it means to calculate the stoch at the open. For clarity let's pretend we're actually using a 3-day stoch. If I calculate the stoch at the close, then that means I look at today's close compared to the High of (today, yesterday, & the day before) and the Low of (today, yesterday, & the day before). Stochastic = 100 * (Close - H(t,y,&tdb)) / (H(t,y,&tdb) - L(t,y,&tdb)).

So what does "stoch of the open" mean? At the open, the High of today and the Low of today are the same -- it's the open price. So is the "High of t,y,&tdb" actually "the max of this bar's open and the Highs of the two previous bars" ?

You may not know the internal workings of Empty4's Stochastic function -- you may just use it. :D But I need to figure out what it's doing if I'm going to test it in TS. If anybody can clarify, I'd appreciate -- else I'll have to delve into Empty4's internal workings and I'd really rather not...
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: Gday: a D1 Stochastic OB/OS trading robot

Post by gaheitman »

garyfritz wrote:So what does "stoch of the open" mean? At the open, the High of today and the Low of today are the same -- it's the open price. So is the "High of t,y,&tdb" actually "the max of this bar's open and the Highs of the two previous bars" ?
I think you should call it "stoch at the open". As you say, the open, high and low are the same, but so is the close. If you discount the smoothing, we are basically selling when yesterday's close was greater than 80% of the high-low range over the prior 8 days and today's open is less than 80% of the range over the prior 7 days. That happens when the low of the prior 8 days was exactly 8 days ago and gets dropped from our determination of the low. The stochastic "moved" lower because the range is smaller now. Or because of the smoothing we discounted earlier. :D

Right?

George

Here's the "source" of the stochastic from the good folks at Empty4: http://codebase.mql4.com/264
garyfritz

Re: Gday: a D1 Stochastic OB/OS trading robot

Post by garyfritz »

gaheitman wrote:I think you should call it "stoch at the open". As you say, the open, high and low are the same, but so is the close. If you discount the smoothing, we are basically selling when yesterday's close was greater than 80% of the high-low range over the prior 8 days and today's open is less than 80% of the range over the prior 7 days.
Yes, I think that's right.
Here's the "source" of the stochastic from the good folks at Empty4: http://codebase.mql4.com/264
Ugh. :) I'll tear that apart if I have to, but you don't happen to know where the source of iStochastic is, would you? I can't find it. That's what Steve's EA uses, not the Stochastic indicator.
garyfritz

Re: Gday: a D1 Stochastic OB/OS trading robot

Post by garyfritz »

Hm. Checking through my calculations of stoch...

I see plenty of cases where the stoch goes over 80, then comes down again -- but the system never triggers because "yesterday's close stoch & today's open stoch" went e.g. from 85 & 90, down to 70 & 65. The stoch went from above 80 to below 80, but the close-and-open values didn't straddle 80.

Am I missing something?? That's what Steve's code does:

Code: Select all

StochSignal = iStochastic(NULL, StochTimeFrame, K_Period,D_Period, Slowing, 
                                         MODE_SMA, 0, MODE_SIGNAL, 0);
PrevStochSignal = iStochastic(NULL, StochTimeFrame, K_Period, D_Period, Slowing, 
                                         MODE_SMA, 0, MODE_SIGNAL, shift);
if (PrevStochSignal >= OverBought && StochSignal < OverBought) ...
Caillou
Trader
Posts: 48
Joined: Sat Dec 03, 2011 9:11 pm

Re: Gday: a D1 Stochastic OB/OS trading robot

Post by Caillou »

Good morning,

Yesterday I finished all the thread reading and thanks to Steve, Shelley, Gary, Will and everyone for this beautifull system. I was not sure about testing this due to Gary´s backtests but since forward tests look so good and the EA´s logic seems a bit different in both cases, I have started a live test with MultiGday.
At the open of the new D1 Candle 5 trades were opened yesterday, without any error, all correct (Admiral Markets Standard Account).

Thanks again.

Cheers
User avatar
fxozgirl
Trader
Posts: 1176
Joined: Wed Nov 16, 2011 9:16 am
Location: Melbourne, Australia

Re: Gday: a D1 Stochastic OB/OS trading robot

Post by fxozgirl »

Gary, the coding of the existing EA in post 1 is not quite accurate for the entrances, which is why I have asked Steve to re-code it. The good news is that Steve is working on it right now...so provided I haven't confused him no end, hopefully we shall have it soon.
Shelley, MiTija has pointed out that I may have misunderstood the way Gday is supposed to work.

Tradestation systems run on the close of the bar. I've been using the stoch of the **CLOSE** of the daily bar, and looking to see if that's crossed 80 or 20. So e.g. I look to see if the stoch at yesterday's close was > 80 and the stoch at today's close is < 80. I figured looking at the close-to-close change in stoch was going to be nearly identical to the open-to-open change in stoch.

MiTija says no, you're looking and the stoch of the OPEN of a daily bar, and comparing to the stoch at the CLOSE of yesterday's bar. So if stoch-at-yesterday's-CLOSE is > 80 and stoch-at-today's-OPEN is < 80, THEN you enter. When he explain this to me, I vaguely remembered you mentioning it waaayy back when you first presented Gday.

Is that right? Or do you look at the OPEN of yesterday vs. the OPEN of today?
MiTija is correct, no wonder your Tradestation test results were so crappy :lol:

There can be a very big difference to the stoch levels between the last tick of the old candle and the first tick of the new candle. Quite often a trade setup will occur right then...The candle closes and the stoch is below 20 (for a buy), the new candle opens and the stoch is now above 20, confirming the set up and trade taken.

This is pretty much what the EA is doing now. What the EA is not doing (and what I have been discussing with Steve), is identifying the trades where the setup occurs prior to the last tick of the old candle see chart attached for audcad today. Looking at this right now it is a perfect set up in the making, just need to wait until the candle close to confirm the setup and take the trade.
As you can see the stoch's have already breached the 20 level, so the EA (as it is now) is not taking this trade, when it should be...this is what Steve & I are working on.
So the questions to be asked are:

check on the first tick of the new candle (for a buy trade):
'Was the stoch line & signal line both under 20 level sometime between the 1st tick & the last tick of the old candle'

if yes,

'Is the stoch line & signal line both over 20 level on the first tick of the new candle'

if yes again, take the trade, if no - no trade
Now the difficult part is trying to code this, which Steve is still trying to get his head around...I really hope he can!
audcad_example_stochlevel.png
You do not have the required permissions to view the files attached to this post.
User avatar
fxozgirl
Trader
Posts: 1176
Joined: Wed Nov 16, 2011 9:16 am
Location: Melbourne, Australia

Re: Gday: a D1 Stochastic OB/OS trading robot

Post by fxozgirl »

garyfritz wrote:Hm. Checking through my calculations of stoch...

I see plenty of cases where the stoch goes over 80, then comes down again -- but the system never triggers because "yesterday's close stoch & today's open stoch" went e.g. from 85 & 90, down to 70 & 65. The stoch went from above 80 to below 80, but the close-and-open values didn't straddle 80.

Am I missing something?? That's what Steve's code does:

Code: Select all

StochSignal = iStochastic(NULL, StochTimeFrame, K_Period,D_Period, Slowing, 
                                         MODE_SMA, 0, MODE_SIGNAL, 0);
PrevStochSignal = iStochastic(NULL, StochTimeFrame, K_Period, D_Period, Slowing, 
                                         MODE_SMA, 0, MODE_SIGNAL, shift);
if (PrevStochSignal >= OverBought && StochSignal < OverBought) ...

Exactly...see my post above, this part of the coding is incorrect and we are trying to fix it.
User avatar
fxozgirl
Trader
Posts: 1176
Joined: Wed Nov 16, 2011 9:16 am
Location: Melbourne, Australia

Re: Gday: a D1 Stochastic OB/OS trading robot

Post by fxozgirl »

Caillou wrote:Good morning,

Yesterday I finished all the thread reading and thanks to Steve, Shelley, Gary, Will and everyone for this beautifull system. I was not sure about testing this due to Gary´s backtests but since forward tests look so good and the EA´s logic seems a bit different in both cases, I have started a live test with MultiGday.
At the open of the new D1 Candle 5 trades were opened yesterday, without any error, all correct (Admiral Markets Standard Account).

Thanks again.

Cheers

I think it's best to disregard Gary's test (no disrespect Gary :D ) at this stage...I don't think he is using the correct entry criteria for the strategy. Hopefully with the discussion happening Gary will be able to set up his Tradestation to match the strategy and test again for us.
Locked

Return to “Automated trading systems”