Gday: a D1 Stochastic OB/OS trading robot

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

Re: Gday: Trigger Questions

Post by fxozgirl »

gaheitman wrote:
fxozgirl wrote:The trigger to buy is for the stoch signal line to have crossed the 20 at the opening of the new candle. (For example, if I was trading manually I would wait until the candle opened, checked where the signal line was and then place a trade/or not).
Ok, to restate your logic and turn it into code....

Only determine if there is a valid signal at the opening of the bar. Once the opening of the bar passes, we're done looking for trades until tomorrow.

For a buy, the Stochastic Signal value at the close of the previous bar must be below 20 and the Stochastic signal value at the instant of the opening of the current bar must be above 20.

For a sell, the Stochastic Signal value at the close of the previous bar must be above 80 and the Stochastic signal value at the instant of the opening of the current bar must be below 80.

Would you want to use a delta value to make sure that it is a sharp turn at the OB/OS levels?

Steve,

I think you need to reinstate code to only check at the beginning of the bar. You may need to check Volume[0] <= 1 to make sure you don't take a trade the moment you add the EA to the chart. I've never used that test myself, but most of my coding has been indicators. Also, you may have to make two calls to GetStoch(), one for the current bar and one for the previous bar. That way you are sure to get the final value for the previous bar stoch.

George
Yes exactly :D

Re: delta value...sorry I don't know what that is :oops:
User avatar
fxozgirl
Trader
Posts: 1176
Joined: Wed Nov 16, 2011 9:16 am
Location: Melbourne, Australia

Re: Gday: Trigger Questions

Post by fxozgirl »

SteveHopwood wrote:
gaheitman wrote:
SteveHopwood wrote: George, knowest ye the code for detecting ob/os yesterday? Probably best to incorporate the Sunday candle into Friday, if possible.

:D
Your current code would work (other than the Sunday candle thing) by just calling GetStoch(1) capturing the values and then calling GetStoch(0).

As for the Sunday problem, hopefully google has that answer so we don't have to recode the indicator... :D
Ok, I am not going to worry about the Sunday thingy just yet.

Assuming your summary is correct and that we are only concerned with the final tick of the old and the first tick of the new candles, then the coding suddenly becomes much easier and more clear-cut. I am going to make the edits as soon as I have finished writing this. I can drop all the 'status' stuff.

The only problem then becomes the wait-a-day scenario. We can take care of this later. I imagine it is Land of Nod time in Upside-Down land, so we will not hear from Shelley for a while.

:D
Yes, pretty much that's all we need to look at...the last tick of the old candle and the first tick of the new candle :)
if the set up doesn't line up, then we wait until tomorrow

I hope this does make it easier for you


btw...it is bed time here in Oz and so I will say good night and thank you to Steve & George
I will login in the morning before I go to work to answer any questions if necessary
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: Gday: Trigger Questions

Post by gaheitman »

fxozgirl wrote: Re: delta value...sorry I don't know what that is :oops:
Sorry, I meant should we also look at the difference between yesterday's value and today's. If at yesterday's close it was 19.9 and today it opened at 20.0001 would you want to take the trade? It may not matter, but you mentioned looking for a clear signal, and the further apart the two values are the sharper the turn in the stoch.

George
ROBST3R
Trader
Posts: 86
Joined: Fri Dec 16, 2011 7:33 pm

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

Post by ROBST3R »

Hi fxozgirl.

What time is it in australia where you live, here its 04:46pm i think it`s 00:46 am with you?

I ask because you search for your trades at 08:00am! Then i think it`s 11:00 pm over here!

Greets
User avatar
spyderman
Trader
Posts: 338
Joined: Sun Dec 11, 2011 1:39 pm

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

Post by spyderman »

Hmmmm.

Placed Gday on all pairs this morning and to my surprise it started taking trades. I thought that it wouldn't until the start of my next day, which for me is in another 6 hrs.

