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

MPTM updated
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5190
Page 1 of 13
Author:  SteveHopwood [ Sun Jun 04, 2017 12:52 pm ]
Post subject:  MPTM updated

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:
Author:  SteveHopwood [ Sun Dec 31, 2017 3:10 pm ]
Post subject:  MPTM updated

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:
Author:  mntiwana [ Sun Dec 31, 2017 6:57 pm ]
Post subject:  MPTM updated

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
Author:  SteveHopwood [ Sun Dec 31, 2017 10:17 pm ]
Post subject:  MPTM updated

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:
Author:  mntiwana [ Sun Dec 31, 2017 10:26 pm ]
Post subject:  MPTM updated

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
Author:  forexsiuk [ Wed Jan 03, 2018 9:00 am ]
Post subject:  MPTM updated

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.
Author:  SteveHopwood [ Wed Jan 03, 2018 10:09 am ]
Post subject:  MPTM updated

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:
Author:  forexsiuk [ Wed Jan 03, 2018 11:26 am ]
Post subject:  MPTM updated

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.
Author:  SteveHopwood [ Wed Jan 03, 2018 11:49 am ]
Post subject:  MPTM updated

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:
Author:  forexsiuk [ Wed Jan 03, 2018 12:32 pm ]
Post subject:  MPTM updated

Tested and all working perfectly now!
Many thanks for your time and attention as always.
All times are UTC Page 1 of 13