How to change that

 

Hello, i have that code. It split CCI value by RSI value. Question is someone know how to change it to split Volume/ATR value?

input int Period1 = 14; // CCI Period
input int Period2 = 14; // RSI Period
input bool Reverse = false; // Reverse

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red

string IndicatorName;
string IndicatorObjPrefix;

string GenerateIndicatorName(const string target)
{
   string name = target;
   int try = 2;
   while (WindowFind(name) != -1)
   {
      name = target + " #" + IntegerToString(try++);
   }
   return name;
}

double Oscillator[];

int init()
{
   IndicatorName = GenerateIndicatorName("RSI CCI Ratio");
   IndicatorObjPrefix = "__" + IndicatorName + "__";
   IndicatorShortName(IndicatorName);

   IndicatorBuffers(1);

   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, Oscillator);
   SetIndexLabel(0, "Oscillator");

   return 0;
}

int deinit()
{
   ObjectsDeleteAll(ChartID(), IndicatorObjPrefix);
   return 0;
}

int start()
{
   int counted_bars = IndicatorCounted();
   int minBars = 1;
   int limit = MathMin(Bars - 1 - minBars, Bars - counted_bars - 1);
   for (int i = limit; i >= 0; i--)
   {
      double cciValue = iCCI(_Symbol, _Period, Period1, PRICE_CLOSE, i);
      double rsiValue = iRSI(_Symbol, _Period, Period2, PRICE_CLOSE, i);
      if (Reverse)
      {
         if (rsiValue != 0)
         {
            Oscillator[i] = cciValue / rsiValue;
         }
      }
      else
      {
         if (cciValue)
         {
            Oscillator[i] = rsiValue / cciValue;
         }
      }
   }
   return 0;
}
 
Łukasz Sajin: Question is someone know how to change it to split Volume/ATR value?
  1. Many do. Do you?
         How To Ask Questions The Smart Way. (2004)
              Only ask questions with yes/no answers if you want “yes” or “no” as the answer.

  2. You haven't stated a problem, you stated even stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help (2017)

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2018)

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
              No free help (2017)

 
Łukasz Sajin:

Hello, i have that code. It split CCI value by RSI value. Question is someone know how to change it to split Volume/ATR value?

input int Period1 = 14; // CCI Period
input int Period2 = 14; // RSI Period
input bool Reverse = false; // Reverse

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
input int AtrPeriod=14;
string IndicatorName;
string IndicatorObjPrefix;

string GenerateIndicatorName(const string target)
{
   string name = target;
   int try = 2;
   while (WindowFind(name) != -1)
   {
      name = target + " #" + IntegerToString(try++);
   }
   return name;
}

double Oscillator[];

int init()
{
   IndicatorName = GenerateIndicatorName("Volume / ATR Ratio");
   IndicatorObjPrefix = "__" + IndicatorName + "__";
   IndicatorShortName(IndicatorName);

   IndicatorBuffers(1);

   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, Oscillator);
   SetIndexLabel(0, "Oscillator");
  IndicatorDigits(8);

   return 0;
}

int deinit()
{
   ObjectsDeleteAll(ChartID(), IndicatorObjPrefix);
   return 0;
}

int start()
{
   int counted_bars = IndicatorCounted();
   int minBars = 1;
   int limit = MathMin(Bars - 1 - minBars, Bars - counted_bars - 1);
   for (int i = limit; i >= 0; i--)
   {
   
    //  double cciValue = iCCI(_Symbol, _Period, Period1, PRICE_CLOSE, i);
    //  double rsiValue = iRSI(_Symbol, _Period, Period2, PRICE_CLOSE, i);
      double cciValue =  iVolume(_Symbol,_Period,i);
      double rsiValue = iATR(_Symbol, _Period, AtrPeriod,i);
      if (Reverse)
      {
         if (rsiValue != 0)
         {
            Oscillator[i] = cciValue / rsiValue;
         }
      }
      else
      {
         if (cciValue)
         {
            Oscillator[i] = rsiValue / cciValue;
         }
      }
   }
   return 0;
}
Reason: