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

Suggestions for a new module in EA Shell
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=444
Page 1 of 1
Author:  Gamma_gallus [ Wed Mar 21, 2012 2:43 pm ]
Post subject:  Suggestions for a new module in EA Shell

Hi everyone,

Would like to share with you below idea so that we can brainstorm together about optimizing it, if it makes sense to you.

The idea is to have a new module into the EA shell, to get automatically, based on the history :

- TP target(s)
- SL target(s)
- Trailing stop or JS

This module can either been used once a given EA has already generated a subsequent number of trades OR by looking at the chart history to look for trades that would have been triggered

Based on the history, the module tries to see what would have been the best values for above points (TP, SL, TS/JS). Then we will use those values for the coming trades to be opened.


I think technically speaking that could be feasible, since 2 indies have "part of the concept" :

- George's indi (DumpHistory with RunUp infos): http://www.stevehopwoodforex.com/phpBB3 ... 1760#p1760

- Squalou's sqDynamicBreakoutBox indi that calculates nbr of buys and sells that would have been trigerred, also the max number of pips that would have been pocketed, and an average of both values (see below snapshot)
sqDynamicBreakoutBox.JPG

Then to determine the best values we should go for, we could apply a kind of weighted average formula ??? I'm not that clear on this part, how best to get them ..

What I have no idea about, is how complex it would be to code the above into the future EAs, meaning : "check the entry signals and apply them to the history" (x days back)

Limitation about above reasonning : Is the history relevant enough to assess the coming trades ? (are the market conditions the same ? etc...)


What do you think ?

cheers
Olivier
Author:  SteveHopwood [ Sat Mar 31, 2012 11:15 pm ]
Post subject:  Re: Suggestions for a new module in EA Shell

I only just saw this, so sorry not to reply before.

I take it you mean my EA shell?

The shell contains the code that I customarily include in my ea's. By definition, your idea here is not customarily included and therefore has no part in my shell.

:D
Author:  Gamma_gallus [ Sat Mar 31, 2012 11:47 pm ]
Post subject:  Re: Suggestions for a new module in EA Shell

SteveHopwood wrote:I only just saw this, so sorry not to reply before.

:D
No worries :D

SteveHopwood wrote: I take it you mean my EA shell?

The shell contains the code that I customarily include in my ea's. By definition, your idea here is not customarily included and therefore has no part in my shell.

:D
You're right, I had this idea of a dynamic TP & SL, based on history, to include them into your EA shell. I have no coding logic, so I didn't know it can't be added to your shell.

But if that makes sense to you, and provided this is not too complex to code, we can perhaps keep it in mind for some future EAs (where TP & SL are fixed values) !?!?

cheers
Olivier
Author:  Ribelo [ Sun Apr 01, 2012 4:30 pm ]
Post subject:  Re: Suggestions for a new module in EA Shell

I tried to calculate the take profit based on the RUN UP, but it does not make sense. RUN UP is always smaller than the take-profit, so every time Take Profit is reduced, which leads inevitably to a situation where TP = 0

IMHO a much better and simpler solution is ...

If the previous transaction was a profit and ended up on TP, the next Take Profit = SL * RR * 1.1

If the previous transaction was profitable but did not end up on TP, the next Take Profit = SL * RR * 0.9

EDIT

After thinking the matter again, I wrote some other code.

Code: Select all

double stop.pip, take.profit.pip, calculated.rr;
   double factor = 1;
   int profit.count;
   stop.pip = MathAbs(NormalizeDouble(open.price - stop.price, Digits ) );
   if ( OrdersHistoryTotal() > 0 ) {
      if ( OrdersHistoryTotal() >= 5 ) {
         int count = 5;
      } else {
         count = OrdersHistoryTotal();
      }
      for ( int cc = OrdersHistoryTotal() - count; cc < OrdersHistoryTotal(); cc++ ) {
         if ( OrderSelect( cc, SELECT_BY_POS, MODE_HISTORY ) ) {
            if ( OrderType() == OP_BUY ) {
               if ( OrderProfit() > 0 ) {
                  if ( OrderClosePrice() + hidden.pips * Point >= OrderTakeProfit() ) {
                     profit.count++;
                  }
                  if ( OrderClosePrice() + hidden.pips * Point < OrderTakeProfit() ) {
                     profit.count--;
                  }
               }
            }
            if ( OrderType() == OP_SELL ) {
               if ( OrderProfit() > 0 ) {
                  if ( OrderClosePrice() - hidden.pips * Point <= OrderTakeProfit() ) {
                     profit.count++;
                  }
                  if ( OrderClosePrice() - hidden.pips * Point > OrderTakeProfit() ) {
                     profit.count--;
                  }
               }
            }
         }
      }
      if ( profit.count != 0 ) {
         if ( profit.count > 0 ) {
            factor = MathPow( 1.1, profit.count );
         }
         if ( profit.count < 0 ) {
            factor = MathPow( 0.9, -profit.count );
         }
      } 
   }
   Print("profit.count: ",profit.count);
   calculated.rr = total.risk.reward * factor;
   calculated.rr = MathMax( calculated.rr, min.rr );
   Print("calculated.rr ",calculated.rr);
   take.profit.pip = stop.pip * calculated.rr;
   Print("take.profit.pip ",take.profit.pip / Point);
   return( take.profit.pip );
All times are UTC Page 1 of 1