거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Facebook에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
Experts

Simplest EA using DeMarker indicator - MetaTrader 4용 expert

조회수:
9838
평가:
(24)
게시됨:
2020.12.16 16:28
업데이트됨:
2020.12.16 21:38
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

In the past, I thought of using an EA for my trading and this is part of my simple EA and this is the simplest EA I ever had so please rate this after read...

This EA working on single pair. With the fully functioning setting timeframe, lots, stoploss and takeprofit here are input in the menu properties.


extern ENUM_TIMEFRAMES TF  = PERIOD_CURRENT;// Select Time Frame
extern int period          = 8;// Period DeMarker
extern double lt           = 0.01;// Lots
extern int sl              = 100;// Stop Loss
extern int tp              = 100;// Take Profit
extern double OB           = 0.7;// Over Sold
extern double OS           = 0.3;// Over Bought
extern bool OPENBAR        = false;// Trading on newbar open price

Here is the secret, I divide it into 3 parts of variables:
1. data | timeframe
2. order
3. pair

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

//-- time frame|indicator
double dmrk[5];
int signal  =-1;//-- 0.buy 1.sell
int hold = 0;


//-- order
int ticket  =0;
double lot  =0.0;
int typ     =-1;




//-- pair
datetime t1=0;
bool newbar=false;
bool entry =false;


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

In OnInit() function, I have to initialize an indicator DeMarker array variable and also checking minimum lot size of trading for the specific type of broker requirement.

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnInit()
  {
   ArrayInitialize(dmrk,0.0);
  //---
      const double test_lot   = SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);
      if(lt<test_lot)   lt    = test_lot;
  }

On OnTick() function, this is the for calculating of the indicator and to determine the buy and sell signals

//---------------------------------------------------------------------------
   signal = -1;
//---------------------------------------------------------------------------


//---calc
   for(int i=0; i<ArraySize(dmrk); i++)
     {
      dmrk[i]  =  iDeMarker(Symbol(),TF,period,i);
     }
//---


   if(dmrk[1] > OB)
     {
      hold = 1;//set
     }
   else
      if(dmrk[1] < OS)
        {
         hold = -1;//set
        }
      else
        {
         hold = 0;//reset
        }


   if(hold ==  1)
     {
      if(dmrk[0]<OB && dmrk[1]>OB)
        {
         signal = OP_SELL;
        }
     }
   if(hold == -1)
     {
      if(dmrk[0]>OS && dmrk[1]<OS)
        {
         signal = OP_BUY;
        }
     }

To open a buy and sell signal...

//---------------------------------------------------------------------------
   if(signal != -1)
      if(newbar==true)
         if(entry==false)//door open
           {
            //---
            entry =true;//set
            //---

            if(signal == OP_BUY)
              {
               ticket = OrderSend(Symbol(),OP_BUY,lt,Ask,(int)((Ask-Bid)/Point),
                                  sl>0?Bid-sl*Point:0.0,
                                  tp>0?Bid+tp*Point:0.0,
                                  EAName+":signal= "+IntegerToString(signal)+":hold= "+IntegerToString(hold),
                                  EANumber,
                                  0,
                                  clrBlue);
               signal=-1;
               //hold =0;
              }//reset
            else
               if(signal == OP_SELL)
                 {
                  ticket = OrderSend(Symbol(),OP_SELL,lt,Bid,(int)((Ask-Bid)/Point),
                                     sl>0?Ask+sl*Point:0.0,
                                     tp>0?Ask-tp*Point:0.0,
                                     EAName+":signal= "+IntegerToString(signal)+":hold= "+IntegerToString(hold),
                                     EANumber,
                                     0,
                                     clrRed);
                  signal=-1;
                  //hold =0;
                 }//reset signal

           }


And for the closing...

   if(entry == true) // closing
     {

      if(OrderSelect(ticket,SELECT_BY_TICKET))
        {
         if(OrderCloseTime() == 0)//-- order active trade
           {
            /*  todo condition to close  */
            //entry = false;
           }
         //else
            if(OrderCloseTime() != 0)//--  close by 1. manual 2. sl/tp 3. ea
              {
               entry = false;//reset entry
              }
        }
     }

  



iFisher iFisher

New fisher to catch trend with indication UP and DN

Deviation Rate BIAS MT4 Deviation Rate BIAS MT4

Stock trading indicators. BIAS.

MultiVote On Balance Volume MultiVote On Balance Volume

MultiVote On Balance Indicator displays a higher resolution of trading volume activity to the regular On Balance Volume calculation.

Clarity Index Clarity Index

Clarity index is a purely volume based indicator which is constructed on basis of volume, range and positive/negative candle count. It reflects the strength of trend with respect to volume.