3 Little Pigs System Automation

Post Reply
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

3 Little Pigs System Automation

Post by milanese »

The EA I coded and all updates, you will always find in third post of this thread..

Cheers :)

Tommaso
This was the original request:
Hello traders,

I've been following this system for about 6 months on the babypips.com website. I believe this system is worth creating an EA or moving average PA touch and/or crossover alert/email indicator. To get every trade opportunity one must check the markets every 4 hours. A follower of this system modified the original rules that incorporates a fixed SL and TP. This trader compiled all the possible trades for 2013 and showed this system generated an average of 272 per month. Here are the original rule:

Credit goes to Harmonicphil

OVERVIEW
The 3 Little Pigs is based on 3 timeframes, Weekly, Daily and 4 Hour. The idea is to “swing” trade in the direction of all 3 timeframes, a Buy signal, as an example:
• Price is above the 55 Simple Moving Average (SMA) on the Weekly timeframe
• Price is above the 21 SMA on the Daily timeframe
• Price closes above the 34 SMA on the 4 Hour timeframe
When the above conditions are met a Long position is opened.
These are the basics - Sell is vice versa.

ENTRY
As I mentioned, there are a number of options in the manual – Here is my chosen approach:
BUY
• Price is above the 55 SMA on the Weekly timeframe and
• Price is above the 21 SMA on the Daily timeframe, I will enter
• On close of the next candle that touches and then closes above the 34 SMA on the 4 Hour timeframe
SELL
• Price is below the 55 SMA on the Weekly timeframe and
• Price is below the 21 SMA on the Daily timeframe, I will enter
• On close of the next candle that touches and then closes below the 34 SMA on the 4 Hour timeframe

STOP LOSS
My choice here may seem a little complicated but only when written down, in practice it’s really straight forward.
First, I check the 14 period Average True Range (ATR(14)) which I added to all my 4 Hour charts. I add the High and the Low values (displayed on the right) and multiply this by 25% – I place my stop above/below the 34 SMA on the 4 Hour timeframe by this number of PIPs.
I have included an example as an attachment.
This is not a real setup just a chart I decided to use to demonstrate how I calculate my Stop loss.
This is the 4 Hour timeframe and assumes price is above the 55 SMA on the Weekly timeframe and the 21 SMA on the Daily timeframe. Price has touched the 34 SMA and has closed above it. The High and the Low of the ATR(14) is 26 and 14 which gives me 40. I take 25% of this value which is 10 PIPs. To get my Stop loss I subtract this from the current 34 SMA value (8460 – 10) so my Entry here is 8482 (the candle close), plus Spread and my Stop loss is 8450.
I will then use a Trailing Stop loss behind the 34 SMA on the same basis, e.g. if the 34 SMA rises to 8475 I will then trail my Stop loss to 8465.

TARGET
Again the manual offers a number of options but I use an open target and exit only when my Trailing Stop loss is taken out.

RE-ENTRY
If I get stopped out I will re-enter according to my Entry rules.



Read more: http://forums.babypips.com/free-forex-t ... z2oOglyuHJ

Credit to four candles for his hard work on backtesting his modification.

The modified rules are that trades are executed as above except the following:

Pairs: EURUSD, GBPUSD, USDCAD, AUDUSD, EURGBP, and USDJPY

TP: 60 Pips except 75 pips for UJ
SL: 30 pips except 50 pips for UJ

Only one trade per pair and all trades are closed on fridays

Attached is his spreadsheet with all the trade details

Please let me know if it's possible to code this system into an EA. If someone can code this into an EA, it will be shared with the trading community. Thanks
You do not have the required permissions to view the files attached to this post.
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

Re: 3 Little Pigs System Automation

Post by milanese »

rktrader714 wrote:Hello traders,

