How I assemble my advisor by trial and error - page 45

 
Come on.
 

A simple Expert Advisor for testing Indicators

enter the name of the indicator

input string short_name       = "LeM 2 Macd"; // name indicator

if the position opens in the wrong direction, switch the reverse

input bool   Revers           = false;        // Revers

not all indicators work - ok, signal indicators work

all expert settings

//---
input double InpLots          = 0.01;         // Lots
input int    InpTrailingStop  = 0;            // Trailing Stop Level (in pips)
input bool   Revers           = false;        // Revers
input string short_name       = "LeM 2 Macd"; // name indicator
//---

Snapshot.PNG

Files:
 
Alexsandr San:

A simple Expert Advisor for testing Indicators

enter the name of the indicator

if the position opens in the wrong direction, switch the reverse

not all indicators work - normal, signal indicators work

all expert settings

if the indicator is located in another folder

write it like this - Examples\\ZigzagColor

Examples

zigzag

 

trying to make something out of the Indicator ( Heiken_Ashi.mq5 )

- so far I got, Musical ( when grey above blue, one sound, when below, another sound )

EURSGDM1

Files:
03.mq5  12 kb
 
Alexsandr San:

trying to make something out of the Indicator ( Heiken_Ashi.mq5 )

- I got it so far, musical (when the gray line above the blue one sound, when below, another sound)


I can not, do not get it right, how to make the line that crosses the other line, the signal went off and shut up ?

I did that, but the alarm goes off every bar

//--- we work only at the time of the birth of new bar
   datetime time_0=iTime(Symbol(),Period(),0);
   if(time_0==m_prev_bars)
      return(rates_total);
   m_prev_bars=time_0;
//---
   int find_buy_level=ObjectFind(0,InpFont2);
   int find_sell_level=ObjectFind(0,InpFont1);

   if(find_buy_level==0)
     {
      double price=ObjectGetDouble(0,InpFont2,OBJPROP_PRICE);
      if(ObjectGetDouble(0,InpFont1,OBJPROP_PRICE)<price)
        {
         PlaySound("tick.wav");
         //---
         return(rates_total);
        }
     }
   if(find_sell_level==0)
     {
      double price=ObjectGetDouble(0,InpFont2,OBJPROP_PRICE);
      if(ObjectGetDouble(0,InpFont1,OBJPROP_PRICE)>price)
        {
         PlaySound("stops.wav");
         //---
         return(rates_total);
        }
     }
//--- done
   return(rates_total);
  }
 
It's an interesting indicator. How does it work?
 
Alex potapenko:
It is an interesting indicator. How does it work?

I don't know yet, I'm not a programmer - so, by poking, I want the line to cross another line and trigger a signal.

- It seems to work - but not like that.

 

The signal from the Heiken_Ashi indicator. ---- Heiken2_Ashi Indicator

And, Expert to test the Indicator

AUDCADH4

Files:
 
Alexsandr San:

The signal from the Heiken_Ashi indicator. ---- Heiken2_Ashi Indicator

And, an Expert Advisor for testing the Indicator


In the Heiken2_Ashi Indicator, you can add filters

//---- получение хендла индикатора RSI
   RSI_Handle=iRSI(NULL,0,int(ParmMult*9),PRICE_CLOSE);
   if(RSI_Handle==INVALID_HANDLE)
      Print(" Не удалось получить хендл индикатора iRSI");
//---- получение хендла индикатора Stochastic
   STO_Handle=iStochastic(NULL,0,int(21*ParmMult),int(3*ParmMult),int(2*ParmMult),MODE_LWMA,STO_LOWHIGH);
   if(STO_Handle==INVALID_HANDLE)
      Print(" Не удалось получить хендл индикатора iStochastic");
//---- получение хендла индикатора MACD
   MACD_Handle=iMACD(NULL,0,int(10*ParmMult),int(15*ParmMult),int(13*ParmMult),PRICE_CLOSE);
   if(MACD_Handle==INVALID_HANDLE)
      Print(" Не удалось получить хендл индикатора iMACD");
//---- получение хендла индикатора hHeiken_Ashi
   hHeiken_Ashi=iCustom(NULL,0,"Examples\\Heiken_Ashi");
   if(hHeiken_Ashi==INVALID_HANDLE)
      Print(" Не удалось получить хендл индикатора hHeiken_Ashi");

by adding these filters here

      RsiDn=RSI[bar]<=x2;
      StochDn=STO[bar]<STOS[bar];
      MacdDn=MACD[bar]<MACDS[bar];
      haClDn=haOpen[bar]>haClose[bar];

      RsiUp=RSI[bar]>=x1;
      StochUp=STO[bar]>STOS[bar];
      MacdUp=MACD[bar]>MACDS[bar];
      haOpUp=haOpen[bar]<haClose[bar];

here

      if(haClDn)
         p = 1;
      if(haOpUp)
         p = 2;
      if(haClDn && (p==1 || p==0))
        {
         if(OldTrend>0)
            SellBuffer[bar]=high[bar];
         if(bar!=0)
            OldTrend=-1;
        }
      if(haOpUp && (p==2 || p==0))
        {
         if(OldTrend<0)
            BuyBuffer[bar]=low[bar];
         if(bar!=0)
            OldTrend=+1;
        }
     }

like this

      if(StochDn && RsiDn && MacdDn && haClDn)
         p = 1;
      if(StochUp && RsiUp && MacdUp && haOpUp)
         p = 2;
      if(StochDn && RsiDn && MacdDn && haClDn && (p==1 || p==0))
        {
         if(OldTrend>0)
            SellBuffer[bar]=high[bar];
         if(bar!=0)
            OldTrend=-1;
        }
      if(StochUp && RsiUp && MacdUp && haOpUp && (p==2 || p==0))
        {
         if(OldTrend<0)
            BuyBuffer[bar]=low[bar];
         if(bar!=0)
            OldTrend=+1;
        }
     }
//----
   return(rates_total);
  }
 

The indicator, there is something about it, when it is best to open a position

Between the two horizontal lines, you can open in whichever colour the dot is .

Photo by

Files:
LN_1.mq5  27 kb