Alpenkorp's Grid Scalping EA

User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Alpenkorp's Grid Scalping EA

Post by SteveHopwood »

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 tells you there is, is either a liar or an idiot. This EA will need manual intervention when NoOfTrades buys and sells are open, and the only recourse from there is to manage the basket manually.
    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.
      - Moving averages.
      - Martingale, and you really do have to understand the implications of this particular piece of spectacular lunacy.
DO NOT TRADE THIS EA ON A LIVE ACCOUNT. IT IS EXPERIMENTAL. IT IS PROBABLY LETHAL

Ehup all

Intro
Alpenkorps sent me a pm recently, outlining a scalping system. The idea is to aim for a small cash profit target.
  • - define the trend using Slowkey's 2 moving averages. If the fast ma is > the slow ma, trend is up. If below, trend is down. I use 100/200.
    - reinforce this with an optional D1 Rsi. When I use this, I use the D1 20 period: Rsi > 55, trend is up; Rsi < 45, trend is down; in between, market is ranging.
    - in an uptrend, the first trade in the grid triggers at the start of a new candle, when the previous candle's low was below the fast ma and closed above.
    - in a downtrend, the first trade in the grid triggers at the start of a new candle, when the previous candle's high was above the fast ma and closed below.
If the market cooperates (yeah, right, cos that happens every day :lol: ) the trade hits its nearby cash tp. If not, things get a little complicated. Take an initial buy trade as an example:
  • - trade is triggered. The trigger candle's low becomes the point at which an opposite direction sell trade will be sent; call this NextTradePrice.
    - the market heads south. When a bear candle closes below NextTradePrice.
    • - the bot sends a sell trade.
      - lot size is the initial trade's lot size x LotMultiplier. Buy trade lot = 0.01, so this trade's lot is 0.02, using the default LotMultiplier.
      - the high of the trigger candle becomes NextTradePrice
    - from here, if the market continues to head south, the profit target is reached quickly.
    - if, instead, the market heads north again, and a bull candle closes above NextTradePrice:
    • - send a second buy trade. Lot size is the previous sell trade's lot x LotMultiplier, i.e. 0.04
      - NextTradePrice becomes the low of the trigger candle
So it continues. Alpencorps doesn't know it yet, but he will be along later with some pictures to explain thingies a little more clearly. There are never consecutive buys or sells, only ever a ziogzag of buy/sell/buy/sell etc, until your tiny profit target is hit.

Or your account is blown. There is a high probability of this. For those of you who have not met it before, Martingale is simple. Every time a trade fails, double the lot size of the next one. Eventually, a trade closes at your take profit level and you recoup all the losses on previous trades. However:
  • - Eventually can be a long way off.
    - do a bit of mental arithmetic. Start with 0.01 lots and work out how many levels you have to go through to get to the kind of scary lot size you would not trade even in your wildest dreams. Then contemplate this: the next trade is at double the scary level.
So, only a cretin with a financial death wish uses Martingale even in his/her most terrifying nightmares. The rest of us do not even bother with the nightmare.

Profit target
The one redeeming feature in all this is the tiny cash profit target to aim for. The input for this is CashProfitTarget (gosh, you would never have guessed, would you?). I suggest setting this for whatever would be the equivalent of about 10 pips. I coded this on an Cowboy IBFX Aussie mini account, where 1 pip = stuff all, so a profit target of $0.10 makes sense. An Alpari pip is 10 times greater, so a profit target of $1 would be its equivalent. Work it out for yourselves and don't post asking how to do so, or I will shout at you.

This target looks ludicrous once Martingale is a few levels deep, but a pip movement on a lot size of, say, 1.28 lots is a lot more than on the original 0.01 trade, so the actual profit is much more once the profit target is reached. Great fun on demo, but not a bundle of laughs live, I suspect. :lol:

Attachments
  • - slowkey 2MA template to save the bone-idle having to set up their own ma's. Make sure your EA inputs match those of the template - by default they do.
    - mtf Rsi so you can have it on your chart should you decide to. Goes in your indicator folder but is not needed by the EA.
    - the EA.
b]In conclusion[/b]
I am going to pop this on demo, using the default inputs apart from enabling Rsi, so I can put the EA on an M15 chart.

The timeframe possibilities are endless. So are the lot size combinations. It might be better, for example, to start with a larger lot size but a smaller multiplier. Have a play and see.

There are other features I can add, should this turn out not to be an instant total disaster - we shall have to see. Just off the top of my head, we can have:
  • - maximum lot size feature to stop the account being blown. I leave you to work out for yourselves the implications this has for a system that only aims for a tiny profit in the first place.
    - a 'trade only one pair at a time' feature, so we can run the bot on lots of charts without ending up with lots of pairs.
Have fun, if you can.

:D

Matters of general interest

Read this post:
http://www.forexfactory.com/showthread. ... ost4923611 Newbie traders, read this for inspiration and warning. Those of you who have suffered losses, read it for inspiration. There is a thread devoted to Sam's trading method at http://www.forexfactory.com/showthre...25#post5118825

Masterly summary of hedging: http://www.forexfactory.com/showthread. ... ost4977179

EA coding
I receive may requests to code EA's. Traders, if I code your EA for free, then I will share it here. If you want me to code your EA without sharing, then my fee is $100 payable into my paypal account. I explain why at http://www.stevehopwoodforex.com/phpBB3 ... p=803#p803, at the bottom of the post.

Useful utilities/EA's/scripts
Matt's chart-population script at http://www.stevehopwoodforex.com/phpBB3 ... 5733#p5733. Use this every time you start a fresh platform.
MaryJane has posted a fabulous utility to allow us to resize EA input windows: http://www.forexfactory.com/showthread.php?t=299017
Multi purpose trade manager: http://www.forexfactory.com/showthread.php?t=89371
Account equity analyser: http://www.forexfactory.com/showthread. ... ost4693716 Also at http://www.forexfactory.com/showthread. ... ost4709098, which includes a template for both USD and the Euro.
Past-trades display indi by squalou; shows a graphical display of the success/failure of trades in your History tab. Breathtaking piece of work. http://www.forexfactory.com/showthread. ... ost3830610
My shell EA – the code I use to produce EA's so quickly. http://www.stevehopwoodforex.com/phpBB3 ... p?f=5&t=15
You do not have the required permissions to view the files attached to this post.
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.
Sissia
Posts: 1
Joined: Thu Apr 12, 2012 3:20 pm

Re: Alpenkorp's Grid Scalping EA

Post by Sissia »

I will give it a try...

let see
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Re: Alpenkorp's Grid Scalping EA

Post by SteveHopwood »

Update in post 1 (V 1f). As soon as I turned on Rsi some holes in my logic emerged that I had not noticed in code-testing backtesting.

Coders, replace hte void FirstTradeOpportunity() function with this:

Code: Select all

void FirstTradeOpportunity()
{

   //Looks for an initial trading opp. The trend has already been determined.
   
   if (SendLong)
   {
      //Previous candle must have crossed and closed above the fast moving average
      if (Low[1] >= FastTrendMaVal)  {SendLong = false; return;}
      if (Close[1] <= FastTrendMaVal)  {SendLong = false; return;}
      if (UseRsiTrendDetection && RsiTrend != up)  {SendLong = false; return;}
      if (SlowkeyTrend != up)  {SendLong = false; return;}
      
      //Buy trades must follow a rising candle
      if (!IsBull()) {SendLong = false; return;}
   }//if (SendLong)
      
   if (SendShort)
   {
      //Previous candle must have crossed and closed below the fast moving average
      if (High[1] <= FastTrendMaVal)  {SendShort = false; return;}
      if (Close[1] >= FastTrendMaVal)  {SendShort = false; return;}
      if (UseRsiTrendDetection && RsiTrend != down)  {SendShort = false; return;}
      if (SlowkeyTrend != down)  {SendShort = false; return;}

      //Sell trades must follow a falling candle
      if (!IsBear()) {SendShort = false; return;}
   }//if (SendShort)
   
}//void FirstTradeOpportunity()
These 4 lines of code are the additions:
if (UseRsiTrendDetection && RsiTrend != down) {SendShort = false; return;}
if (SlowkeyTrend != down) {SendShort = false; return;}
if (UseRsiTrendDetection && RsiTrend != down) {SendShort = false; return;}
if (SlowkeyTrend != down) {SendShort = false; return;}

:D
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.
User avatar
ovisun
Trader
Posts: 63
Joined: Sun Mar 18, 2012 11:54 am
Location: Romania, Constanta

Re: Alpenkorp's Grid Scalping EA

Post by ovisun »

Hello,
Maybe would be better if the profit is in pips, not in cash. In back test I had same profit even after a string of 6-7 trades. Or as a percentage of balance/equity...
Image
eddysukses
Posts: 5
Joined: Fri Apr 20, 2012 12:30 pm

