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

Bob and Shelley Again
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=2759
Page 14 of 120
Author:  SteveHopwood [ Thu Aug 08, 2013 12:45 pm ]
Post subject:  Re: Bob and Shelley Again

V 1j in post 1.I have changed the MA stacking filter in light of Andy's advice. There is an individual inputs section for MA stacking.

:D
Author:  MrLong [ Thu Aug 08, 2013 3:25 pm ]
Post subject:  Re: Bob and Shelley Again

SteveHopwood wrote:V 1j in post 1.I have changed the MA stacking filter in light of Andy's advice. There is an individual inputs section for MA stacking.

:D
Hi Steve,

I use the PRICE_CLOSE, the EA would have just missed the NZDUSD trade with PRICE_OPEN.

if (useMaStack && (!detectMaStack(CurrentPair, PERIOD_H4, 21, 55, 0, MODE_EMA, PRICE_CLOSE, OP_BUY, 0)))

Andy
Author:  SteveHopwood [ Thu Aug 08, 2013 3:57 pm ]
Post subject:  Re: Bob and Shelley Again

MrLong wrote:
SteveHopwood wrote:V 1j in post 1.I have changed the MA stacking filter in light of Andy's advice. There is an individual inputs section for MA stacking.

:D
Hi Steve,

I use the PRICE_CLOSE, the EA would have just missed the NZDUSD trade with PRICE_OPEN.

if (useMaStack && (!detectMaStack(CurrentPair, PERIOD_H4, 21, 55, 0, MODE_EMA, PRICE_CLOSE, OP_BUY, 0)))

Andy
Cheers Andy.

I have made the change folks and uploaded to post 1 - have not changed the version no.

Those of you who know how; find the two lines of code that begin:

Code: Select all

if (detectMaStack(Symbol(), PERIOD_H4, FastStackMaPeriod
and change PRiCE_OPEN to PRICE_CLOSE and recompile.

:D
Author:  fxdaytrader [ Fri Aug 09, 2013 1:24 am ]
Post subject:  Re: Bob and Shelley Again

MrLong wrote:
SteveHopwood wrote:Andy, why do you use the 21 EMA and 55 EMA for MA stack confirmation?
Fibonacci numbers, I've always used them, drop a 55 or 21 on a chart and most pairs respect them.
It is also that e.g. on

H4:
The EMA 55 value is ~equal to the ema 200 on H1
The EMA 21 value is ~equal to the ema 200 on M30

H1:
The EMA 55 value is ~equal to the ema 200 on M15
The EMA 21 value is ~equal to the ema 200 on M5

:)
Author:  fxdaytrader [ Fri Aug 09, 2013 3:16 am ]
Post subject:  Re: Bob and Shelley Again

Could be a bloop?

Code: Select all

         //MA stacking check. Thanks to Andy (Mr Long) for this code
         if (SendShort)
         {
            if (useMaStack && (!detectMaStack(Symbol(), PERIOD_H4, FastMaTdPeriod, SlowMaTdPeriod, 0, MODE_LWMA, PRICE_OPEN, OP_SELL, 0))) return;
         }//if (SendShort)
and

Code: Select all

//MA stacking check. Thanks to Andy (Mr Long) for this code
      if (SendLong)
      {
         if (useMaStack && (!detectMaStack(Symbol(), PERIOD_H4, FastMaTdPeriod, SlowMaTdPeriod, 0, MODE_LWMA, PRICE_OPEN, OP_BUY, 0))) return;
      }//if (SendLong)
Instead of FastMaTdPeriod, SlowMaTdPeriod it should be
FastStackMaPeriod, SlowStackMaPeriod or not? :)
Author:  SteveHopwood [ Fri Aug 09, 2013 9:45 am ]
Post subject:  Re: Bob and Shelley Again

fxdaytrader wrote:Could be a bloop?

Instead of FastMaTdPeriod, SlowMaTdPeriod it should be
FastStackMaPeriod, SlowStackMaPeriod or not? :)
Fabulous spot. Thanks. This is a last gasp just-in-case check, so the bloop completely negated MA stacking.

Fixed in V 1k in post 1.

Guys, discovering that I had negated MA stacking sent me to my demo to study the open trades. Correctly coded MA stacking would have kept me out of most of the losers. Not all of them, but most so this looks like an invaluable filter.

Then I noticed stack trades that should have been taken but were not, so I found a couple of bloops in the troublesome trade stacking code that were stopping the trades.

So, if you want to use MA stacking and demo trade stacking, then the download is essential.

:D
Author:  ffxbettor [ Fri Aug 09, 2013 11:43 am ]
Post subject:  Re: Bob and Shelley Again

Potential bloop :

At the end of the function detectMaStack(), dont forget to add this instruction : return (false);

Before :

Code: Select all

bool detectMaStack(string symbol, int timeframe, int period, int period1, int mashift, int method, int applied, int type, int shift)
{
   if (type == OP_BUY)
   {
    .... blabla
    return(true);
   }

   if (type == OP_SELL)
   {
    .... blabla
    return(true);
   }
   
}//End detectMaStack
After :

Code: Select all

bool detectMaStack(string symbol, int timeframe, int period, int period1, int mashift, int method, int applied, int type, int shift)
{
   if (type == OP_BUY)
   {
    .... blabla
    return(true);
   }

   if (type == OP_SELL)
   {
    .... blabla
    return(true);
   }

   return (false); // <---

}//End detectMaStack

Not sure if it's required, but better to add this small line of code, just to be sure !

Cheers,
Didier
Author:  MrLong [ Fri Aug 09, 2013 12:11 pm ]
Post subject:  Re: Bob and Shelley Again

ffxbettor wrote:Potential bloop :

At the end of the function detectMaStack(), dont forget to add this instruction : return (false);

Before :

Code: Select all

bool detectMaStack(string symbol, int timeframe, int period, int period1, int mashift, int method, int applied, int type, int shift)
{
   if (type == OP_BUY)
   {
    .... blabla
    return(true);
   }

   if (type == OP_SELL)
   {
    .... blabla
    return(true);
   }
   
}//End detectMaStack
After :

Code: Select all

bool detectMaStack(string symbol, int timeframe, int period, int period1, int mashift, int method, int applied, int type, int shift)
{
   if (type == OP_BUY)
   {
    .... blabla
    return(true);
   }

   if (type == OP_SELL)
   {
    .... blabla
    return(true);
   }

   return (false); // <---

}//End detectMaStack

Not sure if it's required, but better to add this small line of code, just to be sure !

Cheers,
Didier
default is false.
Author:  SteveHopwood [ Fri Aug 09, 2013 12:16 pm ]
Post subject:  Re: Bob and Shelley Again

ffxbettor wrote: Not sure if it's required, but better to add this small line of code, just to be sure !

Cheers,
Didier
Theoretically, it does not matter because a CrapQl4 Boolean function will return(false) if not explicitly coded told to return(true). All of us coders know who unreliable implicit values are in CrapQl4 and everything should be done explicitly.

So, I have added the line of code to the function. I have not issued another update yet; I shall do that over the weekend when I have added the ATR stop loss function that Shelley wants.

Also, the 50% stop loss is back - 50 instead of 100 pips. I made an incorrect change to the calculation function (wrong conditional), so those of you who can, copy this over the top of the existing function and recompile:

Code: Select all

double CalculateStopLoss(int type, double price)
{
   //Returns the stop loss for use in LookForTradingOpps and InsertMissingStopLoss
   double stop;

   RefreshRates();
   
   if (type == OP_BUY)
   {
      if (!CloseEnough(StopLoss, 0) ) 
      {
         if (OpenTrades == 0) stop = price - (StopLoss / factor);
         else 
         {
            stop = price - ((StopLoss / 2) / factor);
         }//else 
         
         HiddenStopLoss = stop;
      }//if (!CloseEnough(StopLoss, 0) ) 

      if (HiddenPips > 0 && stop > 0) stop = NormalizeDouble(stop - (HiddenPips / factor), Digits);
   }//if (type == OP_BUY)
   
   if (type == OP_SELL)
   {
      if (!CloseEnough(StopLoss, 0) ) 
      {
         if (OpenTrades == 0) stop = price + (StopLoss / factor);
         else 
         {
            stop = price + ((StopLoss / 2) / factor);
         }//else 
         
         HiddenStopLoss = stop;         
      }//if (!CloseEnough(StopLoss, 0) ) 
      
      if (HiddenPips > 0 && stop > 0) stop = NormalizeDouble(stop + (HiddenPips / factor), Digits);

   }//if (type == OP_SELL)
   
   return(stop);
   
}//End double CalculateStopLoss(int type)
:D
Author:  fxozgirl [ Sun Aug 11, 2013 5:27 am ]
Post subject:  Re: Bob and Shelley Again

Stacking trades is working...3 stack trades were taken on Friday
basawithstacking_130809.png
All times are UTC Page 14 of 120