Slopey Peaky Bob
-
Zennor
- Trader
- Posts: 276
- Joined: Fri Feb 08, 2013 4:44 pm
- Location: On a Canal Boat travelling the waterways.
Slopey Peaky Bob
Steve that is a great idea, regarding my recent trading I had thought that the TP should be proportional to the lot size hence the reason for my increase to see if the risk/reward was a viable option.
I was also considering the fact that trading possibly so many pairs the chicken route as you call it certainly has its merits if you want a stress free life. So I'm now looking at the viability of trading fewer but uncorrelated pairs with a higher lot size so say if the USD heads south it only does it on one pair or two pairs at most and not a host of pairs. Still tinkering with this idea at the moment.
I was also considering the fact that trading possibly so many pairs the chicken route as you call it certainly has its merits if you want a stress free life. So I'm now looking at the viability of trading fewer but uncorrelated pairs with a higher lot size so say if the USD heads south it only does it on one pair or two pairs at most and not a host of pairs. Still tinkering with this idea at the moment.
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Slopey Peaky Bob
Preparing this post highlighted a bloop that means that SPB will use the dynamic lot size calculation whether you want him to or not, so please re-download 1i.
I forgot to explain 1i for the DIY enthusiasts, so here goes:
Do a search for "void AutoTrading()" and add this function directly above:
The top block of code inside the "void AutoTrading()" function ends with this bracket and comment:
"}//if (ForceWholePositionClosure)". Insert this code block underneath:
Do a search for "extern double BasketTargetCash=0;" and add this underneath:
Do a search for "int OnInit()" and scroll down to "//Lot size based on account size" and add this underneath:
Do a search for "SM("Click a pair to open its chart, the table name to switch between views, the headers to show/hide details, the labels at the bottom to let them do what they offer."+NL);" and add the TP display code directly above:
Do a search for "double CalculateLotSize(string symbol, double price1,double price2)" to take you to the RiskPercent based lot calculation, scroll down to "return(LotSize);" and insert this code directly above:
Do a search for "void CalculateLotAsAmountPerCashDollops()" to take you to the LotsPerDollop based lot calculation and add this to the end of the function, underneath "Lot = minlot;":

