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

Speed Trap...Too Far, Too Fast
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=14
Page 2 of 3
Author:  SteveHopwood [ Wed Nov 16, 2011 10:10 pm ]
Post subject:  Re: Speed Trap...Too Far, Too Fast

gaheitman wrote:I'd like to take a crack at creating an indicator that will show us what this looks like before we try to code an EA for it.
/fabulous George. Cheers.

:D
Author:  Pippopotamus [ Wed Nov 16, 2011 10:30 pm ]
Post subject:  Re: Speed Trap...Too Far, Too Fast

We are measuring excursions from candle open, not overall candle length. We attempt to capitalize when price retraces after spiking...FTLR does this, but here we are trading vs a standard, rather than previous candle's H/L...This may just be reinventing the wheel!? Perhaps dear old FTLR just needs to be spiffed up a bit??? At least, grist for our new mill. Would love to hear what some others think of this approach. Detailed harsh criticism, most welcome...A normal distribution...http://en.wikipedia.org/wiki/File:Norma ... scales.gif.
Author:  Pippopotamus [ Wed Nov 16, 2011 10:52 pm ]
Post subject:  Re: Speed Trap...Too Far, Too Fast

gaheitman wrote:Steve,

Empty4 has a drawing object called Standard Deviation Channel (might have to add it to your drawing toolbar -- it's the one with the "D"). When you add it to the chart, you drag it from beginning price to ending price. As you drag, it will change the width of the channel so that it is plus or minus one standard deviation from the center (OK, OK, "centre" :) ) line. You can edit the properties of the object so that you can see what 2 or 3 standard deviations would look like.

Now this is showing a channel based on the actual price, Pippo is suggesting we use the maximum of the distance travelled from the open in each bar (MathMax(High-Open,Open-Low) as the data points instead of actual price. At least I think so.

I'd like to take a crack at creating an indicator that will show us what this looks like before we try to code an EA for it. I have a few questions first, however.

Pippo,

1) How many bars/days of data do we look at? I am assuming we are only looking at bars within our trading times, so we will have to scan back and collect bars, calculate the mean/stdev and then use that for today.

2) Are we basing the channels on the open of each bar? Or are we anchoring them on some MA? If so, what is the moving average type/period?

OK, apparently it was only a couple of questions, though one was multi-part. :D

George
George, we are measuring excursions from candle opening values. This is statistically based trading... Do you have a way to have the stats done within an EA?? That would be of great service. I will dig up the formula for determining adequate sample size...Tomorrow...I need sleep.
Author:  hayseed [ Wed Nov 16, 2011 11:12 pm ]
Post subject:  Re: Speed Trap...Too Far, Too Fast

to get a visual, you can shade in the deviations, atr's or any such pip value.... if using calculations that are based from the opening price, the shaded areas can move with each new bar.... and ofcourse redraw with any change in charts timeframe.....

if using values such as average zigzag move, it's best to to let the area increase with time..... as it will many bars to hit the target......

pending orders can be set at the various levels as seen by the colors.....h
Author:  hiredwhip [ Wed Nov 16, 2011 11:39 pm ]
Post subject:  Re: Speed Trap...Too Far, Too Fast

hayseed wrote:to get a visual, you can shade in the deviations, atr's or any such pip value.... if using calculations that are based from the opening price, the shaded areas can move with each new bar.... and ofcourse redraw with any change in charts timeframe.....

if using values such as average zigzag move, it's best to to let the area increase with time..... as it will many bars to hit the target......

pending orders can be set at the various levels as seen by the colors.....h
H,
Do you already have an EA or Indi that is doing this....

whip
Author:  hayseed [ Thu Nov 17, 2011 12:20 am ]
Post subject:  Re: Speed Trap...Too Far, Too Fast

hey whip..... yes, quite a few actually..... but it's steve's forum and i haven't looked into what can or can not be posted.....

the code required is quite simple.....
//---
//---

takin it further, if you have many orders with odd lot sizes at multiple entry points, you can calculate the projected combined profit/loss at the increments up and down.... every time new orders are placed or orders are closed the projected values will change....

