Breakout indicator
Forums › ProRealTime English forum › ProBuilder support › Breakout indicator
- This topic has 18 replies, 4 voices, and was last updated 6 years ago by GraHal.
-
-
12/18/2017 at 11:55 AM #55950
A request that was addressed to ProRealTime:
I wondered if you could help me put together a simple breakout indicator/autotrader as below? I’d like to use this programme to back test and auto trade various indices and forex markets, on various timeframes with variable £ per lot. I’m relatively new to Prorealtime and am actively trying to learn how to write programs, but info is a little sketchy so would appreciate your help with this 1st programme please. I’ll then hopefully be able to fathom out how the programme requirements in English translate to the syntax!
Many thanks
Breakout indicator
Set time of candles to measure from and to – i.e. 16.00 to 22.00 This time needs to be adjustable to test various markets
Measure highest and lowest points of that time period – this value is to be used as the target when trade entered – see below
Buy/sell when candle closes above/below the highest/lowest points of measured period – ie measure highest and lowest candles for 16.00 to 22.00 and when next candle closes above or below enter trade.
Stop loss equals the opposite high/low value – i.e. if enter long then s/l is the value of lowest measured point – if enter short the s/l is value of highest measured point
Stop loss + “XX” pts – i.e. must be able to add “x” points to s/l for example, to set stop loss +5 pts to prevent being spiked out
Take profit target is equal to value of high minus low of measured period
Trading days/times and close time adjustable i.e. no trades taken after “xx:xx hrs” and all trades to be closed at “xx:xx hrs” trading days mon/tues/wed/thurs
Buy/sell at £x per point – this value should be adjustable
Suggestion for an anwser:
Breakout indicator12345678910111213141516171819202122232425262728293031323334begintime=160000endtime=220000XX=0long=close > myhigh and close[1] > myhighshort=close <mylow and close[1] < mylowif time=begintime or(time > begintime and time[1]<begintime) thenmyhigh=highmylow=lowelsif time > begintime and time <= endtime thenmyhigh=max(high,myhigh)mylow=min(low,mylow)endifif not longonmarket and long thenbuy 1 share at marketsell at mylow+XX stopset target pprofit (myhigh-mylow)/pointsizeendifif longonmarket thensell at mylow+XX stopendifif not shortonmarket and short thensellshort 1 share at marketexitshort at mylow-XX stopset target pprofit (myhigh-mylow)/pointsizeendifif shortonmarket thenexitshort at mylow-XX stopendif1 user thanked author for this post.
12/20/2017 at 8:46 AM #56112Thanks for your response. However, I have tried to run the programme and I doesn’t seem to work correctly. If I can give you an example:
GBP/NZD 1HR chart on Friday 15th December. If I ask the programme to measure the highest and lowest price from 00:00 to 04:00 then the highest price should be at 00:00 19239.5 and the lowest at 04:00 19129.5. The next candle to close above/below these levels was the close of the 07:00 candle at 19129.4. This is where a sell trade should have been entered at the open of the 08:00 candle with the stop loss the highest point i.e. 19239.5.
However, when I run the above example using the programme you have written, it seems to enter a random sell entry at 06:00 a second sell entry at 13:00 which is clearly incorrect as the system should only take a maximum of 1 trade per day which should be at the close of the of the 07:00/open of the 08:00 candle .
Could you please check and compare with my results?
12/20/2017 at 10:23 AM #5612012/20/2017 at 11:45 AM #56130Hi Nicolas
Yes – I’m typically measuring anything between 5minute and 1 hour charts for intraday trading.
The programme above isn’t quite right – its making multiple spurious entries at random times – it should simply buy/sell the next candle after breakout
Andy
12/20/2017 at 11:53 AM #56131I’ve been reading the programming code manual but am struggling to make sense of the order of the coding – i.e. the order of commands. Could you advise if there are there any online video resources that explain this? I’ve noticed there is a video for building indicators but cant find anything for how to create a programme?
Any help/advise would be much appreciated
Regards
Andy
12/21/2017 at 7:05 PM #56279Getting closer but still not right!
Here is the revised version of my breakout indicator from PRT – now correctly taking only 1 trade per day but still entering trades early – as soon as it touches the high/low levels – i.e. not waiting for bar to close above/below breakout levels before entering the trade at the open of the next bar. At the foot is my screen shot explanation to PRT…. can anyone help advise a fix for this?? I’d also like to be able to manually enter stop and take profit levels if possible…
As a programming newbie, I’d very much appreciate a bit of assistance with this if anyone can spare a few minutes??
begintime=000000
endtime=040000
XX=0if barindex=tradeindex or time=begintime then
trading=0
endif
if time=endtime then
trading=1
endifif time=begintime or(time > begintime and time[1]<begintime) then
myhigh=high
mylow=low
elsif time > begintime and time <= endtime then
myhigh=max(high,myhigh)
mylow=min(low,mylow)
endifif not longonmarket and trading then
buy 1 share at myhigh+1*pointsize stop
sell at mylow+XX stop
set target pprofit (myhigh-mylow)/pointsize
endifif longonmarket then
sell at mylow+XX stop
endifif not shortonmarket and trading then
sellshort 1 share at mylow-1*pointsize stop
exitshort at mylow-XX stop
set target pprofit (myhigh-mylow)/pointsize
endifif shortonmarket then
exitshort at mylow-XX stop
endif
***********************
Please note that you can change the period for measured highest and lowest points in the code’s part below:
*****************
begintime=000000
endtime=040000
XX=0
*****************12/21/2017 at 9:27 PM #5629812/21/2017 at 9:59 PM #56300Hi GraHal
Thanks for your response – and the heads up! I’m new to the site and unfamiliar with protocol…but learning. Does this look better?
breakout programme123456789101112131415161718192021222324252627282930313233begintime=000000endtime=040000XX=0if barindex=tradeindex or time=begintime thentrading=0endifif time=endtime thentrading=1endifif time=begintime or(time > begintime and time[1]<begintime) thenmyhigh=highmylow=lowelsif time > begintime and time <= endtime thenmyhigh=max(high,myhigh)mylow=min(low,mylow)endifif not longonmarket and trading thenbuy 1 share at myhigh+1*pointsize stopsell at mylow+XX stopset target pprofit (myhigh-mylow)/pointsizeendifif longonmarket thensell at mylow+XX stopendifif not shortonmarket and trading thensellshort 1 share at mylow-1*pointsize stopexitshort at mylow-XX stopset target pprofit (myhigh-mylow)/pointsizeendifif shortonmarket thenexitshort at mylow-XX stopendifAndy
12/21/2017 at 10:08 PM #56302Results attached 100,000 1 min bars @ Spread = 2
Seems to do really well whilst market is choppy / ranging?
Kinda ‘treads water’ during several week up / down trends?
Andy … are you able to improve performance during trends? Or have I screwed it up changing your XX value?? 🙂
12345678910111213141516171819202122232425262728293031323334353637383940414243//https://www.prorealcode.com/topic/breakout-indicator/#post-56298//Time Standard UCT + 0 (GMT)begintime=070000endtime=083500XX=16if barindex=tradeindex or time=begintime thentrading=0endifif time=endtime thentrading=1endifif time=begintime or(time > begintime and time[1]<begintime) thenmyhigh=highmylow=lowelsif time > begintime and time <= endtime thenmyhigh=max(high,myhigh)mylow=min(low,mylow)endifif not longonmarket and trading thenbuy 1 share at myhigh+1*pointsize stopsell at mylow+XX stopset target pprofit (myhigh-mylow)/pointsizeendifif longonmarket thensell at mylow+XX stopendifif not shortonmarket and trading thensellshort 1 share at mylow-1*pointsize stopexitshort at mylow-XX stopset target pprofit (myhigh-mylow)/pointsizeendifif shortonmarket thenexitshort at mylow-XX stopendif12/21/2017 at 10:43 PM #56305Fantastic! Much appreciated.
Looks quite good doesn’t it?…I felt sure I was on to something with this – just needed the programme for back testing to prove it.
Don’t think you’ve done any harm changing the “XX” value – that was the reason I wanted it in there so stops can be extended to cope with those familiar spikes!
I’ll have a play around with it over the next few days and share the results with you.
One thing I have just noticed is that it is still taking trades half way up/down a candle instead of waiting for that candle to close and entering at the open of the next after price has broken out. (screen shot attached)
Once again, thanks for you help with this.
Andy
12/21/2017 at 11:07 PM #56307Yeah its entering part way thro a candle due to the Buy Stop Sell Stop levels?
I’ve not deciphered your code but may get ‘more into it’ if it makes me some money tomoz! 🙂 Don’t worry, I’ll only run it if I’m at my desk watching it closely.
It’s good to see a live trade unfold realtime! 🙂
GraHal
PS I guess you should make sure the code is working as you intended? It’s possible that my optimising has simply ‘curve fitted’ to get a (good) result?For example … is below working correct, bearing in mind my version is a 1 min timeframe?? Sure you don’t need Highest / Lowest over x periods etc??
1234567if time=begintime or(time > begintime and time[1]<begintime) thenmyhigh=highmylow=lowelsif time > begintime and time <= endtime thenmyhigh=max(high,myhigh)mylow=min(low,mylow)endif12/21/2017 at 11:30 PM #5630912/21/2017 at 11:40 PM #5631012/22/2017 at 12:09 AM #56311yeah – well I think so! by entering the begin/end times x isn’t important (I didn’t think it was that is) – but there again I’m a complete newbie to syntax – I gave PRC the brief at the to of this thread and that’s what they came up with.
Just had a quick look at the wall st……try “XX”= 2, begin 0700 end 1400, 100,000, 5min, used 2pt spread. Results attached. I can see its going to be a late night!
Be even better if we can get it to take the trade on the open of the next bar after breakout – otherwise, it gets caught with to many false breakouts.
12/22/2017 at 10:03 AM #56345Strat has opened a Buy Stop Order on the DAX at 13110 which is 1 point above the highest point reached between times below. I can’t figure out how it is working as I was expecting the 16 points to feature somewhere!!? 🙂
123begintime=070000endtime=083500XX=16 -
AuthorPosts
Find exclusive trading pro-tools on