calculate DT oscillator

To add comments, please log in or register
babigaf
42
babigaf  

Hi fellow traders

I have seen this indicator Mladen RakicDT Oscillator

I already tried iCustome function to calculate the required parameters but when I want to ask parameters of two different time periods, my computer freezes.

so I wanted to know if it is possible to calculate them in my own expert? and if I tend to do so, how can I do that?

any hint and help would be so much appreciated.

thanks

Mladen Rakic
135806
Mladen Rakic  

Check your code

Nothing wrong with that indicator. Here is a short test example :

#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots   0

input ENUM_TIMEFRAMES inpPeriod1 = PERIOD_CURRENT;
input ENUM_TIMEFRAMES inpPeriod2 = PERIOD_D1;

int _handle1,_handle2;
//------------------------------------------------------------------
//
//------------------------------------------------------------------
int OnInit()
{
   _handle1 = iCustom(_Symbol,inpPeriod1,"dt_oscillator"); if (_handle1==INVALID_HANDLE) return(INIT_FAILED);
   _handle2 = iCustom(_Symbol,inpPeriod2,"dt_oscillator"); if (_handle2==INVALID_HANDLE) return(INIT_FAILED);
   return(0);
}
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[])
{
   double _val1[]; int _val1Copied = CopyBuffer(_handle1,0,0,1,_val1);
   double _val2[]; int _val2Copied = CopyBuffer(_handle2,0,0,1,_val2);
   
      if (_val1Copied==1 && _val2Copied==1)
         Comment(_val1[0],"    ",_val2[0]);
   return(rates_total);
}
William Roeder
18658
William Roeder  
babigaf: I already tried iCustome function
  1. Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.

  2. Just get the value(s) of the indicator(s) into the EA (using iCustom) and do what you want with it.
    You should encapsulate your iCustom calls to make your code self-documenting.
              Detailed explanation of iCustom - MQL4 and MetaTrader 4 - MQL4 programming forum

babigaf
42
babigaf  
William Roeder:
  1. Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.

  2. Just get the value(s) of the indicator(s) into the EA (using iCustom) and do what you want with it.
    You should encapsulate your iCustom calls to make your code self-documenting.
              Detailed explanation of iCustom - MQL4 and MetaTrader 4 - MQL4 programming forum

lol william. I was counting on your crystal balls.

sorry I guess I couldn't ask my question properly. I wanted to know it is possible to calculate the parameters in my own expert.

I wanted to know how the DT oscillator is calculated. so calculate it in my own expert.

I think I know how to use iCustom because I already have used it in my old experts but with other indicators. this one is so complicated and with so much bars that the computer freezes whenever I tend to get a back test when I use the indicator. so I though if I could get the formula of DT oscillator and calculate it in my own expert I wouldn'd have the same problem.

babigaf
42
babigaf  
Mladen Rakic:

Check your code

Nothing wrong with that indicator. Here is a short test example :

yeah malden. thanks for your attention and I know the code works by itself and even when I use it in only one time frame it has no problem running the code.

but when I try to use it in two different time frames, I get the same issue. my computer freezes. 

so I thought if it is possible to know how the DT oscillator calculates so I could calculates it in my own expert. I needed the formula of the DT oscillator. 

I need to add that I am not a good programmer and the indicator code has written in so excellent manner that I can not understand how it calculates the main and signal ones.

do you think you can translate it so that I can calculate the main and signal oscillator in my own expert adviser? 

babigaf
42
babigaf  
babigaf:

lol william. I was counting on your crystal balls.

sorry I guess I couldn't ask my question properly. I wanted to know it is possible to calculate the parameters in my own expert.

I wanted to know how the DT oscillator is calculated. so calculate it in my own expert.

I think I know how to use iCustom because I already have used it in my old experts but with other indicators. this one is so complicated and with so much bars that the computer freezes whenever I tend to get a back test when I use the indicator. so I though if I could get the formula of DT oscillator and calculate it in my own expert I wouldn'd have the same problem.

