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

MPTM's new home
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=64
Page 9 of 57
Author:  kelisa [ Sat Jun 02, 2012 9:55 am ]
Post subject:  Re: MPTM's new home

Read every post on this thread. I ve been wanting to see if anyone post their tuned settings for EU or any other pairs, but I also understand that everyone's entry point for a trade is different and with different crims, the setting varies greatly. So, I conclude that, everyone, newbie or experience traders who want to use this EA, you just have to make use of whats available within this EA, which is more than sufficient. No need to request any other variations to be implemented.
Author:  SteveHopwood [ Sat Jun 02, 2012 10:03 am ]
Post subject:  Re: MPTM's new home

pgtips wrote:Dare I offer an alternative I have found (still to resolve 3 problems of 5 digit criminal, preserve lots and it only works on full lot size, not mini) but it does get around multiple instances of code running and using shared variable.

I wonder Steve if I might have permission to play around and maybe borrow some of your code. I have no idea where to start but I'll give it a go.

Code: Select all

//+--------------------------------------------------------+
//|                  e-Smart_Tralling                      |
//+--------------------------------------------------------+

extern   bool     UseOneAccount = true;
extern   bool     UseCloseOneThird = true;
extern   int      LevelProfit1 = 30;
extern   int      LevelMoving1 = 10;
extern   int      LevelProfit2 = 15;
extern   int      LevelMoving2 = 10;
extern   int      LevelProfit3 = 25;
extern   int      LevelMoving3 = 15;
extern   int      TrailingStop = 30;
extern   int      TrailingStep = 5;
extern   int      Slippage = 2;
extern   bool     ShowComment = true;
extern   bool     UseSound = true;
string   var_132 = "expert.wav";

//+------------------------------------------------------------------+

void deinit()
{
Comment("");
}

//+------------------------------------------------------------------+

void start()
{
double point;
int    digits;
string msg = "";

for (int i = 0; i < OrdersTotal(); i++)
   {
   if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      {
      if (UseOneAccount || (OrderSymbol() == Symbol()))
         {
         ThreeLevelSystemOfOutput();
         digits = MarketInfo(OrderSymbol(),MODE_DIGITS);
         point = MarketInfo(OrderSymbol(),MODE_POINT);
         msg = msg + OrderSymbol() + "  Öåíà: " + DoubleToStr(OrderOpenPrice(),digits) + "  SL = " + DoubleToStr(OrderStopLoss(),digits) + " (" + StopLossInPoint() + ")\n";
         }
      }
   }

if (ShowComment) Comment(msg);
}

//+------------------------------------------------------------------+

void ThreeLevelSystemOfOutput()
{
int profit = ProfitPosition();
int sl = StopLossInPoint();
int spread = MarketInfo(OrderSymbol(),MODE_SPREAD);

if ((profit > LevelProfit1) && (profit <= LevelProfit2) && (sl < LevelMoving1))
   {
   ModifyStopLossInPoint(LevelMoving1);
   if (UseCloseOneThird) CloseOneThird();
   }
if ((profit > LevelProfit2) && (profit <= LevelProfit3) && (sl < LevelMoving2)) ModifyStopLossInPoint(LevelMoving2);
if ((profit > LevelProfit3) && (sl < LevelMoving3)) ModifyStopLossInPoint(LevelMoving3);
if (profit > LevelMoving3 + TrailingStop + TrailingStep) TrailingPositions();
}

//+------------------------------------------------------------------+

void CloseOneThird()
{
bool   result = false;
double lots = MathCeil(OrderLots() / 3.0 * 10.0) / 10.0;

if (lots > 0.0)
   {
   if (OrderType() == OP_BUY)
      {
      result = OrderClose(OrderTicket(),lots,Bid,Slippage,CLR_NONE);
      }
   if (OrderType() == OP_SELL)
      {
      result = OrderClose(OrderTicket(),lots,Ask,Slippage,CLR_NONE);
      }
   if (result && UseSound) PlaySound(var_132);
   }
}

//+------------------------------------------------------------------+

void TrailingPositions()
{
double bid;
double ask;
double point = MarketInfo(OrderSymbol(),MODE_POINT);

if (OrderType() == OP_BUY)
   {
   bid = MarketInfo(OrderSymbol(),MODE_BID);
   if (bid - OrderOpenPrice() > TrailingStop * point)
      {
      if (OrderStopLoss() < bid - (TrailingStop + TrailingStep - 1) * point)
         {
         ModifyStopLoss(bid - TrailingStop * point);
         return;
         }
      }
   }

if (OrderType() == OP_SELL)
   {
   ask = MarketInfo(OrderSymbol(),MODE_ASK);
   if (OrderOpenPrice() - ask > TrailingStop * point)
      {
      if ((OrderStopLoss() > ask + (TrailingStop + TrailingStep - 1) * point) || (OrderStopLoss() == 0))
         {
         ModifyStopLoss(ask + TrailingStop * point);
         }
      }
   }
}