I've been following this system for about 6 months on the babypips.com website. I believe this system is worth creating an EA or moving average PA touch and/or crossover alert/email indicator. To get every trade opportunity one must check the markets every 4 hours. A follower of this system modified the original rules that incorporates a fixed SL and TP. This trader compiled all the possible trades for 2013 and showed this system generated an average of 272 per month. Here are the original rule:

Credit goes to Harmonicphil
.....
Please let me know if it's possible to code this system into an EA. If someone can code this into an EA, it will be shared with the trading community. Thanks

Hi,

I will take a look what I can code :xm:

Cheers :)

Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

Re: 3 Little Pigs System Automation

Post by milanese »

[mod=]
SERIOUS WARNING
  • Most Forex traders lose all their money.
  • Using the robot posted here in trading Forex does not guarantee success.
  • Trading this robot could lead to serious financial loss.
  • Trading this robot without understanding its underlying trading strategies guarantees traders will lose their money.
  • This is not a set-and-forget ea; there is no such thing and anyone who tries to claim there is, is either stupid or lying. This ea requires frequent manual intervention.
  • At best, a trading robot is only 90% as good as the manual strategy it trades. At best. At worst, it can be much less effective. If the strategy is rubbish, so is the robot.
  • To trade this robot, you have to understand:
    • How to use EA's.
    • Market trend and retracement patterns.[/mod]


      Ok here is the first version, as always please test it carefully on a demo first..
      SetBEminPip sets the min SL distance from actual price if the EA in profit is moving SL
      MinTPProfitInUSD sets the minmal win that the position must have for using the closing roule too in profit

Please use it on H4 Chart
Cheers :xm:

Tommaso

EA Update from 11 jan,2014
The new version can add aditional trades in trend, if you want.
The settings you will find here:
AddAdditionalPositionsInTrend=true set this to false if you don't want to stack
MaxAdditionalPositions=1 here you set the the max additional trades

Update 21 jan, 2015
LatestVersion for the new builds, with some fixes, automatic spread calculation, and better ordersendsecurity, the strategy-parts are the same, so normally the EA should have nearly same results.
The seperate stack moving SL function is not anylonger in the code, the EA uses for all trades the same moving SL roules,this should not affect the results. The EA will new show the spread that was actual when the order was opened. The OOTB settings are the same like in the latest official B version.

Update 28 feb, 2015
AGT had the idea that function that lets the EA close all open positions if a certain profit reached maybe could give better results. As I lked the idea I embedded this function in the EA and did some cosmetic updates to my latest EA look..
this are the new inputs

Code: Select all

extern string   CloseAllProfitSet1="---Set this to true to close all EA positions----";
extern string   CloseAllProfitSet2="---if Profit reaches CloseAllOfPairInProfit----";
extern bool   UseCloseAllOfPairInProfit=true;
extern string   CloseAllProfitSet3="---enter here the amount in account Currency----";
extern double CloseAllOfPairInProfit=100;
ThreeLittlePigsNextGen_211.mq4
Note the EA counts only its own trades on the specific pair.
You do not have the required permissions to view the files attached to this post.
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

Re: 3 Little Pigs System Automation

Post by milanese »

I did some fixing in the closing logic, please all who had downloaded, redownload as it now works as intended( or should :lol: ), you will find the EA in Post 3 (like 3 little pigs :party: ) ..

Merry Christmas to all :xm:

Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
User avatar
fxdaytrader
Trader
Posts: 190
Joined: Sun Jun 10, 2012 7:03 am
Location: Poon-Town (germany, se-asia, se-europe) ...

Re: 3 Little Pigs System Automation

Post by fxdaytrader »

nice job Tommaso :P

Attached one simple template for that system (the h4 (red),d1(orange),w1(white) moving averages are only displayed in that timeframes).
I have added a mtf (multitimeframe) moving average so that you have the d1, w1 smas displayed in h4 also.

And I am sure somebody wants to backtest the system in craptester. Since it cannot deal with multitimeframe-stuff (as I think), I have added two more mas to the template (must change in the ea also):
SMA 126 (which is daily 21 x 6) and sma 1650 (which is weekly 55 x 5 x 6).