I forgot to explain 1i for the DIY enthusiasts, so here goes:
Do a search for "void AutoTrading()" and add this function directly above:
Code: Select all
void CalculateDynamicBasketCashTP()
{
//Calculates a basket cash TB calculated by lot size
BasketTargetCash = NormalizeDouble(CashTakeProfitPerLot * Lot, 2);
}//End void CalculateDynamicBasketCashTP()"}//if (ForceWholePositionClosure)". Insert this code block underneath:
Code: Select all
//Dynamic basket TP applied to a fixed lot size
if (CloseEnough(LotsPerDollopOfCash, 0))
if (CloseEnough(RiskPercent, 0))
CalculateDynamicBasketCashTP();
Code: Select all
extern string dbt="-- Dynamic basket take profit --";
//Basket cash TP based on lot size
extern bool UseDynamicCashTP=true;
extern double CashTakeProfitPerLot=3000;
Code: Select all
//Dynamic basket TP applied to a fixed lot size
if (CloseEnough(LotsPerDollopOfCash, 0))
if (CloseEnough(RiskPercent, 0))
CalculateDynamicBasketCashTP();
Code: Select all
if (TreatAllPairsAsBasket)
SM("Lot size = " + DoubleToStr(Lot, 2) + ": Basket cash take profit = " + AccountCurrency() + " " + DoubleToStr(BasketTargetCash, 2) + NL);
Code: Select all
//Dynamic basket take profit
if (TreatAllPairsAsBasket)
if (UseDynamicCashTP)
CalculateDynamicBasketCashTP();
Code: Select all
//Dynamic basket take profit
if (TreatAllPairsAsBasket)
if (UseDynamicCashTP)
CalculateDynamicBasketCashTP();
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
- woodlands
- Trader
- Posts: 226
- Joined: Sun Mar 23, 2014 6:16 pm
Slopey Peaky Bob
I have been away for some weeks and left SPB unattended on the (Eaymon) VPS and now catching up
My £2 profit/ M5 setup hasn't worked out.....
Both these have been running without intervention for 8 weeks
But the 'normal' £30 / H4 is looking after itself fine.....
This includes the TCRSS tests which are still above water
My £2 profit/ M5 setup hasn't worked out.....
Both these have been running without intervention for 8 weeks
But the 'normal' £30 / H4 is looking after itself fine.....
This includes the TCRSS tests which are still above water
You do not have the required permissions to view the files attached to this post.
-
1of3
- Posts: 4
- Joined: Mon Nov 21, 2011 1:36 pm
Slopey Peaky Bob
Hi Steve,
I found a bug in the AutoTrading function.
You need to change the following code (that's just under the ForceWholePositionClosure function)
to this.
Otherwise it will always auto calculate the CashTake Profit.
Thank you for this wonderful EA.
John
I found a bug in the AutoTrading function.
You need to change the following code (that's just under the ForceWholePositionClosure function)
Code: Select all
//Dynamic basket TP applied to a fixed lot size
if (CloseEnough(LotsPerDollopOfCash, 0))
if (CloseEnough(RiskPercent, 0))
CalculateDynamicBasketCashTP();
Code: Select all
//Dynamic basket TP applied to a fixed lot size
if (UseDynamicCashTP)
if (CloseEnough(LotsPerDollopOfCash, 0))
if (CloseEnough(RiskPercent, 0))
CalculateDynamicBasketCashTP();
Thank you for this wonderful EA.
John
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Slopey Peaky Bob
Thanks John. I added the extra line in On Init() but forgot here.1of3 » Mon May 21, 2018 3:13 pm wrote:Hi Steve,
I found a bug in the AutoTrading function.
You need to change the following code (that's just under the ForceWholePositionClosure function)
to this.Code: Select all
//Dynamic basket TP applied to a fixed lot size if (CloseEnough(LotsPerDollopOfCash, 0)) if (CloseEnough(RiskPercent, 0)) CalculateDynamicBasketCashTP();
Otherwise it will always auto calculate the CashTake Profit.Code: Select all
//Dynamic basket TP applied to a fixed lot size if (UseDynamicCashTP) if (CloseEnough(LotsPerDollopOfCash, 0)) if (CloseEnough(RiskPercent, 0)) CalculateDynamicBasketCashTP();
Thank you for this wonderful EA.
John
I will post the fix later folks. Lucky64 sent me the code to add this feature to the individual pair baskets, so I will release the fix at the same time - just got a few lines to add to the user guide first. DIYers, this is an easy fix: start at the top of the code and do a search for "//Dynamic basket TP applied to a fixed lot size". There are two of them and the second one needs the line of code adding that John mentions.
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Slopey Peaky Bob
V 1j is in post 1; this includes John's fix in my previous post.
Luciano (Lucky64) sent me the code that allows SPB to calculate a dynamic TP for single pair baskets. Nice one Luciano.
I have updated the user guide but you only need it if you are new to all this. The inputs in the "Individual pairs" basket inputs are obvious and work in the same way as for whole position basket trading.
Three steps for DIY:
Do a search for "extern double IndividualBasketTargetCash" (clear the "Match whole word only" tickbox). Insert this code directly underneath:
Do a search for "SM("Lot size = " + DoubleToStr(Lot, 2)". This will take you to the chart display. The existing code is:
Delete it and replace it with this block:
Do a search for "bool CanIndividualPairBasketBeClosed(string symbol, int PairIndex)" and scroll down to, "//Cash target" - the second code block. Delete the whole block and replace it with:

Luciano (Lucky64) sent me the code that allows SPB to calculate a dynamic TP for single pair baskets. Nice one Luciano.
I have updated the user guide but you only need it if you are new to all this. The inputs in the "Individual pairs" basket inputs are obvious and work in the same way as for whole position basket trading.
Three steps for DIY:
Do a search for "extern double IndividualBasketTargetCash" (clear the "Match whole word only" tickbox). Insert this code directly underneath:
Code: Select all
extern string dbi="-- Dynamic individual pair basket take profit --";
//Individual Pair Basket cash TP based on lot size. Lucky64 added this function. Many thanks Luciano.
extern bool UseDynamicCashTPIndividualPair=true;
extern double CashTakeProfitIndividualePairPerLot=1000;
Code: Select all
if (TreatAllPairsAsBasket)
SM("Lot size = " + DoubleToStr(Lot, 2) + ": Basket cash take profit = " + AccountCurrency() + " " + DoubleToStr(BasketTargetCash, 2) + NL);
Code: Select all
string sizingInfo = "Lot size = " + DoubleToStr(Lot, 2);
if (TreatIndividualPairsAsBasket)
{
if (UseDynamicCashTPIndividualPair)
{
IndividualBasketTargetCash = NormalizeDouble(CashTakeProfitIndividualePairPerLot * Lot, 2);
} // if (UseDynamicCashTPIndividualPair)
sizingInfo += " , Individual pair basket cash take profit = " + AccountCurrency() + " " + DoubleToStr(IndividualBasketTargetCash, 2);
}//if (TreatIndividualPairsAsBasket)
if (TreatAllPairsAsBasket)
sizingInfo += " , Basket cash take profit = " + AccountCurrency() + " " + DoubleToStr(BasketTargetCash, 2) ;
SM(sizingInfo + NL);
Code: Select all
//Cash target
if (!CloseEnough(IndividualBasketTargetCash,0) )
{
if (UseDynamicCashTPIndividualPair)
{
IndividualBasketTargetCash = NormalizeDouble(CashTakeProfitIndividualePairPerLot * Lot, 2);
} // if (UseDynamicCashTPIndividualPair)
if (CashUpl[PairIndex] >= IndividualBasketTargetCash)
{
CloseAllTrades(symbol, AllTrades);
if (ForceTradeClosure)
{
CloseAllTrades(symbol, AllTrades);
if (ForceTradeClosure)
{
CloseAllTrades(symbol, AllTrades);
if (ForceTradeClosure)
{
return(false);
}//if (ForceTradeClosure)
}//if (ForceTradeClosure)
}//if (ForceTradeClosure)
if (!ForceTradeClosure)
return(true);//Closure target reached and closure successful
}//if (CashUpl[PairIndex] >= IndividualBasketTargetCash)
}//if (!CloseEnough(IndividualBasketTargetCash,0) )
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
-
4xtn
- Trader
- Posts: 26
- Joined: Mon Aug 27, 2012 10:32 pm
- Location: Dublin, Ireland
Slopey Peaky Bob
Hi there
Anyone else is having pending orders cancelled and sent over & over again with 'DeletePendingsOnOppositeColour=true? AUDCHF pair @ H1 Peaky|D1 SS?
Anyone else is having pending orders cancelled and sent over & over again with 'DeletePendingsOnOppositeColour=true? AUDCHF pair @ H1 Peaky|D1 SS?
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Slopey Peaky Bob
I cannot find this variable.4xtn » Mon May 21, 2018 10:31 pm wrote:Hi there
Anyone else is having pending orders cancelled and sent over & over again with 'DeletePendingsOnOppositeColour=true? AUDCHF pair @ H1 Peaky|D1 SS?
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
-
Peepaws
- Trader
- Posts: 121
- Joined: Thu Nov 27, 2014 11:19 pm
Slopey Peaky Bob
The c. $130 DD disappeared within a hour or so when the markets finally moved back in the right direction. I have noticed that a basket closes rapidly when this happens - it can go from DD to TP within minutes. I am wondering if I am leaving too much on the table with my TP - is anyone here demoing a much higher one?
Looking good.
![]()
Steve, I have been trading a live account with a 500 pip basket TP for a month or so with very good results so far.
I have split my account into 3 smaller accounts to test 100 pip, 200 pip and 500 pip baskets. I am just waiting for Myfxbook to verify the new accounts before I can make them public.
I will post myfxbook links as soon as possible.
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Slopey Peaky Bob
V 1k is in post 1. Radar emailed to say that the dynamic whole-position basket TP was not updating. I saw loads wrong with the code when I looked, so 1k is attempting to fix this. You do not need the update if you are not basket trading.
The DIY is relatively simple. Do a search for "void CalculateDynamicBasketCashTP()" and replace it with:
void CalculateDynamicBasketCashTP(double lots)
Doing a recompile will highlight a lot of errors; ignore them for now.
Go to the top of the file and do a 'Match whole word only' for "UseDynamicCashTP". The first one will take you to the variable declaration; leave that alone.
Repeat the search. It will take you to a code block in int OnInit(). Replace the block with this:
Repeat the search twice more, ignoring the code each time.
Repeat the search a third time and you will find yourself in void Autotrading(). Replace the code block with the one you just copied into int OnInit().
Press the F7 key to recompile. There will be two wrong parameters count errors. Double click the first one to be taken to the first error. The code is " CalculateDynamicBasketCashTP();". Replace it with:
CalculateDynamicBasketCashTP(LotSize);
Re-compile and there will be one error left. Navigate to it and replace "CalculateDynamicBasketCashTP();" with:
CalculateDynamicBasketCashTP(Lot);

The DIY is relatively simple. Do a search for "void CalculateDynamicBasketCashTP()" and replace it with:
void CalculateDynamicBasketCashTP(double lots)
Doing a recompile will highlight a lot of errors; ignore them for now.
Go to the top of the file and do a 'Match whole word only' for "UseDynamicCashTP". The first one will take you to the variable declaration; leave that alone.
Repeat the search. It will take you to a code block in int OnInit(). Replace the block with this:
Code: Select all
//Calculate a dynamic whole basket TP for initial display
if (UseDynamicCashTP)
{
//Applied to a fixed lot size
if (CloseEnough(LotsPerDollopOfCash, 0))
if (CloseEnough(RiskPercent, 0))
CalculateDynamicBasketCashTP(Lot);
//LotsPerDollop
if (!CloseEnough(LotsPerDollopOfCash, 0))
{
CalculateLotAsAmountPerCashDollops();
CalculateDynamicBasketCashTP(Lot);
}//if (!CloseEnough(LotsPerDollopOfCash, 0))
//RiskPercent
if (!CloseEnough(RiskPercent, 0))
{
//Simulate a trade to calculate the lot size for a RiskPercent-based trade.
double stop = 0, price = 0;
string symbol = TradePair[0];
price = MarketInfo(symbol, MODE_ASK);
stop = CalculateStopLoss(OP_BUY, price);
double SendLots = CalculateLotSize(symbol, price, stop);
CalculateDynamicBasketCashTP(SendLots);
}//if (!CloseEnough(RiskPercent, 0))
}//if (UseDynamicCashTP)
Repeat the search a third time and you will find yourself in void Autotrading(). Replace the code block with the one you just copied into int OnInit().
Press the F7 key to recompile. There will be two wrong parameters count errors. Double click the first one to be taken to the first error. The code is " CalculateDynamicBasketCashTP();". Replace it with:
CalculateDynamicBasketCashTP(LotSize);
Re-compile and there will be one error left. Navigate to it and replace "CalculateDynamicBasketCashTP();" with:
CalculateDynamicBasketCashTP(Lot);
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.