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

MPTM updated
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5190
Page 7 of 13
Author:  SteveHopwood [ Fri Oct 16, 2020 2:59 pm ]
Post subject:  MPTM updated

stevenforex » Fri Oct 16, 2020 8:03 am wrote:
Hey Steve!

I just checked the code a bit and found that in the DoTradeManagement() the part-close Lot-Size calculation is done twice. Lines 1891 and 1915

One using the "CloseEnough()" and the other one without...

Could that be the problem?

If the compare of the two doubles gets different results for both parts :?

Cheers
You probably guessed that I forgot all about this.

The Close_Lots calculation is not needed twice but would make no difference as it will result in the same value. Delete the second calculation.

I will manage some trades next week and see if I can work out what is wrong.

:xm: :rocket:
Author:  K-Lander [ Mon Nov 16, 2020 2:48 pm ]
Post subject:  Minor bug on MPTM

Hi folks,
Just found a small bug on MPTM´s InsertTakeProfit function (line 1732). When calculating the TP, it does so from current price instead of the order´s open price. The needed changes are as follows:

Line # ..... Replace... ....... With...
1753........ ask............ OrderOpenPrice()
1762........ bid............ OrderOpenPrice()


Credit goes to laziness, as I couldn´t be bothered to manually placing the SL and TP to some pending orders, which led to finding the glitch.

I am not attaching the amended EA as it would not be an authentic, certified, made-in-Hopwoodshire version of the thing.

My very small $0.02.

Cheers,
Author:  SteveHopwood [ Mon Nov 16, 2020 4:19 pm ]
Post subject:  Minor bug on MPTM

K-Lander » Mon Nov 16, 2020 2:48 pm wrote:Hi folks,
Just found a small bug on MPTM´s InsertTakeProfit function (line 1732). When calculating the TP, it does so from current price instead of the order´s open price. The needed changes are as follows:

Line # ..... Replace... ....... With...
1753........ ask............ OrderOpenPrice()
1762........ bid............ OrderOpenPrice()


Credit goes to laziness, as I couldn´t be bothered to manually placing the SL and TP to some pending orders, which led to finding the glitch.

I am not attaching the amended EA as it would not be an authentic, certified, made-in-Hopwoodshire version of the thing.

My very small $0.02.

Cheers,
Not sure what you are looking at; the code is correct in my version and in the post 1 version. Are you sure yours is up to date?

:xm: :rocket:
Author:  K-Lander [ Mon Nov 16, 2020 4:27 pm ]
Post subject:  Minor bug on MPTM

SteveHopwood » Mon Nov 16, 2020 1:19 pm wrote:
K-Lander » Mon Nov 16, 2020 2:48 pm wrote:Hi folks,


Not sure what you are looking at; the code is correct in my version and in the post 1 version. Are you sure yours is up to date?

:xm: :rocket:
Seems I have an old version of MPTM and the bug seems to have been fixed in the updated one. My bad, sorry.

Have a nice weekend

K
Author:  Fourxxxx [ Tue Nov 24, 2020 1:54 am ]
Post subject:  MPTM updated

I seem to be missing something trying to get MPTM to close trades using HGI Blue Wavy lines.

I have the latest HGI Indicators and library files (fresh download) installed and HGI is displaying on the charts. MPTM will close trades if I set take profit in Pips but I would like it to close trades when the Blue Wavy lines are displayed. I have tried everything but I am running out of hair to pull out very fast.
MPTM 4H.tpl
Author:  SteveHopwood [ Tue Nov 24, 2020 1:51 pm ]
Post subject:  MPTM updated

Fourxxxx » Tue Nov 24, 2020 1:54 am wrote:I seem to be missing something trying to get MPTM to close trades using HGI Blue Wavy lines.

I have the latest HGI Indicators and library files (fresh download) installed and HGI is displaying on the charts. MPTM will close trades if I set take profit in Pips but I would like it to close trades when the Blue Wavy lines are displayed. I have tried everything but I am running out of hair to pull out very fast.
You will be sort of glad to know that the fault was in the coding, not in your attempts to use mptm. Fixed in 1c in post 1.

Coders and most DIYers will understand the bloop immediately. Go to the bool UsingHgiToCloseTrade(int ticket) function and scroll down to:
//The HGI library functionality was added by tomele. Many thanks Thomas.

These two lines need editing:
signal = getHGISignal(Symbol(), HgiTimeFrameC, shift);//This library function looks for arrows.
slope = getHGISlope (Symbol(), HgiTimeFrameC, shift);//This library function looks for wavy lines.

Change the highlighted words to these:
signal = getHGISignal(OrderSymbol(), HgiTimeFrameC, shift);//This library function looks for arrows.
slope = getHGISlope (OrderSymbol(), HgiTimeFrameC, shift);//This library function looks for wavy lines.

FYI folks, in looking for the fault I noticed how similar the hgi closure input names were to the hgi hedging input names, so I changed them. It should not affect the running of mptm if you leave yours as they are.


:xm: :rocket:
Author:  Fourxxxx [ Wed Nov 25, 2020 2:03 am ]
Post subject:  MPTM updated

Thank you :clap: :clap: :clap: :clap: still testing but seems to be closing trades as expected for Blue Wavy lines. The logic for the Yellow Wavy's does not seem right though. I have changed it to this and seems to be doing what I need.
if (slope == RANGEABOVE && HgiCloseOnYellowWavyC) and if (slope==RANGEBELOW && HgiCloseOnYellowWavyC)
R

Code: Select all

   if (OrderType() == OP_BUY)
   {
      if (signal==TRENDDN && HgiCloseOnLargeArrowsC)
      {
         //HgiStatus = hgidownarrowtradable;
         return(true);
      }
      else 
      if (slope==TRENDABOVE && HgiCloseOnBlueWavyC)
      {
         //HgiStatus = hgibluewavyshort;
         return(true);
      }
      else
      if (slope == RANGEABOVE && HgiCloseOnYellowWavyC)
      {
         //HgiStatus = hgiyellowrangewaveydown;
         return(true);
      }//if (slope == RANGEBELOW)      
   
   }//if (OrderType() == OP_BUY)

   if (OrderType() == OP_SELL)
   {
      if (signal==TRENDUP && HgiCloseOnLargeArrowsC)
      {
         //HgiStatus = hgiuparrowtradable;
         return(true);
      }
      else 
      if (slope==TRENDBELOW && HgiCloseOnBlueWavyC)
      {
         //HgiStatus = hgibluewavylong;
         return(true);
      }
      else 
      if (slope==RANGEBELOW && HgiCloseOnYellowWavyC)
      {
         //HgiStatus = hgiyellowrangewaveyup;
         return(true);
      }//if (slope==RANGEABOVE)
   
   }//if (OrderType() == OP_SELL)
if (slope == RANGEABOVE && HgiCloseOnYellowWavyC) and if (slope==RANGEBELOW && if (slope == RANGEABOVE && HgiCloseOnYellowWavyC) and if (slope==RANGEBELOW && HgiCloseOnYellowWavyC)giCloseOnYellowWavyC) were the other way around in Buy and Sell.
Author:  SteveHopwood [ Wed Nov 25, 2020 10:53 am ]
Post subject:  MPTM updated

:xm:
Fourxxxx » Wed Nov 25, 2020 2:03 am wrote:The logic for the Yellow Wavy's does not seem right though.
Thanks for a really helpful contribution. :clap: :clap: :clap: :clap: I have added the fix to 1c in post 1. Remember folks, if you are updating from post 1, to delete the existing .ex4 file to force recompilation when you restart the platform.

I have added a slightly different solution to Fourxxxx's, so the easiest DIY is to copy the entire function over the top of the existing one:

Code: Select all

bool UsingHgiToCloseTrade(int ticket)
{

   //Returns 'true' if HGI generates an opposite signal, else 'false'

   if (!BetterOrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
      return(false);
      
   
   int shift = 0;
   if (HgiOnlyConfirmedSignalsC)
      shift = 1;

   //No need to read the previous candle at every timer event
   static datetime OldBarTime = 0;
   if (!HgiOnlyConfirmedSignalsC)
      OldBarTime = 0;//Force a read at every timer event.
   if (OldBarTime == iTime(OrderSymbol(), HgiTimeFrameC, 0) )
      return(false);
   OldBarTime = iTime(OrderSymbol(), HgiTimeFrameC, 0);
      
   SIGNAL signal = 0;
   SLOPE  slope  = 0;

   //HgiStatus = hginosignal;
   
   //The HGI library functionality was added by tomele. Many thanks Thomas.
   signal = getHGISignal(OrderSymbol(), HgiTimeFrameC, shift);//This library function looks for arrows.
   slope  = getHGISlope (OrderSymbol(), HgiTimeFrameC, shift);//This library function looks for wavy lines.



   if (OrderType() == OP_BUY)
   {
      if (signal==TRENDDN && HgiCloseOnLargeArrowsC)
      {
         //HgiStatus = hgidownarrowtradable;
         return(true);
      }
      else 
      if (slope==TRENDABOVE && HgiCloseOnBlueWavyC)
      {
         //HgiStatus = hgibluewavyshort;
         return(true);
      }
      
   }//if (OrderType() == OP_BUY)

   if (OrderType() == OP_SELL)
   {
      if (signal==TRENDUP && HgiCloseOnLargeArrowsC)
      {
         //HgiStatus = hgiuparrowtradable;
         return(true);
      }
      else 
      if (slope==TRENDBELOW && HgiCloseOnBlueWavyC)
      {
         //HgiStatus = hgibluewavylong;
         return(true);
      }
     
   }//if (OrderType() == OP_SELL)
   
   //Yellow wavy closure
   if (HgiCloseOnYellowWavyC)
      if (slope==RANGEABOVE || slope == RANGEBELOW)
         return(true);
   
      

   //Got this far, so no signal
      return(false);
      
}//End bool UsingHgiToCloseTrade(int ticket
:xm: :rocket:
Author:  Fourxxxx [ Mon Dec 14, 2020 3:42 am ]
Post subject:  MPTM updated

Thank you for the fixes so far, is it possible to have the option to close all Pending Orders for the same pair when an indicator close is triggered, please?
Author:  SteveHopwood [ Mon Dec 14, 2020 7:39 pm ]
Post subject:  MPTM updated

Fourxxxx » Mon Dec 14, 2020 3:42 am wrote:Thank you for the fixes so far, is it possible to have the option to close all Pending Orders for the same pair when an indicator close is triggered, please?
You are talking about the likes of SS and HGI as included with MPTM?

:xm: :rocket:
All times are UTC Page 7 of 13