A simple way to calculate Max Potential profit and growth of a forex symbol

 

Its a MT5 Script if any one could turn it into an EA it would be very much appreciated. 

void OnStart()
  {
   int Num_bars;
   switch(_Period)
     {
      case PERIOD_M1:Num_bars    = 180;break;   case PERIOD_M3:Num_bars    = 60;break;
      case PERIOD_M5:Num_bars    = 36;break;    case PERIOD_M10:Num_bars   = 18;break;
      case PERIOD_M15:Num_bars   = 12;break;    case PERIOD_M30:Num_bars   = 6;break;
      case PERIOD_H1:Num_bars    = 3;break;     default:Num_bars = WRONG_VALUE;
     };
   long Spr_Pure = SymbolInfoInteger(_Symbol,SYMBOL_SPREAD);

   MqlRates  Pri_Info[];
   ArraySetAsSeries(Pri_Info,true);
   CopyRates(_Symbol,PERIOD_CURRENT,0,Num_bars,Pri_Info);

   double Atr_Data[];
   ArraySetAsSeries(Atr_Data,true);
   CopyBuffer(iATR(_Symbol,PERIOD_CURRENT,Num_bars),0,0,Num_bars,Atr_Data);
   double Atr_Pure = (NormalizeDouble(Atr_Data[0],Digits()))/_Point;

   double Hig_Data[];
   ArraySetAsSeries(Hig_Data,true);
   CopyHigh(_Symbol,PERIOD_CURRENT,0,Num_bars,Hig_Data);
   double Hig_Pure = (NormalizeDouble((Pri_Info[ArrayMaximum(Hig_Data,0,Num_bars)].high),Digits()))/_Point;

   double Low_Data[];
   ArraySetAsSeries(Low_Data,true);
   CopyLow(_Symbol,PERIOD_CURRENT,0,Num_bars,Low_Data);
   double Low_Pure = (NormalizeDouble((Pri_Info[ArrayMinimum(Low_Data,0,Num_bars)].low),Digits()))/_Point;

   double   Profit   =  NormalizeDouble((Hig_Pure-Low_Pure-(2*Spr_Pure)),2);
   double   Growth   =  NormalizeDouble(((Atr_Pure/Spr_Pure)-1),2);

   Comment("Profit="+Profit+","+"Growth="+Growth+","+"Bars="+Num_bars+","+"ATR="+Atr_Pure+","+"Spread="+Spr_Pure+","+"High="+Hig_Pure+","+"Low="+Low_Pure);
   Print("Profit="+Profit+","+"Growth="+Growth+","+"Bars="+Num_bars+","+"ATR="+Atr_Pure+","+"Spread="+Spr_Pure+","+"High="+Hig_Pure+","+"Low="+Low_Pure);
  }
Files:
Over-View.mq5  2 kb
 
Simply use OrderCalcProfit().
Documentation on MQL5: Trade Functions / OrderCalcProfit
Documentation on MQL5: Trade Functions / OrderCalcProfit
  • www.mql5.com
OrderCalcProfit - Trade Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: