iCustom

 

Hey guys first time posting here, so I've found an indicator which i like that i wanted to use on my expert advisor. When i use the iCustom to bring the indicator onto the chart it works by using -

void OnTick()

{




      int indicator = iCustom (_Symbol,_Period,"donchian_channels");


 }


simple enough, however im stuck as to getting the values for the 3 bands, im not sure whether i should be using the copybuffer to give the arrays that are on the original script a value or...@?

completely hit a wall here guys so any help would be useful, been at this for a while and adding custom indicators is the final step to having what i need going, for referance the indicator that im using for the bands is here:


https://www.mql5.com/en/code/402


Its a great indicator and is exactly how the original indicator works. I really need help getting the values of the 3 bands, thanks guys!


Full Code Here for my MA's Macd etc


#property description "Operation Automation V1"

#include<Trade\Trade.mqh>


   // Create an instance of CTrade

   CTrade trade;

   

   

input int MA1=1;

input int MA3=3;

input int MA5=5;         

input int MA8=8;

input int MA14=14;

input int MA30=30;

input int MA50=200;

input int MA100=100;

input int MA200=200;


void OnTick()

{

            

       //  Ask price

      double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);                 

      //   Bid price

      double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);

            //Get Account Equity

      double Balance=AccountInfoDouble(ACCOUNT_MARGIN_FREE);

      double Equity=AccountInfoDouble(ACCOUNT_EQUITY);      

      // Set Position Size Dynamically

      double DynamicPositionSize=NormalizeDouble((Equity/15000),2);      

         //create an Array for several prices

      MqlRates PriceInfo[];

      ArraySetAsSeries (PriceInfo,true);

         // Strings for Various Signals 

      string signal=""; 

      string bias1h="";         

         

         double MA1Array[],MA3Array[],MA5Array[],MA8Array[],MA14Array[],MA30Array[],MA50Array[],MA100Array[],MA200Array[],PriceArray[];


      int MacDDefinition = iMACD(_Symbol,_Period,12,26,9,PRICE_CLOSE);

      int DonchianChannels = iCustom (_Symbol,_Period,"donchian_channels");   

      int MA1Definition = iMA (_Symbol,_Period,MA1,0,MODE_EMA,PRICE_CLOSE);

      int MA3Definition = iMA (_Symbol,_Period,MA3,0,MODE_EMA,PRICE_CLOSE);

      int MA5Definition = iMA (_Symbol,_Period,MA5,0,MODE_EMA,PRICE_CLOSE);

      int MA8Definition = iMA (_Symbol,_Period,MA8,0,MODE_EMA,PRICE_CLOSE);

      int MA14Definition = iMA (_Symbol,_Period,MA14,0,MODE_EMA,PRICE_CLOSE);

      int MA30Definition = iMA (_Symbol,_Period,MA30,0,MODE_EMA,PRICE_CLOSE);

      int MA50Definition = iMA (_Symbol,_Period,MA50,0,MODE_EMA,PRICE_CLOSE);

      int MA100Definition = iMA (_Symbol,_Period,MA100,0,MODE_EMA,PRICE_CLOSE);

      int MA200Definition = iMA (_Symbol,_Period,MA200,0,MODE_EMA,PRICE_CLOSE);

         

         ArraySetAsSeries(PriceArray,true); // MACD         

         ArraySetAsSeries(MA1Array,true);

         ArraySetAsSeries(MA3Array,true);

         ArraySetAsSeries(MA5Array,true);

         ArraySetAsSeries(MA8Array,true);

         ArraySetAsSeries(MA14Array,true);

         ArraySetAsSeries(MA30Array,true);

         ArraySetAsSeries(MA50Array,true);

         ArraySetAsSeries(MA100Array,true);

         ArraySetAsSeries(MA200Array,true);

         

         CopyBuffer(MacDDefinition,0,0,3,PriceArray); //MACD

         CopyBuffer(MA1Definition,0,0,5,MA1Array);

         CopyBuffer(MA3Definition,0,0,5,MA3Array);

         CopyBuffer(MA5Definition,0,0,5,MA5Array);

         CopyBuffer(MA8Definition,0,0,5,MA8Array);

         CopyBuffer(MA14Definition,0,0,5,MA14Array);

         CopyBuffer(MA30Definition,0,0,5,MA30Array);

         CopyBuffer(MA50Definition,0,0,5,MA50Array);

         CopyBuffer(MA100Definition,0,0,5,MA100Array);

         CopyBuffer(MA200Definition,0,0,5,MA200Array);

         

         double LastMacDValue=(PriceArray[1]);

         double MacDV=(PriceArray[0]); //MACD

         

         double MA1Value=MA1Array[0];

         double MA3Value=MA3Array[0];

         double MA5Value=MA5Array[0];

         double MA8Value=MA8Array[0];

         double MA14Value=MA14Array[0];

         double MA30Value=MA30Array[0];

         double MA50Value=MA50Array[0];

         double MA100Value=MA100Array[0];

         double MA200Value=MA200Array[0];


 }

Donchian Channels
Donchian Channels
  • www.mql5.com
Richard Donchian is a legendary figure in trading. He is often called a founder of the trend following systems. The famous Turtle trading system is based on his works. Donchian came to a serious success when he was in quite an old age already. Despite that, he continued working and proved to be a successful trader showing by his own example...
 

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button

 

Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
          General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
          Messages Editor

Reason: