Experts: Flat Channel

 

Flat Channel:

Brief Description

Flat Channel

Author: Vladimir Karputov

 

The authors are good! Good work, achieved the goal - profitable flat Expert Advisor. Now I tested it on our market, in particular on Si-12.18, it gives a good profit! I've been looking for such an Expert Advisor for a long time.

There are a couple of comments: 1. It takes too long to draw, all the logic is in OnTick, it is not a tick, you can use CBarDetector with period M1 or M5. I made it with M5 - it is much more fun to work. 2. I would like to have min.-max. channel width in dynamics depending on the current market volatility.

 
Rashit Ibatullin:

The authors are good! Good work, achieved the goal - profitable flat Expert Advisor. Now I tested it on our market, in particular on Si-12.18, it gives a good profit! I've been looking for such an Expert Advisor for a long time.

There are a couple of comments: 1. It takes too long to draw, all the logic is in OnTick, it is not tick-based, you can use CBarDetector with period M1 or M5. I made it with M5 - it is much more fun to work. 2. I would like to have a min.-max. channel width in dynamics depending on the current market volatility.

To test quickly in the visual mode, you need to disable the comments output in the code:

/*   Comment("\nСоветник "+__FILE__+" весь в работе:  ",TimeControl(),
           "\nДень:  ",Dayof(STimeCurrent),
           "\nТорговый счёт:  ",m_account.Login(),
           "\nCompany:  ",m_account.Company(),
           "\nEquity:  ",m_account.Equity(),
           "\nВремя по GMT:  "+TimeToString(TimeGMT(),TIME_DATE|TIME_SECONDS),
           "\nSpread:  ",m_symbol.Spread(),
           "\nStopLevel:  ",m_symbol.StopsLevel(),
           "\nПлечо:  ",m_account.Leverage()
           );*/
//--- we work only at the time of the birth of new bar
 

Thanks to those who implemented this EA!

I'm taking this EA apart line by line to adapt it to moex (it is designed for forex after all), so I have a question about the code.

//--- FreezeLevel -> for pending order and modification

   double freeze_level=m_symbol.FreezeLevel()*m_symbol.Point();
   if(freeze_level==0.0)
      freeze_level=(m_symbol.Ask()-m_symbol.Bid())*3.0;
   freeze_level*=1.1;
   
   
   
   
//--- StopsLevel -> for TakeProfit and StopLoss
   double stop_level=m_symbol.StopsLevel()*m_symbol.Point();
   if(stop_level==0.0)
      stop_level=(m_symbol.Ask()-m_symbol.Bid())*3.0;
   stop_level*=1.1;
   

why is there multiplication, exactly by 3 and then by 1.1?

 
refounder83:

Thank you to those who implemented this EA!

I am taking this EA apart line by line to adapt it to moex (it is designed for forex after all), so I have a question about the code.

why is there multiplication, exactly by 3 and then by 1.1?

I know forex, I know stock exchange. But I don't know what kind of a beast moex is.

 
You yourself created a topic yesterday called ---- Expert Advisor for moex. Getting the price ?
 
I just want to understand the logic of the code and adapt it to the exchange.
 
refounder83:
I just want to understand the logic of the code and adapt it to the stock exchange

1.Please note: if I reply to someone, I use the "Reply" button.

2.To write the code accurately, first find out everything about SYMBOL_TRADE_STOPS_LEVEL and SYMBOL_TRADE_FREEZE_LEVEL levels from the broker's tech support: are these levels zero on all symbols? What does "zero" mean - is it a floating level or is there really no level.

 
Vladimir Karputov:

1- Please note: if I am replying to someone, I use the "Reply" button.

2.To write the code accurately, first find out everything about SYMBOL_TRADE_STOPS_LEVEL and SYMBOL_TRADE_FREEZE_LEVEL levels from the broker's tech support: are these levels zero on all symbols? What does "zero" mean - is it a floating level or is there really no level.

I wrote to the broker's technical support that these levels are not broadcasted.

 
refounder83:

I wrote to the broker's technical support that these levels are not broadcast.

Then just ignore them (temporarily comment out the lines where these levels are learnt).

 
Vladimir Karputov:

Then just ignore them (temporarily comment out the lines where those levels are learnt).

Can you tell me if time control does not work in this EA? There are lines in the TimeControl procedure.

  if(!InpTimeControl)
      return(true);

i.e. if the value of InpTimeControl is false, it still returns true to the TimeControl procedure?

bool TimeControl(void)
  {
   if(!InpTimeControl)
      return(true);
      
   MqlDateTime STimeCurrent;
   datetime time_current=TimeCurrent();
   if(time_current==D'1970.01.01 00:00')
      return(false);
   TimeToStruct(time_current,STimeCurrent);
   if(InpStartHour<InpEndHour) // intraday time interval
     {

      if(STimeCurrent.hour>=InpStartHour && STimeCurrent.hour<InpEndHour)
         return(true);
     }
   else if(InpStartHour>InpEndHour) // time interval with the transition in a day
     {

      if(STimeCurrent.hour>=InpStartHour || STimeCurrent.hour<InpEndHour)
         return(true);
     }
   else
      return(false);
//---
   return(false);
  }