//+------------------------------------------------------------------+

void ModifyStopLoss(double sl)
{
bool result = OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0,CLR_NONE);
if (result && UseSound) PlaySound(var_132);
}

//+------------------------------------------------------------------+

void ModifyStopLossInPoint(int stoploss)
{
bool   result;
double sl = 0;
double point = MarketInfo(OrderSymbol(),MODE_POINT);

if (OrderType() == OP_BUY) sl = OrderOpenPrice() + stoploss * point;
if (OrderType() == OP_SELL) sl = OrderOpenPrice() - stoploss * point;

result = OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0,CLR_NONE);
if (result && UseSound) PlaySound(var_132);
}

//+------------------------------------------------------------------+

int ProfitPosition()
{
double bid;
double ask;
double point = MarketInfo(OrderSymbol(),MODE_POINT);
double profit = 0;

if (OrderType() == OP_BUY)
   {
   bid = MarketInfo(OrderSymbol(),MODE_BID);
   profit = (bid - OrderOpenPrice()) / point;
   }
if (OrderType() == OP_SELL)
   {
   ask = MarketInfo(OrderSymbol(),MODE_ASK);
   profit = (OrderOpenPrice() - ask) / point;
   }
return(MathRound(profit));
}

//+------------------------------------------------------------------+

int StopLossInPoint()
{
double point = MarketInfo(OrderSymbol(),MODE_POINT);
double sl = 0;

if (OrderType() == OP_BUY) sl = (OrderStopLoss() - OrderOpenPrice()) / point;
if (OrderType() == OP_SELL) sl = (OrderOpenPrice() - OrderStopLoss()) / point;
if (OrderStopLoss() == 0.0) sl = -OrderOpenPrice() / point;
return(MathRound(sl));
}
Kevin
My code is open-source and free for everyone to adapt to their own uses. In fact, my work is usually a composite that includes contributions by others, and mptm is no exception.

Have fun.

:D
Author:  GilR [ Mon Jun 11, 2012 1:08 am ]
Post subject:  Re: MPTM's new home

Hi

I must be doing something wrong --- The read out of left top just blinks

What setting would I use for

SL=8pips
TP=6pips
Trailing stop 8pips

So if price moves in my favor 5pips my stop has moved to -3 pips

Thanks

Gil
Author:  Jagg [ Mon Jun 11, 2012 10:21 am ]
Post subject:  Re: MPTM's new home

Also wondering if it's possible to that with MPTM:

- order two pips of symbol xy
- both should get a stop loss of e.g. 60 pips
- BE should be set to 60 (+5 pips)
- when +60 is reached half the position should be exited and the rest stay in as a "runner" with jumping stop loss active.

possible?!

(and also a question of using mptm with non forex pairs like FDAX. It has 0.5 as tick value. Is this a problem?)
Author:  daveM [ Tue Jun 12, 2012 4:19 am ]
Post subject:  Re: MPTM's new home

I am using MPTM on a small basket and it is doing a wonderful job (according to me......).

Jumping Stop is a heading that I have not seen info on.

Would someone point me to some documentation on that feature please..

Thanks for your help.

daveM
Author:  garyfritz [ Mon Jun 18, 2012 5:03 am ]
Post subject:  Re: MPTM's new home

See p. 3 of the manual.
Author:  getting [ Mon Jun 18, 2012 10:57 pm ]
Post subject:  Re: MPTM's new home

someone please show me how to modified MPTM to Hedge different pair, rather than hedging the same pair. :idea:
Author:  SteveHopwood [ Mon Jun 18, 2012 11:08 pm ]
Post subject:  Re: MPTM's new home

getting wrote:someone please show me how to modified MPTM to Hedge different pair, rather than hedging the same pair. :idea:
Good luck if you try to get into that, my friend. Your best bet is to look at the conditions that will trigger a same-pair hedge, then replace the pair with the pair you want to use as a hedge.

Yurk, is all I can say about looking into that, but if you bugger up the code you can always re-download and start again.

I hope you manage what you want to achieve.

:D
Author:  tonycashflow [ Tue Jun 19, 2012 12:56 am ]
Post subject:  Re: MPTM's new home

Hi everyone,

I was wondering if it was possible to add the TradeExpiry setting like in the Basket section, but for individual trades.

Thanks ;)
Author:  SteveHopwood [ Wed Jun 27, 2012 6:13 pm ]
Post subject:  Re: MPTM's new home

Latest update in post 1.

From post 1:
All our thanks go to Lifesys - Paul. Paul has adapted all the previous pips/point stuff that emerged a couple of weeks ago. He has also adapted the part-close code to simply close Close_LotsFract percent of a trade at each closure point, so no need any more to specify Close_Lots and Preserve_Lots. Thanks Paul. You are a star.


:D
All times are UTC Page 9 of 57