It placed a buy on Aud/Cad at 1.02887
placed a sell on Gbp/Nzd at 2.04551
then flipped out and placed sells on same pair at 2.04529, 2.04530, 2.04538 and 2.04535 all for .03 lots each. :(

Any ideas what happened.

Could changing TF initiate these trades?
Snaggin' some pips
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 »

spyderman wrote:Hmmmm.

Placed Gday on all pairs this morning and to my surprise it started taking trades. I thought that it wouldn't until the start of my next day, which for me is in another 6 hrs.

It placed a buy on Aud/Cad at 1.02887
placed a sell on Gbp/Nzd at 2.04551
then flipped out and placed sells on same pair at 2.04529, 2.04530, 2.04538 and 2.04535 all for .03 lots each. :(

Any ideas what happened.

Could changing TF initiate these trades?
Steve is making changes to prevent this from happening. Hold tight testing until the next update appears.

George
garyfritz

Re: Gday: Trigger Questions

Post by garyfritz »

fxozgirl wrote:Yes, pretty much that's all we need to look at...the last tick of the old candle and the first tick of the new candle :)
if the set up doesn't line up, then we wait until tomorrow
That's what George said too, and I assumed he was mistaken. But now you're agreeing??

The last tick of the old candle, and the first tick of the new candle, are going to occur mere seconds apart, aren't they? They will almost always have the exact same value within a pip or three.

Judging from the way you read your charts, I thought you were using the CLOSING value of the stoch Signal. (The open of the next candle is basically identical, but the CLOSING value is what you see on past candles on a chart.) So if the CLOSING stoch Signal value is < 20 on the CLOSE of the 19 Dec candle, and if it's > 20 on the CLOSE of the 20 Dec candle, then you would buy the OPEN of the 21 Dec candle -- basically instantly after the 20 Dec candle closes.

To avoid confusion I would only talk about the Signal values at the close of the candle, since that's what you see on the chart on all candles except the currently-building candle. "If the Signal crosses from <20 on candle N to >20 on candle N+1, buy immediately after the close of candle N+1." (Which would be the open of candle N+2.) Or, to put it in MQL-speak, "If the Signal value is <20 on bar 2, and >20 on bar 1, buy immediately after bar 1 closes, i.e. the first tick of bar 0."

Or am I totally misunderstanding?
User avatar
spyderman
Trader
Posts: 338
Joined: Sun Dec 11, 2011 1:39 pm

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

Post by spyderman »

gaheitman wrote:
Steve is making changes to prevent this from happening. Hold tight testing until the next update appears.

George
No worries, that's why we demo ;)
Snaggin' some pips
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

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

Post by SteveHopwood »

Latest update in post 1:
  • Should only trade on info from the last tick of the previous candle and the first tick of the new one
    Trade will be closed if there is a recross of the signal by the main line detected at the start of the new candle. The cross may have occurred much earlier; Gday simply checks to see if Main is wrong side of Signal.
    Added Saturday and Sunday no-trade inputs.
:D
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: Gday: Trigger Questions

Post by gaheitman »

garyfritz wrote:
fxozgirl wrote:Yes, pretty much that's all we need to look at...the last tick of the old candle and the first tick of the new candle :)
if the set up doesn't line up, then we wait until tomorrow
That's what George said too, and I assumed he was mistaken. But now you're agreeing??

Hey! :lol:
garyfritz wrote:The last tick of the old candle, and the first tick of the new candle, are going to occur mere seconds apart, aren't they? They will almost always have the exact same value within a pip or three.

Judging from the way you read your charts, I thought you were using the CLOSING value of the stoch Signal. (The open of the next candle is basically identical, but the CLOSING value is what you see on past candles on a chart.) So if the CLOSING stoch Signal value is < 20 on the CLOSE of the 19 Dec candle, and if it's > 20 on the CLOSE of the 20 Dec candle, then you would buy the OPEN of the 21 Dec candle -- basically instantly after the 20 Dec candle closes.

To avoid confusion I would only talk about the Signal values at the close of the candle, since that's what you see on the chart on all candles except the currently-building candle. "If the Signal crosses from <20 on candle N to >20 on candle N+1, buy immediately after the close of candle N+1." (Which would be the open of candle N+2.) Or, to put it in MQL-speak, "If the Signal value is <20 on bar 2, and >20 on bar 1, buy immediately after bar 1 closes, i.e. the first tick of bar 0."
That was my option 2 in an earlier message, but I didn't think it was what she was doing.

The %K of the stochastic is

%K = (Current Close - Lowest Low)/(Highest High - Lowest Low) * 100

On the open of the new bar, the Current Close is the Open, which is a pip or two away from the previous close. So, any difference in the two readings is related to a Higher High or Lower Low either occurring or dropping off of the calculation. Or a change due to the smoothing.

It does mean that visual backtesting isn't worth much since you can't tell what the stoch value was at the beginning of a bar.

For fun, I was thinking of updating the stochastic indicator to project the next stochastic value (at open). It could then be used to visually backtest this system.

George
Locked

Return to “Automated trading systems”