Create an EA based on an indicator for mt5

2020.10.17 Experts

Specification

I need to create MT5 EA based on custom indicator attached below 

When a star appear on top it's a sell

When a star appear on the bottom it's a buy

A robot must close a trade when another star appear

lot size 

TP and SL as extra option 

source code

i have attached source code below 

//------------------------------------------------------------------
#property copyright   "non repainting system"
#property link        "mladenfx@gmail.com"
#property description "SAMUEL MOEPI NQAI NON REPAINTING SYSTEM"
//------------------------------------------------------------------
#property indicator_chart_window
#property indicator_buffers 9
#property indicator_plots   4
#property indicator_label1  "PTL trend candles"
#property indicator_type1   DRAW_COLOR_CANDLES
#property indicator_color1  clrDodgerBlue,clrCrimson
#property indicator_label2  "PTL slow line"
#property indicator_type2   DRAW_LINE
#property indicator_style2  STYLE_DOT
#property indicator_color2  clrDodgerBlue
#property indicator_label3  "PTL fast line"
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrCrimson
#property indicator_style3  STYLE_DOT
#property indicator_label4  "PTL trend start"
#property indicator_type4   DRAW_COLOR_ARROW
#property indicator_color4  clrDodgerBlue,clrCrimson
#property indicator_width4  2

//
//
//

input int inpFastLength = 3; // Fast length
input int inpSlowLength = 7; // Slow length

//
//
//

double slowlu[],slowln[],fastln[],arrowar[],arrowcl[],candleo[],candleh[],candlel[],candlec[],candleC[];
int _fastPeriod,_slowPeriod;
//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//

int OnInit()
{
   SetIndexBuffer( 0,candleo,INDICATOR_DATA);
   SetIndexBuffer( 1,candleh,INDICATOR_DATA);
   SetIndexBuffer( 2,candlel,INDICATOR_DATA);
   SetIndexBuffer( 3,candlec,INDICATOR_DATA);
   SetIndexBuffer( 4,candleC,INDICATOR_COLOR_INDEX);
   SetIndexBuffer( 5,slowln ,INDICATOR_DATA);
   SetIndexBuffer( 6,fastln ,INDICATOR_DATA);
   SetIndexBuffer( 7,arrowar,INDICATOR_DATA); 
   SetIndexBuffer( 8,arrowcl,INDICATOR_COLOR_INDEX);

      _fastPeriod = MathMax(MathMin(inpFastLength,inpSlowLength),1);
      _slowPeriod = MathMax(MathMax(inpFastLength,inpSlowLength),1);
      
      //
      //---
      //      

      PlotIndexSetInteger(3,PLOT_ARROW,159);

   return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason) { return; }

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
{                
   struct sPtlStruct
   {
      datetime time;
      double   fastHigh;
      double   fastLow;
      double   slowHigh;
      double   slowLow;
      int      trend;
      int      trena;
   };
   static sPtlStruct m_array[];
   static int        m_arraySize=-1;
                 if (m_arraySize<rates_total) m_arraySize = ArrayResize(m_array,rates_total+500,2000);
   
   //
   //
   //
   
   int i= prev_calculated-1; if (i<0) i=0; for (; i<rates_total && !_StopFlag; i++)
   {
      if (m_array[i].time != time[i])
      {
         m_array[i].time = time[i];
            int _startf = i-_fastPeriod+1; if (_startf<0) _startf = 0;
            int _starts = i-_slowPeriod+1; if (_starts<0) _starts = 0;
                                           if (i<rates_total-1) m_array[i+1].time = 0;
               m_array[i].fastHigh = high[ArrayMaximum(high,_startf,_fastPeriod-1)];
               m_array[i].fastLow  = low [ArrayMinimum(low ,_startf,_fastPeriod-1)];
               m_array[i].slowHigh = high[ArrayMaximum(high,_starts,_slowPeriod-1)];
               m_array[i].slowLow  = low [ArrayMinimum(low ,_starts,_slowPeriod-1)];
      }

      //
      //
      //
      
      double thighs = (high[i]<m_array[i].slowHigh) ? m_array[i].slowHigh : high[i];
      double tlows  = (low[i] >m_array[i].slowLow)  ? m_array[i].slowLow  : low[i];
      double thighf = (high[i]<m_array[i].fastHigh) ? m_array[i].fastHigh : high[i];
      double tlowf  = (low[i] >m_array[i].fastLow)  ? m_array[i].fastLow  : low[i];

      //
      //
      //
            
         m_array[i].trend = -1;
         if (i>0)
         {
            m_array[i].trena  = m_array[i-1].trena;
               slowln[i] = (close[i]>slowln[i-1]) ? tlows : thighs;
               fastln[i] = (close[i]>fastln[i-1]) ? tlowf : thighf;
                  if (close[i]<slowln[i] && close[i]<fastln[i])     m_array[i].trend = 1;
                  if (close[i]>slowln[i] && close[i]>fastln[i])     m_array[i].trend = 0;
                  if (slowln[i]>fastln[i] || m_array[i].trend == 1) m_array[i].trena = 1;
                  if (slowln[i]<fastln[i] || m_array[i].trend == 0) m_array[i].trena = 0;
               
                  //
                  //
                  //
               
                  arrowar[i] = (m_array[i].trena !=m_array[i-1].trena) ? (m_array[i].trena==1) ? MathMax(fastln[i],slowln[i]) : MathMin(fastln[i],slowln[i]) : EMPTY_VALUE;
         }
         else 
         { 
            arrowcl[i] = 0; 
            arrowar[i] = EMPTY_VALUE; 
            fastln[i]  = slowln[i] = close[i]; 
            m_array[i].trend = m_array[i].trena = 0;
         }
         if (m_array[i].trend!=-1)
            { 
               candleo[i] = open[i];
               candleh[i] = high[i];
               candlel[i] = low[i];
               candlec[i] = close[i];
            }
         else candleo[i] = candleh[i] = candlel[i] = candlec[i] = EMPTY_VALUE;
         
         //
         //
         //
         
         candleC[i] = m_array[i].trend;
         arrowcl[i] = m_array[i].trena;
   }          
   return(rates_total);
}


