MPTM updated

MPTM's new home
Post Reply
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.

MPTM updated

Post by SteveHopwood »

I have re-written MPTM.

I have dumped the irrelevant functions and basket trading functions. Basket functions are dealt with elsewhere far better than MPTM ever did - details in the user guide.

This version's code is much clearer and so will be easier to add to. Coders, the notes pdf explains how.

Don't rush to put this on live accounts until you have tested test the features you want on demo first. There should not be bugs but you never know......................

I will consider requests for additional functionality they I think it might be useful to other members.

:xm: :rocket:
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.
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.

MPTM updated

Post by SteveHopwood »

My re-write is complete and this thread is open for business. Details in post 1, the user guide and the notes for coders.

:xm:
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.
mntiwana
Trader
Posts: 17
Joined: Fri Aug 16, 2013 11:57 am

MPTM updated

Post by mntiwana »

Thanks Steve - for your continues updating/upgrading MPTM,it is so fine,especially descriptions inside code so that a person like me with zero coding knowledge can easily understand and learn things :)
attaching your latest "hgi_lib" that is updated till (HGI.expires Aprile 1st, 2018) just for to save users time finding it
from here
http://www.stevehopwoodforex.com/phpBB3 ... 64#p105044
regards
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.

MPTM updated

Post by SteveHopwood »

mntiwana » Sun Dec 31, 2017 6:57 pm wrote:Thanks Steve - for your continues updating/upgrading MPTM,it is so fine,especially descriptions inside code so that a person like me with zero coding knowledge can easily understand and learn things :)
attaching your latest "hgi_lib" that is updated till (HGI.expires Aprile 1st, 2018) just for to save users time finding it
from here
http://www.stevehopwoodforex.com/phpBB3 ... 64#p105044
regards
Thanks for trying to help.

I have deleted the library file from your post. Members have to get used to downloading it from Bob's thread because it is a date-limited file and there is only one place to find the latest working version.

:xm:
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.
mntiwana
Trader
Posts: 17
Joined: Fri Aug 16, 2013 11:57 am

MPTM updated

Post by mntiwana »

SteveHopwood » Mon Jan 01, 2018 3:17 am wrote: Thanks for trying to help.

I have deleted the library file from your post. Members have to get used to downloading it from Bob's thread because it is a date-limited file and there is only one place to find the latest working version.

:xm:
Thanks you too and happy new year 2018 - :)
Of course,you knows better how to handle forum matters
forexsiuk
Posts: 8
Joined: Fri Nov 04, 2016 4:47 pm

MPTM updated

Post by forexsiuk »

Would anybody be kind enough to check out if the part close function is working on their MPTM updated version please? No matter what I try it will not work here. I have used the old versions for a long while and they has always worked perfectly, so although I am as talented as a chimp wearing boxing gloves at coding I do know my way around the settings.
Thanks for any assistance on this one.
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.

MPTM updated

Post by SteveHopwood »

forexsiuk » Wed Jan 03, 2018 9:00 am wrote:Would anybody be kind enough to check out if the part close function is working on their MPTM updated version please? No matter what I try it will not work here. I have used the old versions for a long while and they has always worked perfectly, so although I am as talented as a chimp wearing boxing gloves at coding I do know my way around the settings.
Thanks for any assistance on this one.
The code is the same - a direct copy from the old version apart from my leaving out the error-trapping code. No idea why I did not include that.

Try the updated version with the error trapping code in post 1 or copy this over the top of the existing function:

Code: Select all