void OnTick()
  {
//---
   int p,o;
   string OrdSymbol;
   static string posiSymbol,ordSymbol,symbol,cmnt,posiComment;
   ulong posiTicket,posiStat;
   static double ask,bid,stpls,tkprf,dista,spread;
   static int posiTotal,ordTotal;
      double
   main[],
   sign[],
   mainM15[],
   signM15[];
   
      bool
   BB=false,
   BS=false,
   SB=false,
   SS=false;
   
   
   
   ArraySetAsSeries(main,   true);
   ArraySetAsSeries(sign,   true);
   ArraySetAsSeries(mainM15,true);
   ArraySetAsSeries(signM15,true);
   
   int handle    = iCustom(_Symbol,PERIOD_H1 ,"dt_oscillator",13,8,5,5,true);
   int handleM15 = iCustom(_Symbol,PERIOD_M15,"dt_oscillator",13,8,5,3,true);
   
   
   
   CopyBuffer(handle,0,0,3,main);
   CopyBuffer(handle,1,0,3,sign);
   CopyBuffer(handleM15,0,0,3,mainM15);
   CopyBuffer(handleM15,1,0,3,signM15);
   
   double H1main0=main[0];
   double H1sign0=sign[0];
   double M15main0=mainM15[0];
   double M15sign0=signM15[0];
   double M15main1=mainM15[1];
   double M15sign1=signM15[1];
}

you tell me if there is any wrong doing in my code please.

babigaf
42
babigaf  
babigaf:

you tell me if there is any wrong doing in my code please.

opening new indicator windows

OMG guess I found the leak!!!
in every thick it opens one new indicator windows. do you think you can see what's wrong with my code that it goes like this?

Keith Watford
Moderator
16517
Keith Watford  
babigaf:

Do not double post.

Your other topic has been deleted.

Mladen Rakic
135806
Mladen Rakic  
babigaf:

yeah malden. thanks for your attention and I know the code works by itself and even when I use it in only one time frame it has no problem running the code.

but when I try to use it in two different time frames, I get the same issue. my computer freezes. 

so I thought if it is possible to know how the DT oscillator calculates so I could calculates it in my own expert. I needed the formula of the DT oscillator. 

I need to add that I am not a good programmer and the indicator code has written in so excellent manner that I can not understand how it calculates the main and signal ones.

do you think you can translate it so that I can calculate the main and signal oscillator in my own expert adviser? 

That example is using dt oscillator from two time frames and is not causing any issue at all

As of formula : you have the code of it, you can see how it is calculated

babigaf
42
babigaf  
Mladen Rakic:

That example is using dt oscillator from two time frames and is not causing any issue at all

As of formula : you have the code of it, you can see how it is calculated

double dtosc[];
double dtoss[];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   SetIndexBuffer( 0,dtosc ,INDICATOR_DATA);
   SetIndexBuffer( 1,dtoss ,INDICATOR_DATA);
   
   
   
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+

double rsibuf[];
double stobuf[];


void OnTick()
  {
   double H1main,H1sign,M15main0,M15sign0,M15main1,M15sign1;
   
   
      bool
   BB=false,
   BS=false,
   SB=false,
   SS=false;
   
   H1main=iDtsto1Hour(0);
   H1sign=iDtsto1Hour(1);
   M15main0=iDtsto15minute(0,0);
   M15sign0=iDtsto15minute(1,0);
   M15main1=iDtsto15minute(0,1);
   M15sign1=iDtsto15minute(1,1);
   
   Comment("main: ",H1main,
           " sign: ",H1sign,
           "\n main15: ",M15main0,
           " sign15: ",M15sign0);
   
  }
  

double iDtsto1Hour (int i)
{
   double
   main[];
   
   ArraySetAsSeries(main,   true);
   
   int handle    = iCustom(_Symbol,PERIOD_H1 ,"DTOS",13,8,5,5,true);
   
   CopyBuffer(handle,i,0,3,main);
   
   double H1main0=NormalizeDouble((main[0]),0);
   
   return(H1main0);
   
   IndicatorRelease(handle);
}
double iDtsto15minute (int i, int j)
{
   double
   mainM15[];
   
   ArraySetAsSeries(mainM15,true);
   
   int handleM15 = iCustom(_Symbol,PERIOD_M15,"DTOS",13,8,5,3,true);
   
   CopyBuffer(handleM15,i,0,3,mainM15);
   
   double M15main0=NormalizeDouble((mainM15[j]),0);
   
   return(M15main0);
   
   IndicatorRelease(handleM15);
}
//+------------------------------------------------------------------+

what is wrong by my code then? why when I use it in strategy tester, I end up having 3000 indicator window?


KEENBASE SOFTWARE SOLUTIONS
15887
Nitin Raj  
babigaf:

what is wrong by my code then? why when I use it in strategy tester, I end up having 3000 indicator window?


Call the indicator handle in OnInit() not in OnTick()
12
To add comments, please log in or register