Sunday Bar Breakout

User avatar
squalou
Trader
Posts: 49
Joined: Wed Nov 16, 2011 8:57 am
Location: fabulous Aix en Provence, southern France;

WORBOT EA Version 1.0

Post by squalou »

Hi everyone!

Welcome to "WORBOT", the Weekly Opening Range BreakOut BOT !

Khalid asked me to code this robot for him a few weeks ago.
After 2 weeks of forward-testing, we have now reached the point where the bot seems to be ready for publishing.
:party:
Attached to Post #2 is version 1.0.
This version and any new version will also be attached to post #2 of the thread.

WARNING: It is still experimental, and may still have some bugs, so:


!!! PLEASE DO NOT USE THIS ROBOT ON LIVE ACCOUNTS YET !!!


This is a single-pair trader;
If you are planing to trade WORBOT on 28 pairs (or more), then you'll have to open 28(or more) charts, and load WORBOT on each of them;

You can load WORBOT on any timeframe, although M15 is recommended for "visual comfort"...
Make sure you have enough H1 history loaded in your platform to get accurate average WOR values.

Although the week is already started at the time of this post, no hurry:
you still have a few hours to load and start WORBOT on your demo charts before it starts looking for placing trades...

The EA displays the "Weekly Opening Range" (WOR) as a light blue box when it is completed, or purple box when the Opening Range period is not yet completed;
Once the WOR period is completed, the WOR box turns light blue, and the Long and Short trading zones are displayed as light green boxes above and below the WOR box.

WORBOT will also display the past weeks WOR boxes and corresponding Long and Short trading zones.

The "comment zone" displays live information showing various inputs and calculated parameters.

WORBOT can be backtested, with the restriction that Empty4 backtester will only load a small amount of H1 history data, typically 10 weeks or so only.
This will have the side effect of giving inaccurate average WOR box sizes in the backtester, potentially modifying the trade allowed/not allowed condition on some backtested weeks.


I encourage you to experiment with various WOR box durations (WeeklyOpeningBoxDuration input), the default being 7-hours boxes.
You can try with 24-hours boxes to let the whole Monday pass to build a "Monday Range box" before WORBOT starts placing trades.
Or even 48 hours if you want to wait for any potential "direction of the week" to be established.

Many inputs can be customized and produce very different outcomes.
You are welcome to post your findings on the thread.



------------------------------
Quick review of the EA inputs:
------------------------------


WeeklyOpeningBoxDuration = 7; duration in hours of the weekly opening "box"

HoursBeforeEndOfWeekToCloseTrades = 9; close trades X hours before the trading week closes; 9 hours before the markets close is Friday 3PM EST;

AvgWeeklyOpeningRangeNumWeeks = 52; number of past weeks to determine the Average Weekly Opening Range;
if the available H1 history data contains less than 52 weeks, the EA will use whatever is available;

MaxAvgWeeklyOpeningRangeFactor = 1.25; factor of the Average Weekly Opening Range to determine the max acceptable range to allow trading;

MinBoxSizeInPips = 0; min tradable box size; when box is smaller than that, you should at least reduce your usual lot-size if you decide to trade it;

EntryBufferPips = 3.0; adds an extra buffer to the WOR for Buy/Sell entry levels

---- Position Sizing Inputs ----

RiskPerCent = 0; % of AccountBalance for the given SL; 0 will use fixed Lots below;

MinBuyLots = 0.0; Fixed minimum Lotsize for BUYs; when 0, will use the MINLOT for the symbol; Not used when RiskPerCent is not 0;
MinSellLots = 0.0; Fixed minimum Lotsize for SELLs; when 0, will use the MINLOT for the symbol; Not used when RiskPerCent is not 0;

---- SL/TP management: ----

The computed SL is considered our '1R' value (Initial Risk);
All other SL/TP management parameters are in multiples of this '1R' ("R-multiples"), in other words: multiples of the SL;