Adjust the template to fit your needs, see the draft attached :P

edit: Attached milanese's EA with small mod.: made the ma-parameters external (just in case someone likes to play around with the params/craptest the ea), added copyright and changed

Code: Select all

if (d == 1 && BrokerHasSundayCandle && Period()==1024)
to

Code: Select all

if (d == 1 && BrokerHasSundayCandle && Period()==1440)
;)
You do not have the required permissions to view the files attached to this post.
Last edited by fxdaytrader on Wed Dec 25, 2013 8:41 am, edited 1 time in total.
User avatar
fxdaytrader
Trader
Posts: 190
Joined: Sun Jun 10, 2012 7:03 am
Location: Poon-Town (germany, se-asia, se-europe) ...

Re: 3 Little Pigs System Automation

Post by fxdaytrader »

8-) small copy&paste-bloop spotted in double LastOpenTradePrice(string strSymbol, int nMagic)

I have changed

Code: Select all

for (int i=OrdersTotal()-1 ; i>=0 ; i--)
to

Code: Select all

for (int i=OrdersHistoryTotal()-1 ; i>=0 ; i--)
and

Code: Select all

if (!OrderSelect(i,SELECT_BY_POS)) continue;
to

Code: Select all

if (!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) continue;
User avatar
fxdaytrader
Trader
Posts: 190
Joined: Sun Jun 10, 2012 7:03 am
Location: Poon-Town (germany, se-asia, se-europe) ...

Re: 3 Little Pigs System Automation

Post by fxdaytrader »

I think a few more, my changes:

in datetime TimeElapsedSinceLastOpenTrade(string strSymbol, int nMagic)
added

Code: Select all

if (opentime==0) return(-1);
after the for-loop, vice versa (only the vars have other names) I did in datetime TimeElapsedSinceLastHistoTrade(string strSymbol, int nMagic)


In CloseTheTrade(
in the check for closing OP_BUY-loop I changed

Code: Select all

if(Bid < StopValueSell)
to

Code: Select all

if(Bid < StopValueBuy)
in the signal-check after

Code: Select all

if (BuyOk==1)
(for sell vice versa) changed the lines to

Code: Select all

if(TimeElapsedSinceLastOpenTrade(Symbol(),MagicNumber)>DeltaTimeLiveTrades || TimeElapsedSinceLastOpenTrade(Symbol(),MagicNumber)==-1)
if(TimeElapsedSinceLastHistoTrade(Symbol(),MagicNumber)>DeltaTimeHistoTrades || TimeElapsedSinceLastHistoTrade(Symbol(),MagicNumber)==-1)
in the displayuserinfo-function I have added a short infostring (string sMainDirInfo;) which should show the main direction of the price/moving averages

Find the (current) actual mod. version attached.

To play around with craptester I have added two bools:
extern bool AdjustTfForH4: if true, it will adjust the ma-periods so you can run craptester in H4 timeframe

extern bool AdjustTfForH1 = should convert all to h1 (so ma34 is h1, the medium h4, the high-tf d1), just as a pastime.

I do not know whether Tommaso will keep that mods. or not, but in the attached version they are implemented.

what a day - Markets closed, cannot be bothered to read some books, shit wheather outside and too early to have some drinks - so playing around with mql4 + craptester now ... :yahoo:
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

Re: 3 Little Pigs System Automation

Post by milanese »

Hi Marc,

happy christmas :xm: :xm: sure I will take that, thanks for this bug fixing :party: and the new stuff :yahoo:

Cheers :)

Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

Re: 3 Little Pigs System Automation

Post by milanese »

Ok as always in this thread :party: you will find the actual version attached at post three

Cheers :xm:

Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
bazze

Re: 3 Little Pigs System Automation

Post by bazze »

Just great,guys :clap: :cheer: :clap:
Post Reply

Return to “Automated trading systems”