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 17 of 71
Author:  fxozgirl [ Wed Dec 21, 2011 11:02 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

SteveHopwood wrote:
gaheitman wrote:Steve,

I think JumpingStopLoss() still relies on it being at breakeven. The code still expect "sl" to have a valid value and makes sure its above the OrderOpenPrice().

This

Code: Select all

   if (OrderType()==OP_BUY)
   {
      if (sl < OrderOpenPrice() ) return;//Not at breakeven yet
      // Increment sl by sl + JumpingStopPips.
      // This will happen when market price >= (sl + JumpingStopPips)
      //if (Bid>= sl + ((JumpingStopPips*2)*Point) ) 
      if (Bid >= MathMax(sl, OrderOpenPrice() ) + ((JumpingStopPips * 2) * Point) )//George{
      {
         NewStop = NormalizeDouble(sl + (JumpingStopPips * Point), Digits);
         if (HiddenPips > 0) ObjectMove(LineName, 0, Time[0], NewStop);
         if (NewStop - OrderStopLoss() >= Point) modify = true;//George again. What a guy
         modify = true;   
      }// if (Bid>= sl + (JumpingStopPips*Point) && sl>= OrderOpenPrice())      
   }//if (OrderType()==OP_BUY)
   
   if (OrderType()==OP_SELL)
   {
      if (sl > OrderOpenPrice() ) return;//Not at breakeven yet
      // Decrement sl by sl - JumpingStopPips.
      // This will happen when market price <= (sl - JumpingStopPips)
      //if (Bid<= sl - ((JumpingStopPips*2)*Point)) Original code
      if (Bid <= MathMin(sl, OrderOpenPrice() ) - ((JumpingStopPips * 2) * Point) )//George
      {
         NewStop = NormalizeDouble(sl - (JumpingStopPips * Point), Digits);
         if (HiddenPips > 0) ObjectMove(LineName, 0, Time[0], NewStop);
         if (OrderStopLoss() - NewStop >= Point || OrderStopLoss() == 0) modify = true;//George again. What a guy   
         modify = true;   
      }// close if (Bid>= sl + (JumpingStopPips*Point) && sl>= OrderOpenPrice())         
   }//if (OrderType()==OP_SELL)
should be this

Code: Select all

   if (OrderType()==OP_BUY)
   {
      //if (sl < OrderOpenPrice() ) return;//Not at breakeven yet
      // Increment sl by sl + JumpingStopPips.
      // This will happen when market price >= (sl + JumpingStopPips)
      //if (Bid>= sl + ((JumpingStopPips*2)*Point) ) 
      sl = MathMax(sl, OrderOpenPrice());
      if (Bid >=  sl + ((JumpingStopPips * 2) * Point) )//George{
      {
         NewStop = NormalizeDouble(sl + (JumpingStopPips * Point), Digits);
         if (HiddenPips > 0) ObjectMove(LineName, 0, Time[0], NewStop);
         if (NewStop - OrderStopLoss() >= Point) modify = true;//George again. What a guy
         modify = true;   
      }// if (Bid>= sl + (JumpingStopPips*Point) && sl>= OrderOpenPrice())      
   }//if (OrderType()==OP_BUY)
   
   if (OrderType()==OP_SELL)
   {
      //if (sl > OrderOpenPrice() ) return;//Not at breakeven yet
      // Decrement sl by sl - JumpingStopPips.
      // This will happen when market price <= (sl - JumpingStopPips)
      //if (Bid<= sl - ((JumpingStopPips*2)*Point)) Original code
      sl = MathMin(sl, OrderOpenPrice());
      if (sl == 0) sl = OrderOpenPrice();
      if (Bid <= sl - ((JumpingStopPips * 2) * Point) )//George
      {
         NewStop = NormalizeDouble(sl - (JumpingStopPips * Point), Digits);
         if (HiddenPips > 0) ObjectMove(LineName, 0, Time[0], NewStop);
         if (OrderStopLoss() - NewStop >= Point || OrderStopLoss() == 0) modify = true;//George again. What a guy   
         modify = true;   
      }// close if (Bid>= sl + (JumpingStopPips*Point) && sl>= OrderOpenPrice())         
   }//if (OrderType()==OP_SELL)
I commented out the "if (sl < OrderOpenPrice() ) return;" line and reset "sl" to be the value we want to use later, including a second test for sells to make sure it isn't zero.

George
George, that is brilliant.

Guys, you might want to hang on before downloading the latest update. TIG's solution is better than mine, so I am just going to finish catching up on the posts and then will make the edits to the code.

:D
Thanks George...this ea is certainly the better as a result of your input and experience :)
Author:  fxozgirl [ Wed Dec 21, 2011 11:09 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

SteveHopwood wrote: Here we are in the run up to Christmas when the markets are so difficult that a lot of experienced traders shut down their platforms altogether, and we have a system that is making pips. Remarkable achievement, Shelley.

:D
Steve, thank you so much...seriously I was not expecting anybody to show interest in this system. My trading experience and knowledge is but a 'pip', and yet I have the likes of you, George, Gary and others who have shared their time and knowledge to help me and others to gain an edge in this difficult environment. :oops:

Thanks so much
Author:  fxozgirl [ Wed Dec 21, 2011 11:10 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

ROBST3R wrote:Opened aud/usd manually and first trade was taken by the ea! 50 pips secured!

Free trade now :D
It feels good doesn't it :D
Author:  fxozgirl [ Wed Dec 21, 2011 11:13 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

garyfritz wrote: BTW I'm not sure yet but I'm not certain the 3-lot model is necessary. It seems to work almost as well exiting the full position at a single TP -- at least almost as well as my simplified end-of-bar model. The 3-lot model might work better if you're doing realtime jumping stops &etc.

Gary
This is an area that I think we can look at further...
mind you my main criteria is safety first, which is why I decided to do the 1/2/3 especially as we are trading the dailys where 200-300 pip moves are common place.
Author:  SteveHopwood [ Wed Dec 21, 2011 11:15 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

Ok, gals and galesses, latest latest update in post 1.

The JS function will work correctly now that TIG has fixed it.

I am dying to catch George out in a bloop of his own. In a pm, I described how I played competitive chess in my younger days. Within a chess club, there was always that player with whom drawing a practise match would be an immense achievement.

I never happens. I suspect catching George out will never happen. Hey ho.

George, can you do us all another favour, please. This fix needs to go into the shell code as well. Before I post it, can you run your slide rule over the trailing stop feature. All these functions derive from mptm and I coded them as part of my learning-the-language process. I knew nothing of features such as MathMax etc, so if you can tidy up the code, that would be great.

:D
Author:  gaheitman [ Wed Dec 21, 2011 11:19 am ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

SteveHopwood wrote:Ok, gals and galesses, latest latest update in post 1.

The JS function will work correctly now that TIG has fixed it.
Well, I'm certain it will work differently, at least. :D
Author:  dynel14 [ Wed Dec 21, 2011 12:23 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

SteveHopwood wrote:Ok, gals and galesses, latest latest update in post 1.

The JS function will work correctly now that TIG has fixed it.

I am dying to catch George out in a bloop of his own. In a pm, I described how I played competitive chess in my younger days. Within a chess club, there was always that player with whom drawing a practise match would be an immense achievement.

I never happens. I suspect catching George out will never happen. Hey ho.

George, can you do us all another favour, please. This fix needs to go into the shell code as well. Before I post it, can you run your slide rule over the trailing stop feature. All these functions derive from mptm and I coded them as part of my learning-the-language process. I knew nothing of features such as MathMax etc, so if you can tidy up the code, that would be great.

:D
Thank you Steve for the update and fxozgirl for the method.
Just to make sure...should we set BE true or false? OOTB is false.

dynel14
Author:  SteveHopwood [ Wed Dec 21, 2011 12:27 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

dynel14 wrote:
SteveHopwood wrote:Ok, gals and galesses, latest latest update in post 1.

The JS function will work correctly now that TIG has fixed it.

I am dying to catch George out in a bloop of his own. In a pm, I described how I played competitive chess in my younger days. Within a chess club, there was always that player with whom drawing a practise match would be an immense achievement.

I never happens. I suspect catching George out will never happen. Hey ho.

George, can you do us all another favour, please. This fix needs to go into the shell code as well. Before I post it, can you run your slide rule over the trailing stop feature. All these functions derive from mptm and I coded them as part of my learning-the-language process. I knew nothing of features such as MathMax etc, so if you can tidy up the code, that would be great.

:D
Thank you Steve for the update and fxozgirl for the method.
Just to make sure...should we set BE true or false? OOTB is false.

dynel14
I need to add the break even profit to JS - I forgot - so turn BE on for now. BE also closes the first third of the trade.

Nearly there.

:D
Author:  garyfritz [ Wed Dec 21, 2011 2:49 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

fxozgirl wrote:Interesting results Gary...when I was trading manually, the stop loss would vary depending on the pair being traded to take into account the volatility of the pair and the daily range.
Stop losses ranged between 200 pips for less volatile pairs & 300 pips for the more volatile pairs.
Yes, I started with fixed stops because I thought that was the way you trade it. I intend to add some volatility-scaled stops and see how that works.
SteveHopwood wrote:Thanks for doing all this Gary. I have linked this post so that newcomers do not miss it.
Once you get a version working that you're happy with, we should compare backtests and make sure that my results (and thus the recommended pairs) actually match up with what everybody will be using.
Author:  Alpenkorps [ Wed Dec 21, 2011 3:37 pm ]
Post subject:  Re: Gday: a D1 Stochastic OB/OS trading robot

garyfritz wrote: Once you get a version working that you're happy with, we should compare backtests and make sure that my results (and thus the recommended pairs) actually match up with what everybody will be using.
Not all backtest result will match because of the time zone difference of different brokers. But its not gonna be a problem in long run I hope.

I am actually thinking something else. We can try it on different timeframes rather than D1, With BE and fixed TP, SL. Just for fun, we might get some interesting result too.
All times are UTC Page 17 of 71