SLFactor = 1.0; SL is defined as a factor of the WOR box size;
if SLFactor >= 10, it will be considered as FIXED PIPs rather than a factor of the WOR box;

Reward_Risk_ratio = 1.5; R:R ratio: the TP will be set as R:R * 1R (= R:R * SL);

MoveToBEAfter_Rmult = 1.0; move to BE+ when profit reaches this R multiple (factor of SL);
BEProfit_in_Rmult = 0.0; lock-in this amount of R-multiple when MoveToBEAfter_Rmult is hit;
TrailingStart_at_Rmult = 0.5; R-multiples to start trailing the StopLoss;
TrailingStop_in_Rmult = 0.5; R-multiples to trail the StopLoss; if 0 then no trailing stop
TrailingStopStep_in_Rmult = 0.1; trailing SL jumping step in R-multiples

---- Trades per week limits:


MaxTradesAllowedPerSession = 2; max number of trades per week, whatever direction; 0 means no limit on trades;

AllowThirdTrade = false; option to allow a 3rd trade when both Buy and Sell trades were losses;

MaxLossesAllowedPerSession = 2; max number of losses per week, whatever direction; 0 means no limit on losses

MaxWinsAllowedPerSession = 2; max number of wins per week, whatever direction; 0 means no limit on wins

---- Misc stuff:

TradeComment="Weekly Opening Range Breakout EA";
SlippagePips = 3.0;
MaxSpreadPips = 4.0; spread limitation: the EA won't send trades if spread is higher than this value;
brokerIsECN = false; set this to TRUE if your broker requires to send trades with no SL and TP; the order will be modified in order to apply the TP and SL;


Regards to all;
Squalou
:xm:
" Every battle is won before it is ever fought "
Sun-Tzu, The Art of War, 400BC.
User avatar
squalou
Trader
Posts: 49
Joined: Wed Nov 16, 2011 8:57 am
Location: fabulous Aix en Provence, southern France;

WORBOT Version 1.1 is in Post #2

Post by squalou »

Post #2 updated with version 1.1 to fix a situation that had not yet been tested: trades with no predefined R:R.

- Version 1.1: fix: when Reward_Risk_ratio is set to 0, WORBOT would not send any trade; Reward_Risk_ratio=0 will now send the trade with no TP; the trade should be monitored manually, or using Steve's MPTM (or any other trade management EA).

Sq
" Every battle is won before it is ever fought "
Sun-Tzu, The Art of War, 400BC.
User avatar
Wavegarrick
Trader
Posts: 1172
Joined: Sun Dec 30, 2012 11:21 am
Location: South Africa

Sunday Bar Breakout

Post by Wavegarrick »

Hi Khalaad and Squalou.

Thanks for all the hard work you Guys have put into this Ea. I have started practising this method manually from Khalaads 1st postings and it does look promising. Demo up and running on 7hr input. The 24 hr setting and 48 hr does look promising but will look at that from next week.

Thanks again Guys :good:
Radar
Trader
Posts: 437
Joined: Fri Mar 23, 2012 5:39 pm
Location: Round the bend ;)

Sunday Bar Breakout

Post by Radar »

Good evening, gentlemen :)

Nice work! :)

I got caught out when I put the EA on a couple of charts this morning... It said that the session had finished for the week, with today's date... I found the culprit... Any chance of replacing TimeCurrent() with Friday's close time?

And now, for a couple of silly trade management ideas...

1. A long, long time ago, in a far, far forex factory, a hard trader began teaching people how to build a stairway to success... A few days later, Squalou popped in, and coded an indicator for it... Not long after, Mer071898 suggested adding Fib-lines as TP points... The Fibs were based on the size of the box, and more often than not, price-action respected those levels.

As much as I loved the simple entry system, I wasn't all that enamored by the lot sizes (even at 0.03 lots), and couldn't see the point in scaling-out of winning trades, or using TP's (or wig warmers, for that matter). So I came up with my own silly management system...

