stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Slopey Peaky Bob
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5389
Page 54 of 84
Author:  Dragonian [ Thu Feb 07, 2019 1:00 pm ]
Post subject:  Slopey Peaky Bob

SteveHopwood » 07 Feb 2019 10:29 wrote:
Done. Post 1 as usual.
Thank you Steve :hi:
Author:  SteveHopwood [ Sun Feb 10, 2019 4:37 pm ]
Post subject:  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)

:xm: :rocket:
Author:  SteveHopwood [ Thu Feb 14, 2019 10:17 am ]
Post subject:  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:
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.
This probably applies to Desky as well, but I will look at that later.

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) )
 
Thanks Mauro. :clap: :clap: :clap: :clap: :clap:

:xm: :rocket:
Author:  SteveHopwood [ Sat Feb 16, 2019 4:20 pm ]
Post subject:  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:

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;
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:

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;
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:

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;
:xm: :rocket:
Author:  billv [ Sat Feb 16, 2019 11:06 pm ]
Post subject:  Slopey Peaky Bob

Many thanks Steve, will give it a test :hi:
Author:  billv [ Mon Feb 18, 2019 7:52 am ]
Post subject:  Slopey Peaky Bob

Hi Steve

Is this code only meant to place TP on the 1st grid of 5 orders?

Regards
Bill
Author:  SteveHopwood [ Mon Feb 18, 2019 10:47 am ]
Post subject:  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. :clap: :clap: :clap: :clap: :clap:

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);

:xm: :rocket:
Author:  barry [ Tue Feb 19, 2019 9:19 am ]
Post subject:  Slopey Peaky Bob

billv » Sun Feb 03, 2019 7:10 am wrote:
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. :
The following example is from my $60K AUD account with settings: riskpercent=2 and stoploss =2000.
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, 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.
Author:  billv [ Tue Feb 19, 2019 10:33 am ]
Post subject:  Slopey Peaky Bob

barry » 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.
Hi Barry

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.
Author:  SteveHopwood [ Thu Feb 21, 2019 5:29 pm ]
Post subject:  Slopey Peaky Bob

I have written a do it yourself for beginners guide. http://www.stevehopwoodforex.com/phpBB3 ... 92#p166292

:xm: :rocket:
All times are UTC Page 54 of 84