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 5 of 71
Author:  SteveHopwood [ Mon Dec 19, 2011 10:23 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

Yet another update in post 1. I still hadn't got the blasted buy trigger code correct.

:D
Author:  fxozgirl [ Mon Dec 19, 2011 10:24 am ]
Post subject:  Re: Gday: Trigger Questions

gaheitman wrote:
fxozgirl wrote:
Cheers George...I don't have much idea when it comes to code...I appreciate your input

Thanks again Steve :)
Happy to help.

Can you clarify the trigger for me? For a buy, you want the stoch signal line at the close of yesterday's bar to be below 20, but above 20 at the opening of today's bar (reverse for sells). Or are you looking for the stoch to be below 20 at the close 2 days ago, and above at the close yesterday?

The value of the signal line changes throughout the day. Do you take a trade later in the day if the stoch signal line eventually moves above 20?

Thanks,
George

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).

The reason for this (as you already know) is that the stoch is a lagging indicator and does changes throughout the day (but is delayed), however the indicator always updates/confirms at the close/open of a candle (I see these actions as simultaneous - 1 candle closes the new one opens), hence there is now a 'confirmed' signal.

I have seen many times where there has been a cross during the day and then price direction has changed and then by the time the signal is confirmed at the close/open there is no longer a cross...that's why I wait.

The opposite is the case for a sell...the signal line must cross over 80 at the opening of the new candle for a trade to be taken.

Personally, I also like to make sure it is a 'clear' cross, not just touching. If the signal line is just touching or barely crossed, I will wait an extra day before deciding to take the trade or not.

Also, I never take a trade during the course of the day...always at the open or not at all (which is why I asked Steve if he would code this ea, as I was no longer able to be at my pc at the candle open).

What happened this morning with the chfjpy trade was that prior to trading opening the signal line was below the 20 but I could see by the price action from Friday that the price was going up and that the signal line would subsequently cross the 20 (be confirmed) at the new opening. That was why I attached the ea in anticipation of this happening, however it didn't take the trade.
Author:  SteveHopwood [ Mon Dec 19, 2011 10:28 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

Hehe. The mystery of the apparently lost edit is solved. I had made the change on my trading machine and forgot to upload it here. I found this out just now, when I went to make the change.

Hey ho.

:D
Author:  SteveHopwood [ Mon Dec 19, 2011 10:34 am ]
Post subject:  Re: Gday: Trigger Questions

fxozgirl wrote:
gaheitman wrote:
fxozgirl wrote:
Cheers George...I don't have much idea when it comes to code...I appreciate your input

Thanks again Steve :)
Happy to help.

Can you clarify the trigger for me? For a buy, you want the stoch signal line at the close of yesterday's bar to be below 20, but above 20 at the opening of today's bar (reverse for sells). Or are you looking for the stoch to be below 20 at the close 2 days ago, and above at the close yesterday?

The value of the signal line changes throughout the day. Do you take a trade later in the day if the stoch signal line eventually moves above 20?

Thanks,
George

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).

The reason for this (as you already know) is that the stoch is a lagging indicator and does changes throughout the day (but is delayed), however the indicator always updates/confirms at the close/open of a candle (I see these actions as simultaneous - 1 candle closes the new one opens), hence there is now a 'confirmed' signal.

I have seen many times where there has been a cross during the day and then price direction has changed and then by the time the signal is confirmed at the close/open there is no longer a cross...that's why I wait.

The opposite is the case for a sell...the signal line must cross over 80 at the opening of the new candle for a trade to be taken.

Personally, I also like to make sure it is a 'clear' cross, not just touching. If the signal line is just touching or barely crossed, I will wait an extra day before deciding to take the trade or not.

Also, I never take a trade during the course of the day...always at the open or not at all (which is why I asked Steve if he would code this ea, as I was no longer able to be at my pc at the candle open).

What happened this morning with the chfjpy trade was that prior to trading opening the signal line was below the 20 but I could see by the price action from Friday that the price was going up and that the signal line would subsequently cross the 20 (be confirmed) at the new opening. That was why I attached the ea in anticipation of this happening, however it didn't take the trade.
Gday is not programmed like this just yet - I slightly misunderstood. Need a little rethink.

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

:D
Author:  fxozgirl [ Mon Dec 19, 2011 10:41 am ]
Post subject:  Re: Gday: Trigger Questions

SteveHopwood wrote: Gday is not programmed like this just yet - I slightly misunderstood. Need a little rethink.

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

:D
Sorry Steve, I think I should have provide you much more detailed information. I apologise for the trouble I am putting to you :oops:

Shelley
Author:  SteveHopwood [ Mon Dec 19, 2011 10:48 am ]
Post subject:  Re: Gday: Trigger Questions

fxozgirl wrote:
SteveHopwood wrote: Gday is not programmed like this just yet - I slightly misunderstood. Need a little rethink.

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

:D
Sorry Steve, I think I should have provide you much more detailed information. I apologise for the trouble I am putting to you :oops:

Shelley
Nope, you described thingies just fine; it just isn't always that easy for a dimwit like me to fully grasp a spec.

TIG will provide a snippet to find the highest/lowest Stoch from an appropriate period (I can hear his brain whirring over this). Then all it will take is a little re-write to make sure Gday only trades the start of the D1 candle.

:D
Author:  SteveHopwood [ Mon Dec 19, 2011 10:51 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

Thinking about 'appropriate period', I suppose this is yesterday?

If Sto was overbought yesterday and then the signal line fell out of the ob area, then the open of the new D1 candle confirms the fall and triggers the trade.

This also means Gday will be working with historical data and should then function as you intended.

:D
Author:  gaheitman [ Mon Dec 19, 2011 10:53 am ]
Post subject:  Re: Gday: Trigger Questions

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
Author:  gaheitman [ Mon Dec 19, 2011 10:58 am ]
Post subject:  Re: Gday: Trigger Questions

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
Author:  SteveHopwood [ Mon Dec 19, 2011 11:11 am ]
Post subject:  Re: Gday: Trigger Questions

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
All times are UTC Page 5 of 71