Responded

1
Developer 1
2020.10.17
Rating
4.9
(39)
Projects
47
19%
Arbitration
5
0% / 60%
Overdue
4
9%
Loaded
2
Developer 2
2020.10.17
Rating
5
(1)
Projects
2
0%
Arbitration
1
0% / 100%
Overdue
0
Working
3
Developer 3
2020.10.17
Rating
4.76
(51)
Projects
59
31%
Arbitration
6
0% / 83%
Overdue
7
12%
Working
4
Developer 4
2020.10.17
Rating
4.92
(545)
Projects
722
41%
Arbitration
24
67% / 21%
Overdue
37
5%
Loaded
5
Developer 5
2020.10.17
Rating
5
(4)
Projects
4
0%
Arbitration
0
Overdue
0
Working
6
Developer 6
2020.10.17
Rating
4.84
(100)
Projects
139
28%
Arbitration
6
50% / 33%
Overdue
8
6%
Free
7
Developer 7
2020.10.17
Rating
5
(8)
Projects
8
38%
Arbitration
3
0% / 67%
Overdue
3
38%
Working
8
Developer 8
2020.10.17
Rating
3.67
(3)
Projects
2
0%
Arbitration
3
0% / 100%
Overdue
2
100%
Free
9
Developer 9
2020.10.17
Rating
4.77
(35)
Projects
35
17%
Arbitration
6
0% / 100%
Overdue
7
20%
Free
10
Developer 10
2020.10.17
Rating
5
(1)
Projects
1
0%
Arbitration
0
Overdue
0
Free
11
Developer 11
2020.10.17
Rating
0
Projects
0
0%
Arbitration
0
Overdue
0
Free
12
Developer 12
2020.10.17
Rating
4.68
(22)
Projects
28
18%
Arbitration
0
Overdue
2
7%
Working
13
Developer 13
2020.10.18
Rating
4.79
(33)
Projects
48
46%
Arbitration
16
19% / 63%
Overdue
8
17%
Working
14
Developer 14
2020.10.18
Rating
5
(4)
Projects
5
0%
Arbitration
1
0% / 0%
Overdue
0
Loaded
15
Developer 15
2020.10.18
Rating
5
(1)
Projects
1
0%
Arbitration
0
Overdue
0
Free
16
Developer 16
2020.10.18
Rating
4.89
(19)
Projects
21
5%
Arbitration
1
0% / 0%
Overdue
2
10%
Working
17
Developer 17
2020.10.21
Rating
4.86
(58)
Projects
126
32%
Arbitration
7
14% / 71%
Overdue
32
25%
Free

Project information

Budget
30+ USD
For the developer
27 USD
Deadlines
from 1 day(s)

Customer

Placed orders29
Arbitrage count2