as example, in the chart below the values are in yellow at each aqua line.... i have squished the chart to fit the forum pages..... it would normally not be so cluttered.....


handy for those that trade support or resistance and would like to know the profit/loss at that point......h


//---
//---

example using atr

//---
//---

Code: Select all

 
  DrawRectangle("rectanglec", 0,Time[1],(Close[1]+iATR(NULL,0,20,1)), Time[0],(Close[1]-iATR(NULL,0,20,1)), Blue); 
  DrawRectangle("rectangleh", 0,Time[1],(Close[1]+iATR(NULL,0,20,1)), Time[0],(Close[1]+2*iATR(NULL,0,20,1)), Magenta); 
  DrawRectangle("rectanglel", 0,Time[1],(Close[1]-iATR(NULL,0,20,1)), Time[0],(Close[1]-2*iATR(NULL,0,20,1)), Magenta); 

  DrawRectangle("rectangleh2",0,Time[1],(Close[1]+2*iATR(NULL,0,20,1)), Time[0],(Close[1]+3*iATR(NULL,0,20,1)), Red); 
  DrawRectangle("rectanglel2",0,Time[1],(Close[1]-2*iATR(NULL,0,20,1)), Time[0],(Close[1]-3*iATR(NULL,0,20,1)), Red); 
  
  if(Volume[0] < 4)
  {
   ObjectDelete("rectanglec");
   ObjectDelete("rectangleh");  
   ObjectDelete("rectanglel");
   ObjectDelete("rectangleh2");  
   ObjectDelete("rectanglel2");
   }  

//----
//---
//---

Code: Select all

  void DrawRectangle(string name, int window, int startbar,double startprice, int endbar, double endprice, color clr)   
  {  
  ObjectCreate(name,OBJ_RECTANGLE,window,startbar,startprice,endbar,endprice);
  ObjectSet   (name,OBJPROP_COLOR,clr);
  ObjectSet   (name,OBJPROP_BACK ,true);
  }
Author:  hiredwhip [ Thu Nov 17, 2011 12:37 am ]
Post subject:  Re: Speed Trap...Too Far, Too Fast

hayseed wrote:hey whip..... yes, quite a few actually..... but it's steve's forum and i haven't looked into what can or can not be posted.....

the code required is quite simple.....
//---
//---

takin it further, if you have many orders with odd lot sizes at multiple entry points, you can calculate the projected combined profit/loss at the increments up and down.... every time new orders are placed or orders are closed the projected values will change....

as example, in the chart below the values are in yellow at each aqua line.... i have squished the chart to fit the forum pages..... it would normally not be so cluttered.....


handy for those that trade support or resistance and would like to know the profit/loss at that point......h


//---
//---

example using atr

//---
//---

Code: Select all

 
  DrawRectangle("rectanglec", 0,Time[1],(Close[1]+iATR(NULL,0,20,1)), Time[0],(Close[1]-iATR(NULL,0,20,1)), Blue); 
  DrawRectangle("rectangleh", 0,Time[1],(Close[1]+iATR(NULL,0,20,1)), Time[0],(Close[1]+2*iATR(NULL,0,20,1)), Magenta); 
  DrawRectangle("rectanglel", 0,Time[1],(Close[1]-iATR(NULL,0,20,1)), Time[0],(Close[1]-2*iATR(NULL,0,20,1)), Magenta); 

  DrawRectangle("rectangleh2",0,Time[1],(Close[1]+2*iATR(NULL,0,20,1)), Time[0],(Close[1]+3*iATR(NULL,0,20,1)), Red); 
  DrawRectangle("rectanglel2",0,Time[1],(Close[1]-2*iATR(NULL,0,20,1)), Time[0],(Close[1]-3*iATR(NULL,0,20,1)), Red); 
  
  if(Volume[0] < 4)
  {
   ObjectDelete("rectanglec");
   ObjectDelete("rectangleh");  
   ObjectDelete("rectanglel");
   ObjectDelete("rectangleh2");  
   ObjectDelete("rectanglel2");
   }  