bool PartCloseOrderFunction()
{
   // Called when any attempt to part-close a long trade is needed.
   // Trade has already been selected 
   // Returns 'true' if succeeds, else false.
   
   
         
   bool result = CloseOrder(OrderTicket(), __FUNCTION__,  Close_Lots, pcm );
   
   if (result)
   {
      if (ShowAlerts==true) Alert("Partial close of ", OrderSymbol(), " ticket no ", OrderTicket());
      return(true);
   }//if (result)
   else
   {
      int err=GetLastError();
      if (ShowAlerts==true) Alert("Partial close of ", OrderSymbol(), " ticket no ", OrderTicket()," failed with error (",err,") :  ",ErrorDescription(err));
      Print("Partial close of ", OrderSymbol(), " ticket no ", OrderTicket()," failed with error (",err,") :  ",ErrorDescription(err));
      return(false);
   }//else                         
   
}// End bool PartCloseOrderFunction()
This will tell us if there is a fault in the code.

:xm:
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.
forexsiuk
Posts: 8
Joined: Fri Nov 04, 2016 4:47 pm

MPTM updated

Post by forexsiuk »

A trial with updated version on a demo account shows part-close is still not working. The BE and other functions work perfectly. No error messages are being generated.
Thank you for looking into this.
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.

MPTM updated

Post by SteveHopwood »

forexsiuk » Wed Jan 03, 2018 11:26 am wrote:A trial with updated version on a demo account shows part-close is still not working. The BE and other functions work perfectly. No error messages are being generated.
Thank you for looking into this.
That told me the part-close function function was not being called. It turns out I had forgotten to add the call to the break even code. Fixed in post 1, or copy this over the top of the existing void BreakEvenStopLoss(int ticket):

Code: Select all

void BreakEvenStopLoss(int ticket) 
{

   // Move stop loss to breakeven
   
   if (!BetterOrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
      return;//Order has closed, so nothing to do.    

   //No need to continue if already at BE
   if (OrderType() == OP_BUY)
      if (OrderStopLoss() >= OrderOpenPrice() )
         return;
         
   if (OrderType() == OP_SELL)
      if (!CloseEnough(OrderStopLoss(), 0) )//Sell stops need this extra conditional to cater for no stop loss trades
         if (OrderStopLoss() <= OrderOpenPrice() )
            return;
             

   int err = 0;
   bool modify = false;
   double stop = 0;
   
  //Can we move the stop loss to breakeven?        
   if (OrderType()==OP_BUY)
      if (OrderStopLoss() < OrderOpenPrice() )
         if (bid >= OrderOpenPrice() + (BreakEven / factor) )
            if (OrderStopLoss() < OrderOpenPrice() )
            {
               modify = true;
               stop = NormalizeDouble(OrderOpenPrice() + (BreakEvenProfit / factor), digits);
            }//if (OrderStopLoss()<OrderOpenPrice())
   	                  			         
          
   if (OrderType()==OP_SELL)
      if (OrderStopLoss() > OrderOpenPrice() || CloseEnough(OrderStopLoss(), 0) )
         if (bid <= OrderOpenPrice() - (BreakEven / factor) )
         {
            modify = true;
            stop = NormalizeDouble(OrderOpenPrice() - (BreakEvenProfit / factor), digits);
         }//if (OrderStopLoss()>OrderOpenPrice()) 
         
   //Modify the order stop loss if BE has been achieved
   if (modify)
   {
      bool result = ModifyOrder(OrderTicket(), OrderOpenPrice(), stop, OrderTakeProfit(), 
                                OrderExpiration(), clrNONE, __FUNCTION__, slm);
      if (result)
      {
         if (UsePartClose && OrderLots() > Preserve_Lots)//Call the partial close function if enabled
         {
            bool PartCloseSuccess = PartCloseOrderFunction();
            if (!PartCloseSuccess) 
               SetAGlobalTicketVariable();
         }//if (PartCloseEnabled && OrderLots() > Preserve_Lots)
      }//if (result)

      
   }//if (modify)
   

}//End void BreakEvenStopLoss(int ticket)
Can you confirm that this works now, please?

:xm:
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.
forexsiuk
Posts: 8
Joined: Fri Nov 04, 2016 4:47 pm

MPTM updated

Post by forexsiuk »

Tested and all working perfectly now!
Many thanks for your time and attention as always.
Post Reply

Return to “Utilities Indicators and Scripts”