Thank you Steve :hi:
Slopey Peaky Bob
- 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
Mauro spotted one of my copy-paste-forget to edit bloops in the shirt protection function is the Latest version. I have uploaded a fix to post 1.
DIY: do a search for, "//Close the entire position if we are in danger of a margin call." You will see this three lines down:
if (ml < DeletePendingsBelowThisMarginLevelPercent)
Change it to:
if (ml < CloseDeleteAllBelowThisMarginLevelPercent)

DIY: do a search for, "//Close the entire position if we are in danger of a margin call." You will see this three lines down:
if (ml < DeletePendingsBelowThisMarginLevelPercent)
Change it to:
if (ml < CloseDeleteAllBelowThisMarginLevelPercent)
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
Latest V 2a is in post 1, with a fix for the problem described in Mauro's pm to me this morning:
Easy DIY. Go to, "bool IsTradingAllowed(string symbol, int PairIndex)" and add this code block:
Thanks Mauro.

This probably applies to Desky as well, but I will look at that later.Hello Steve.
I found one of my demo running SPB latest version in an endless loop, opening and closing pendings.
Margin was below the threshold so ShirtProtection kicked in but I think LookForTradingOpportunities that gets called right after creates the pendings again.
Easy DIY. Go to, "bool IsTradingAllowed(string symbol, int PairIndex)" and add this code block:
Code: Select all
//Margin level
if (!CloseEnough(AccountMargin(), 0) )
{
double ml = NormalizeDouble(AccountEquity() / AccountMargin() * 100, 2);
if (ml < DeletePendingsBelowThisMarginLevelPercent || ml < CloseDeleteAllBelowThisMarginLevelPercent)
return(false);
}//if (!CloseEnough(AccountMargin(), 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.
- 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
SPB Latest V 2c is in post 1.
I have added a new feature to grid trading. This is the option to use the order open price of the next trade in the grid as the take profit of the one being sent to the server. The input is UseNextLevelForTP.
This is a simple DIY. Do a search for this variable, "extern double GridAtrDivisor". Insert this code underneath:
Go to void SendBuyGrid(string symbol,int type,double price,double lot,string comment). Scroll down the this line of code:
take = CalculateTakeProfit(OP_BUY, price);
Replace it with this block:
Go to void SendSellGrid(string symbol,int type,double price,double lot,string comment) - it is the next function in the file. Scroll down to this line of code:
take = CalculateTakeProfit(OP_SELL, price);
Replace it with this block:

I have added a new feature to grid trading. This is the option to use the order open price of the next trade in the grid as the take profit of the one being sent to the server. The input is UseNextLevelForTP.
This is a simple DIY. Do a search for this variable, "extern double GridAtrDivisor". Insert this code underneath:
Code: Select all
extern string gtp="-- Grid trades take profit --";
//This tells Desky to set the take profit for each trade at the open price of the next trade in the grid.
extern bool UseNextLevelForTP=false;
take = CalculateTakeProfit(OP_BUY, price);
Replace it with this block:
Code: Select all
if (!UseNextLevelForTP)
take = CalculateTakeProfit(OP_BUY, price);
if (UseNextLevelForTP)//Set the tp at the open price of the next trade
take = price;
take = CalculateTakeProfit(OP_SELL, price);
Replace it with this block:
Code: Select all
if (!UseNextLevelForTP)
take = CalculateTakeProfit(OP_SELL, price);
if (UseNextLevelForTP)//Set the tp at the open price of the next trade
take = price;
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.
-
billv
- Trader
- Posts: 283
- Joined: Fri Apr 13, 2012 1:57 pm
Slopey Peaky Bob
Many thanks Steve, will give it a test :hi:
-
billv
- Trader
- Posts: 283
- Joined: Fri Apr 13, 2012 1:57 pm
Slopey Peaky Bob
Hi Steve
Is this code only meant to place TP on the 1st grid of 5 orders?
Regards
Bill
Is this code only meant to place TP on the 1st grid of 5 orders?
Regards
Bill
- 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
Mauro spotted a logic bloop in the code that sets grid trades take profit at the open price of the next trade. Thanks again Mauro.
Fixed in post 1. A DIY is easy. Do a search for, "//Set the tp at the open price of the next trade". The next line of code is:
take = price;
This needs replacing with:
take = NormalizeDouble(price + (DistanceBetweenTrades/factor), digits);
Repeat the search and you will land in the function that sends sell grids. The next line of code will again be:
take = price;
This needs replacing with:
take = NormalizeDouble(price - (DistanceBetweenTrades/factor), digits);

Fixed in post 1. A DIY is easy. Do a search for, "//Set the tp at the open price of the next trade". The next line of code is:
take = price;
This needs replacing with:
take = NormalizeDouble(price + (DistanceBetweenTrades/factor), digits);
Repeat the search and you will land in the function that sends sell grids. The next line of code will again be:
take = price;
This needs replacing with:
take = NormalizeDouble(price - (DistanceBetweenTrades/factor), digits);
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.
-
barry
- Trader
- Posts: 81
- Joined: Thu Mar 01, 2012 5:12 am
Slopey Peaky Bob
billv, this looks like a nice idea, thanks for posting it. Do you have this account on FXTestify or anywhere else it can be followed? I would like to look at the results more closely, thanks.billv » Sun Feb 03, 2019 7:10 am wrote:The following example is from my $60K AUD account with settings: riskpercent=2 and stoploss =2000.SteveHopwood » Sun Feb 03, 2019 5:56 am wrote: There is one more input allowing the user to chose his/her own lot size but retains Thomas' simplicity. :
Currently the account does not have open EURGBP trades but if there were any, they would have been size 0.02.
This technique is not only helping me reduce my DD, but it also makes my money work harder because currency pairs which have low pip value can be traded at higher lot size.
I hope this helps someone
-
billv
- Trader
- Posts: 283
- Joined: Fri Apr 13, 2012 1:57 pm
Slopey Peaky Bob
Hi Barrybarry » Tue Feb 19, 2019 8:19 pm wrote:
billv, this looks like a nice idea, thanks for posting it. Do you have this account on FXTestify or anywhere else it can be followed? I would like to look at the results more closely, thanks.
I believe it is essential for this type of trading and we can thank Thomas for putting in this code.
I cannot participate with this account in fxtestify because it is live and I intervene manually (closing and adding new orders).
You can experiment with these settings and see what works for you.
Lot=0
LotsPerDollopOfCash=0
RiskPercent=2
SL=1400 ( try higher or lower SL and see what lot size you get)
As a general rule, I would let the pairs which have the highest pip value be traded at the minimum size (0.01) and I would let the others be traded at 0.02, 0.03 etc
I have now set some of my test accounts to 2% and 1400, and others to 2.5% and 1400
These settings work for my AUD account and they would be different for a different base currency but in my opinion we don't need surgical precision.
We only want to balance our trade size so that a 1 pip move would have approximately the same impact on any traded pair. This would help reduce our DD.
- 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 have written a do it yourself for beginners guide. http://www.stevehopwoodforex.com/phpBB3 ... 92#p166292

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.