Re: Alpenkorp's Grid Scalping EA

Post by eddysukses »

will try it, thanks Steve
User avatar
Alpenkorps
Trader
Posts: 213
Joined: Thu Dec 15, 2011 4:03 am

Re: Alpenkorp's Grid Scalping EA

Post by Alpenkorps »

Thanks a lot Steve for coding this, I am amazed to see your level of patience.

I am sorry for being late to join, I got caught with some family thingy. I am still backtesting and comparing the results, once I am done, I'll post them one by one.

The original idea is to scalp, but what do I know!! The bot works fine at 4H and daily too !!
Take my love, take my land, Take me where I cannot stand
I don't care, I'm still free, You can't take the sky from me
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Re: Alpenkorp's Grid Scalping EA

Post by SteveHopwood »

Alpenkorps wrote:Thanks a lot Steve for coding this, I am amazed to see your level of patience.

I am sorry for being late to join, I got caught with some family thingy. I am still backtesting and comparing the results, once I am done, I'll post them one by one.

The original idea is to scalp, but what do I know!! The bot works fine at 4H and daily too !!
That is the great thing about an EA; it gives us scope to try out ideas quickly and easily.

:D
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.
User avatar
bernard
Trader
Posts: 99
Joined: Tue Jan 10, 2012 1:10 pm
Location: Moers - Germany

Re: Alpenkorp's Grid Scalping EA

Post by bernard »

Hi Steve,

The "coders" should replace the void FirstTradeOpportunity() function.
What should the "non-coders" do? :o

I managed to replace the function, but have no clue about the 4 lines that are to be added.

Best,
Bernard

SteveHopwood wrote:Update in post 1 (V 1f). As soon as I turned on Rsi some holes in my logic emerged that I had not noticed in code-testing backtesting.

Coders, replace hte void FirstTradeOpportunity() function with this:

Code: Select all

void FirstTradeOpportunity()
{

   //Looks for an initial trading opp. The trend has already been determined.
   
   if (SendLong)
   {
      //Previous candle must have crossed and closed above the fast moving average
      if (Low[1] >= FastTrendMaVal)  {SendLong = false; return;}
      if (Close[1] <= FastTrendMaVal)  {SendLong = false; return;}
      if (UseRsiTrendDetection && RsiTrend != up)  {SendLong = false; return;}
      if (SlowkeyTrend != up)  {SendLong = false; return;}
      
      //Buy trades must follow a rising candle
      if (!IsBull()) {SendLong = false; return;}
   }//if (SendLong)
      
   if (SendShort)
   {
      //Previous candle must have crossed and closed below the fast moving average
      if (High[1] <= FastTrendMaVal)  {SendShort = false; return;}
      if (Close[1] >= FastTrendMaVal)  {SendShort = false; return;}
      if (UseRsiTrendDetection && RsiTrend != down)  {SendShort = false; return;}
      if (SlowkeyTrend != down)  {SendShort = false; return;}

      //Sell trades must follow a falling candle
      if (!IsBear()) {SendShort = false; return;}
   }//if (SendShort)
   
}//void FirstTradeOpportunity()
These 4 lines of code are the additions:
if (UseRsiTrendDetection && RsiTrend != down) {SendShort = false; return;}
if (SlowkeyTrend != down) {SendShort = false; return;}
if (UseRsiTrendDetection && RsiTrend != down) {SendShort = false; return;}
if (SlowkeyTrend != down) {SendShort = false; return;}

:D
1- Give me 10 pips a day and I build an Empire. 2- Have never seen any individual to get rich throu Forex. 3- Conclusion?
User avatar
Dixpat
Trader
Posts: 33
Joined: Tue Nov 15, 2011 9:32 pm
Location: Auckland. NZ

Re: Alpenkorp's Grid Scalping EA

Post by Dixpat »

If you have replaced the function then that is all you need to do

Steve has just listed the lines that were added within the function
kelisa
Trader
Posts: 188
Joined: Sun Mar 04, 2012 6:51 am

Re: Alpenkorp's Grid Scalping EA

Post by kelisa »

The logic of this EA does make good sense.

How about the idea of allowing this EA to scan thru all available pairs and filter orders by MAX Spread settings?

I hope Steve or other expert programmers can look into this idea. ;)

regards,
kelisa
If your strategy is working well, dont be GREEDY and change it!
Post Reply

Return to “Automated trading systems”