Może ktoś zerknąć na poniższy kod? Otóż, chciałem go przerobić i podstawić zamiast TipuCCI, wskaźnik od Clusterdelta i zrobić skumulowaną deltę. Problem w tym, że nie jestem programistą i prośba czy ktoś mógłby mnie nakierować. Otóż chciałem funkcję iCustom zamienić "ClusterDelta_#Delta...", i zostaje jeszcze przerobienie obszaru "Tipu indicator parameters"? Czy mógłbym całkowicie tą sekcję wywalić i wrzucić funkcję icustom z cluserdelta?
Kod: Zaznacz cały
//+------------------------------------------------------------------+
//| WeisWaveTipuCCI.mq4 |
//| Copyright 2023, Sergey Shevchenko |
//| https://www.mql5.com/ru/users/baromix |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, Sergey Shevchenko"
#property link "https://www.mql5.com/ru/users/baromix"
#property version "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_type1 DRAW_HISTOGRAM
#property indicator_color1 clrGreen
#property indicator_width1 3
#property indicator_type2 DRAW_HISTOGRAM
#property indicator_color2 clrRed
#property indicator_width2 3
enum ENUM_SignalMark
{
None=0,
Arrows=1,
VLine=2,
};
input int bars_calc = 500; //Bars to calculate
input string str1 = "";//---- ZigZag indicator parameters
input int InpDepth=12; // Depth
input int InpDeviation=5; // Deviation
input int InpBackstep=3; // Backstep
input string str2 = "";//---- Tipu indicator parameters
input string sCCISettings="---CCI Settings"; //CCI Settings
input int iCCI_Period=14; //CCI Period
input ENUM_APPLIED_PRICE eAppliedPrice=PRICE_TYPICAL; //Applied Price
input int iCCI_OB = 0; //Overbought
input int iCCI_OS = 0; //Oversold
input string sSignalType="----Signal Types--"; //Signal Types
input ENUM_SignalMark eMarkSignals=1; //Mark Buy/Sell Signals
input int iAOffset=5; //Arrow offset (pips)
input color cUpCandle = C'31,159,192'; //Up Color
input color cDwnCandle = C'230,77,69'; //Down Color
input string sAlert0="---Buy/Sell Global Alert Settings----------"; //Alert Settings
input bool bAlertBuy = true; //Alert Buy?
input bool bAlertSell = true; //Alert Sell?
input int iAlertShift = 1; //Alert Shift
input bool bAlertM = false; //Alert Mobile
input bool bAlertS=true; //Alert Onscreen
input bool bAlertE=false; //Alert Email
double buf_up[],buf_dn[];
static datetime Old_Time=Time[0];
bool IsNewBar=true;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
IndicatorBuffers(2);
SetIndexBuffer(0,buf_up,INDICATOR_DATA);
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3,clrGreen);
SetIndexBuffer(1,buf_dn,INDICATOR_DATA);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,3,clrRed);
ArraySetAsSeries(buf_up,true);
ArraySetAsSeries(buf_dn,true);
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
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[])
{
//---
IsNewBar=false;
if(Old_Time!=iTime(_Symbol,PERIOD_CURRENT,0))
{
IsNewBar=true;
Old_Time=iTime(_Symbol,PERIOD_CURRENT,0);
};
double _zig[];
double tipu_up[],tipu_dn[];
ArrayResize(buf_up,rates_total);
ArrayResize(_zig,rates_total);
ArrayResize(tipu_up,rates_total);
ArrayResize(tipu_dn,rates_total);
ArrayInitialize(_zig,0);
int start_pos=0;
for(int i=0; i<bars_calc-1; i++)
{
_zig[i]=iCustom(_Symbol,PERIOD_CURRENT,"ZigZag",InpDepth,InpDeviation,InpBackstep,0,i);
tipu_up[i]=iCustom(_Symbol,PERIOD_CURRENT,"Tipu_CCI",sCCISettings,iCCI_Period,eAppliedPrice,iCCI_OB,iCCI_OS,sSignalType,eMarkSignals,iAOffset,
cUpCandle,cDwnCandle,sAlert0,bAlertBuy,bAlertSell,iAlertShift,bAlertM,bAlertS,bAlertE,0,i);
tipu_dn[i]=iCustom(_Symbol,PERIOD_CURRENT,"Tipu_CCI",sCCISettings,iCCI_Period,eAppliedPrice,iCCI_OB,iCCI_OS,sSignalType,eMarkSignals,iAOffset,
cUpCandle,cDwnCandle,sAlert0,bAlertBuy,bAlertSell,iAlertShift,bAlertM,bAlertS,bAlertE,1,i);
};
for(int i=bars_calc-100; i>0; i--)
{
double sum=0.0;
if(_zig[i]!=0 && _zig[i]!=EMPTY_VALUE)
{
int j=i-1;
while((_zig[j]==0 || _zig[j]==EMPTY_VALUE) && j>0)
{
if(tipu_up[j]!=EMPTY_VALUE)
sum=sum+tipu_up[j];
if(tipu_dn[j]!=EMPTY_VALUE)
sum=sum+tipu_dn[j];
if(sum>0)
buf_up[j]=sum;
if(sum<0)
buf_dn[j]=sum;
j--;
};
if(tipu_up[j]!=EMPTY_VALUE)
sum=sum+tipu_up[j];
if(tipu_dn[j]!=EMPTY_VALUE)
sum=sum+tipu_dn[j];
if(sum>0)
buf_up[j]=sum;
if(sum<0)
buf_dn[j]=sum;
i=j+1;
};
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+