"Fake signals" showing up in MT4 when I don't want them too.

Back to topics list To post a new topic, please log in or register
avatar
6
Lowkey 2015.09.22 20:52
 

Hello, I've noticed that an indicator of mine sometimes show signals when they are not supposed to come (or atleast I believe so).

 I've snapped 2 pictures for you so it's easier to understand.

The first picture is when some of them have shown up. As you can see they only show up within one candlestick of a "real" signal. I can fix this by opening the indicator options and press ok and they will dissappear. The second picture is after I've done this. However, I need them to not show up at all as it messes with my strategy. Is there any way to fix this? I'll be very thankful if someone can help with this.

I will give $20 in bitcoin to whoever can solve this. Thanks!

  

 

avatar
Moderator
172
alexvd 2015.09.23 08:58 #
 
It seems like logical mistake, check your code.
avatar
Moderator
3404
GumRai 2015.09.23 09:24 #
 

Probably, the indicator is checking conditions on the current bar (at the time).

When you re-initialise the indicator, it can only do the calculations on closed bars, so it will be different.

Re-code the indicator to only calculate with closed bars 

avatar
6
Lowkey 2015.09.23 17:47 #
 

Thanks. Unfortunately, I don't know much about coding (not me who made it) but I assume it's something that needs to be modified in this.

Anyone mind taking a look at this and see if they can fix this problem? Very appreciated. 


#property copyright "Copyright © 2006, MetaQuotes Software Corp."

#property link      "http://www.metaquotes.net"

//----

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 clrWhite

#property indicator_color2 clrRed

#property indicator_width1 2

#property indicator_width2 2

//----

double CrossUp[];

double CrossDown[];

extern int FasterMode=3; //0=sma, 1=ema, 2=smma, 3=lwma

extern int FasterMA=3;

extern int SlowerMode=3; //0=sma, 1=ema, 2=smma, 3=lwma

extern int SlowerMA=3;

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

//| Custom indicator initialization function                         |

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

int init()

  {

//---- indicators

   SetIndexStyle(0,DRAW_ARROW,EMPTY);

   SetIndexArrow(0,233);

   SetIndexBuffer(0,CrossUp);

   SetIndexStyle(1,DRAW_ARROW,EMPTY);

   SetIndexArrow(1,234);

   SetIndexBuffer(1,CrossDown);

//----

   return(0);

  }

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

//| Custom indicator deinitialization function                       |

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

int deinit()

  {

//---- 

//----

   return(0);

  }

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

//| Custom indicator iteration function                              |

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

int start()

  {

   int limit,i,counter;

   double fasterMAnow,slowerMAnow,fasterMAprevious,slowerMAprevious,fasterMAafter,slowerMAafter;

   double Range,AvgRange;

   int counted_bars=IndicatorCounted();

   if(counted_bars<0) return(-1);

   if(counted_bars>0) counted_bars--;

   limit=Bars-counted_bars;

   if(counted_bars==0) limit-=(1+9);

   if(Bars<10) return(0);

//----

   for(i=0; i<=limit; i++)

     {

      counter=i;

      Range=0;

      AvgRange=0;

      for(counter=i;counter<=i+9;counter++)

        {

         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);

        }

      Range=AvgRange/10;

      fasterMAnow=iMA(NULL,0,FasterMA,0,FasterMode,PRICE_CLOSE,i);

      fasterMAprevious=iMA(NULL,0,FasterMA,0,FasterMode,PRICE_CLOSE,i+1);

      fasterMAafter=iMA(NULL,0,FasterMA,0,FasterMode,PRICE_CLOSE,i-1);

      //----

      slowerMAnow=iMA(NULL,0,SlowerMA,0,SlowerMode,PRICE_OPEN,i);

      slowerMAprevious=iMA(NULL,0,SlowerMA,0,SlowerMode,PRICE_OPEN,i+1);

      slowerMAafter=iMA(NULL,0,SlowerMA,0,SlowerMode,PRICE_OPEN,i-1);

      if((fasterMAnow>slowerMAnow) && (fasterMAprevious<slowerMAprevious) && (fasterMAafter>slowerMAafter))

        {

         CrossUp[i]=Low[i]-Range*0.5;

        }

      else if((fasterMAnow<slowerMAnow) && (fasterMAprevious>slowerMAprevious) && (fasterMAafter<slowerMAafter))

        {

         CrossDown[i]=High[i]+Range*0.5;

        }

     }

   return(0);

  }

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

avatar
12983
WHRoeder 2015.09.24 20:25 #
 
Don't paste code
Play video
Please edit your post.
For large amounts of code, attach it.
avatar
6
Lowkey 2015.09.24 21:43 #
 
WHRoeder:

Play video
Please edit your post.
For large amounts of code, attach it.

Thx

avatar
Moderator
3404
GumRai 2015.09.25 00:19 #
 

"Fake signals" is correct, that code is a cheat as it checks the bar after the arrow when it is initialised.

   double fasterMAnow,slowerMAnow,fasterMAprevious,slowerMAprevious,fasterMAafter,slowerMAafter;

 delete highlighted

   double fasterMAnow,slowerMAnow,fasterMAprevious,slowerMAprevious;

 

   for(i=0; i<=limit; i++)

 if you want to only work with closed bars, so not to get false signals while the bar is current, change the 0 to 1

 

      fasterMAafter=iMA(NULL,0,FasterMA,0,FasterMode,PRICE_CLOSE,i-1);



      slowerMAafter=iMA(NULL,0,SlowerMA,0,SlowerMode,PRICE_OPEN,i-1);

 Remove these 2 lines as they are cheats

 

      if((fasterMAnow>slowerMAnow) && (fasterMAprevious<slowerMAprevious) && (fasterMAafter>slowerMAafter))

 Remove the cheating condition

      if((fasterMAnow>slowerMAnow) && (fasterMAprevious<slowerMAprevious))

 

 and again here

      else if((fasterMAnow<slowerMAnow) && (fasterMAprevious>slowerMAprevious) && (fasterMAafter<slowerMAafter))

 

      else if((fasterMAnow<slowerMAnow) && (fasterMAprevious>slowerMAprevious))

 Then the indicator should work properly without cheating

 

 

 

 

 

 

avatar
6
Lowkey 2015.09.25 01:16 #
 

Thanks, I tried it but now it shows the "false signals" which I don't as soon as I load the indicator. Is there any way to get those signals to not show up at all? 


For example, perhaps you could stop them from appearing within one candlestick of another signal? I think that could solve it. Or would just one of the fakes show up then?

Another way could be if there was some way to auto refresh or auto update the indicator as that would remove the fake signals.

EDIT: A third solution could be to have those arrows/signals in a different colour, if that's possible...  

avatar
Moderator
3404
GumRai 2015.09.25 01:47 #
 

No, it should now be showing signals. The signals may not be so (apparently) accurate as before, because the indicator no longer cheats, it doesn't use data that didn't exist when the bar was current.

Imagine if I said to you look at Monday's close price, now if Tuesday's close is higher, draw an up arrow, if lower, draw a down arrow. Simple to do and off course extremely accurate.

Now do it for today's chart by looking at tomorrow's close. Can't be done can it? Because you can't see tomorrow's close until tomorrow.

That is similar to what the indicator was doing, looking at the next bar before drawing an arrow. Cannot be done when the bar is the current bar 

avatar
6
Lowkey 2015.09.25 02:27 #
 
GumRai:

No, it should now be showing signals. The signals may not be so (apparently) accurate as before, because the indicator no longer cheats, it doesn't use data that didn't exist when the bar was current.

Imagine if I said to you look at Monday's close price, now if Tuesday's close is higher, draw an up arrow, if lower, draw a down arrow. Simple to do and off course extremely accurate.

Now do it for today's chart by looking at tomorrow's close. Can't be done can it? Because you can't see tomorrow's close until tomorrow.

That is similar to what the indicator was doing, looking at the next bar before drawing an arrow. Cannot be done when the bar is the current bar 

Hmm, so why is it doing that? Is it because the indicator is indecisive or something? 

It actually acts the same after the changes, except before I could remove those fake signals by resetting or reloading the indicator. I just don't want to see them at all.

Do you know what I mean? 

 

EDIT: I've now noticed that some new different kind of fake signals show up after the changes and instead those will disappear when I reset/reload the indicator... I can supply pictures tomorrow if needed, heading for sleep now probably.

 

avatar
6
Lowkey 2015.09.25 02:48 #
 
I will give $20 in bitcoin to whoever solves this problem btw
Back to topics list  

To add comments, please log in or register