//----
//---
//---

Code: Select all

  void DrawRectangle(string name, int window, int startbar,double startprice, int endbar, double endprice, color clr)   
  {  
  ObjectCreate(name,OBJ_RECTANGLE,window,startbar,startprice,endbar,endprice);
  ObjectSet   (name,OBJPROP_COLOR,clr);
  ObjectSet   (name,OBJPROP_BACK ,true);
  }
Thanks H,
Nicely done.....Detailed......I've stepped in about everything I need to step in.......Time to get some sleep......

Have a great day

whip
Author:  skoda2008 [ Thu Nov 17, 2011 12:46 am ]
Post subject:  Std Dev Channels

Here's a little indi I cobbled together a couple of years ago, to replicate the standard deviation channels in Empty4.

I also wrote an EA to counter trade from the standard deviations back to the linear regression point. Sorry the EA is long since deleted.

My conclusion was that this kind of strategy suits stocks / indices rather than forex. Having said that, I did use this indicator to successfully sell currency options for a while until I started making too much money and the crim made it too difficult for me to trade :x
Author:  Pippopotamus [ Thu Nov 17, 2011 3:44 pm ]
Post subject:  Re: Speed Trap...Too Far, Too Fast

Sample size calculator....Perhaps best to look back at all bars in history, if possible. http://www.raosoft.com/samplesize.html
Author:  squalou [ Sat Nov 19, 2011 4:29 pm ]
Post subject:  Re: Speed Trap...Too Far, Too Fast

Has someone summoned me here ?.... :D

OK, yes, i must admit i like the statistical approach very much, and i coded quite a few indis with self-coded SD functions.
One of them is the "MA Normalized Deviation sq.mq4" indicator, which draws the deviation of price from a given MA, in factors of the SD from this MA.
This might sound like some kind of Bollinger Band, however, my indicator allows to set different lengths for the MA and the number of bars used to determine the SD from this MA.
Bollinger Bands use the same length for both the MA and the SD calculation, which does not reflect (IMO) what is the actual average SD value over a much longer period;
I set the number of bars to calc the SD to be very high compared to the MA length itself, typically 500 bars or more.
Enough about how this indicator works.

Back to how we could use it here.

If i understand well, we want to determine the SD of High-Open, and High-Low, and start from there.

Because we are working here with a very particular case of MA length: 1, I had to modify my indicator a bit to allow it to effectively work with different price type inputs for calculating the MA and the "price line", otherwize the difference would have always been 0...

Attached is the modified indicator.

I also attached a template that will load 2 sets of this indicator, one showing the deviations of the High from Open (histogram pointing north), and the second showing the dev of the Low from Open (histogram pointing south).
Each histogram window will also give you the value of the SD itself in pips, so it is easy to estimate the 0.5*SD "expected" retracement pips... :mrgreen:

Note to our beloved "Site Admin" :roll:
i cannot attach .tpl files... would be nice to allow that, thx Steve.
so i renamed it .mq4 for the time being, but you should rename it .tpl and put it in your template folder.

The indicator is designed to plot yellow bars when the SD exceeds 2SD, and red when it exceeds 3SD.
Which is exactly what we are looking for.

Here is a screenshot of how it looks like on the latest EU H4 chart:
speed_trap-H1.gif
Note: the SD values shown are as calculated at the close of each candle.
But in real time, the histogram bars will most of the times extend further than what it looks like at the candle close, so i think we should typically wait for the red histograms only, ie for price to exceed 3SD, before entering the retracement trade.
On the screenshot, we can actually see some candles with long wicks being shown with less then 2SD extension at the candle close, but these would very likely have gone beyond 3SD in real time, so they would have been good trading candidates -- and good trades as well of course, as they reversed within the same candle already!


We could very easily code a "main chart" indicator very similar to the Bollinger Band, that would draw the 2SD and 3SD channels around the Open price on each candle, which would show us instantly price extensions and the retracements.

I will leave that to gaheitman if he wants to give it a try.


I think we are on to something here.....

8-)


Sq
All times are UTC Page 2 of 3