Use the Fib-lines as jumping stop points... When price closes above (for longs) the 2nd fib-line, move SL to a few pips below the 1st fib-line... When it closes above the 3rd fib-line, move SL to a few pips below the 2nd fib-line... Continue until you have enough profit protected by an SL to pay for the potential loss of a scale-in... Rinse and repeat.

It took me 2 years of staring at useful code and turning it into a pile of goop before I could pull parts out of Steve's shell and put them together to make a trade management/scale-in EA that followed my philosophy of "Risk balance on the first trade, risk a fraction of (or all) locked-in profit for scale-ins" but it used fixed pip distances, as I couldn't work out how to create and use the Fibs, (I reckon they'd work better with BO Boxes anyways). Here ends silly idea No.1.

2. Use the breakout as an entry point for long-term trends... It's best if we're using the fibs at jumping SL points to pull this one off, but we can use any other method that extends the range of each jump...

Take the breakout trade as normal, and manage the trade's SL so that each jump is further away from market... If the trade is still running by Thursday evening (NY time), we stop moving our SL...

Now, here's the weird bit... We take the average weekend gap, multiply it by 1.5, and if our SL is within that range from market by 4pm NY time, we close the trade.

If, on the other hand, our SL is outside that range, we leave the SL where it is, and wait 'til a new box is formed on Monday... If the break-out of that box is going against us, we take that trade, and close last week's trade... If the break-out is in our direction, we take it, and manage both trades, using the new box's jumping-stop ranges. Here ends silly idea No.2.

Anyroad, thought you might be interested... ;)

Have fun!

Radar =8^)
Check out my new, (well, old now), manual trade & automatic scale-in manager,
StackManV2
bazze

Sunday Bar Breakout

Post by bazze »

Trades since yesterday :good:
You do not have the required permissions to view the files attached to this post.
bazze

Sunday Bar Breakout

Post by bazze »

Oooops ;)
You do not have the required permissions to view the files attached to this post.
bazze

Sunday Bar Breakout

Post by bazze »

Will you update the fix,Khalid?
bazze

Sunday Bar Breakout

Post by bazze »

Khalaad » Thu May 29, 2014 5:06 pm wrote:
bazze » Thu 29 May 2014 9:01 pm wrote:Will you update the fix,Khalid?
Yes, bazze, Sq will correct this and post the updated version. In time for next week.

Khalid
Great :good:...Thanks to you,guys :clap:...Have a nice weekend :party:
User avatar
squalou
Trader
Posts: 49
Joined: Wed Nov 16, 2011 8:57 am
Location: fabulous Aix en Provence, southern France;

Sunday Bar Breakout

Post by squalou »

Thank you Khalid and all for the kind words.

Thanks to the past pre-release tests and now to these forward-live-testing, we are making progress on refining WORBOT's behaviour.

I will post an updated version before sunday night, with additional inputs to refine the Long/Short options, and also fix box/trading zone/TP levels calculations and updating issues, that are misleading when looking at the screen.

Once we have a reliable engine, we can move on to the really interesting challenge:
reducing losses and maximizing profits, by improving position sizing and risk management.

Sq
" Every battle is won before it is ever fought "
Sun-Tzu, The Art of War, 400BC.
User avatar
squalou
Trader
Posts: 49
Joined: Wed Nov 16, 2011 8:57 am
Location: fabulous Aix en Provence, southern France;

WORBOT Version 1.2 is in Post #2

Post by squalou »

Hi all,

as promised, please find Version 1.2 in Post #2.

It should fix the visual issues (boxes not updating after the "FORMING" period).

New inputs are added to select separately the max number of BUY and SELL trades for a given session:
extern int MaxBuyTradesAllowedPerSession = 2;
extern int MaxSellTradesAllowedPerSession = 2;

These are still eventually limited by "MaxTradesAllowedPerSession".

Enjoy!
Sq
:xm:
" Every battle is won before it is ever fought "
Sun-Tzu, The Art of War, 400BC.
Post Reply

Return to “Automated trading systems”