learning mql5

Enivid

Administrator
Staff member
Nov 30, 2008
19,492
1,593
144
Odesa
www.earnforex.com
hey enivid..... thanks for the reply......

saw both those functions but tried neither.....

was trying the same arraycopy method which has worked without fail before....

the basic code is very simple, we both could write every line of it in our heads..... until volume for me.....

the only difference i can see is ivolume requires a shift where the others do not.....

the indicator sets all the global values for it's symbol and 7 common timeframes......

the dashboard indicator then cycles thru all the global values and displays them....

i will read up on the functions you mentioned.......

my goal is to see the coppock indicator and all others, in a single at a glance screen.....h

//------- using iVolume(_Symbol,tf[j],0) > iVolume(_Symbol,tf[j],1) works

MQL5:
//-------  individual []  arrays declared above
 
 
 for(int i = 0; i < 7; i++)    // 7 timeframes
      {
 
      alma[i]     = iCustom(_Symbol,tf[i],"alma");
      coppock[i]  = iCustom(_Symbol,tf[i],"Coppock");
      hma[i]      = iCustom(_Symbol,tf[i],"hma",20,2.0);
      //schaff[i]   = iCustom(_Symbol,tf[i],"schaff");
      psar[i]     = iSAR(_Symbol,tf[i],0.01,0.2);
      ma10[i]     = iMA(_Symbol,tf[i],10,0,MODE_SMA,PRICE_CLOSE);
      ma20[i]     = iMA(_Symbol,tf[i],20,0,MODE_SMA,PRICE_CLOSE);
      ma50[i]     = iMA(_Symbol,tf[i],50,0,MODE_SMA,PRICE_CLOSE);
      stoch[i]    = iStochastic(_Symbol,tf[i], 10, 3, 6, MODE_SMA, STO_CLOSECLOSE);
      atr[i]      = iATR(_Symbol,tf[i],20);
      ao[i]       = iAO(_Symbol,tf[i]);
      tema[i]     = iTEMA(_Symbol,tf[i],20,0,PRICE_CLOSE);
      dema[i]     = iDEMA(_Symbol,tf[i],20,0,PRICE_CLOSE);
      vol[i]      = iRealVolume(_Symbol,tf[i],0);              // insists on a shift where others do not have tried several versions
      bars        = iBars(_Symbol,tf[i]);
 
      }
 
 
    for(int j = 0; j < 7; j++)  // 7 timeframes
      {
 
        double vols[];
 
        ArraySetAsSeries(vols,true);
 
        CopyBuffer(vol[j],0,0,4,vols);
 
 
        double almas[];
 
        ArraySetAsSeries(almas,true);
 
        CopyBuffer(alma[j],0,0,20,almas);
 
 
        double coppocks[];
 
        ArraySetAsSeries(coppocks,true);
 
        CopyBuffer(coppock[j],0,0,20,coppocks);
 
//----------        repetitive array copy
 
//-----------  global variables set in this manner
 
            if(coppocks[1] > coppocks[2])  { GlobalVariableSet(_Symbol+tfs[j]+"coppock", 10); } 
 
            if(coppocks[1] < coppocks[2])  { GlobalVariableSet(_Symbol+tfs[j]+"coppock",-10); }
 
            if(coppocks[1] > 0)            { GlobalVariableSet(_Symbol+tfs[j]+"coppock0", 10); } 
 
            if(coppocks[1] < 0)            { GlobalVariableSet(_Symbol+tfs[j]+"coppock0",-10); }
 
 
            GlobalVariableSet(_Symbol+tfs[j]+"ahm", 0);
 
            if((hmas[0] > almas[0]) && (almas[0] > ma10s[0]) && (ma10s[0] > ma20s[0]))  {GlobalVariableSet(_Symbol+tfs[j]+"ahm", 10); }
 
            if((hmas[0] < almas[0]) && (almas[0] < ma10s[0]) && (ma10s[0] < ma20s[0]))  {GlobalVariableSet(_Symbol+tfs[j]+"ahm",-10); }
 
 
            //if( !((almas[1] > almas[2]) && (hmas[1] > hmas[2]) && (coppocks[1] > coppocks[2])) && !((almas[1] < almas[2]) && (hmas[1] < hmas[2]) && (coppocks[1] < coppocks[2])))   {clr[j] = clrYellow;  GlobalVariableSet(_Symbol+tfs[j],0);}
 
 
            if(aos[0] >  aos[1])  {GlobalVariableSet(_Symbol+tfs[j]+"ao",  10); }
 
            if(aos[0] <= aos[1])  {GlobalVariableSet(_Symbol+tfs[j]+"ao", -10); }
 
 
            if(temas[0] >  temas[1])  {GlobalVariableSet(_Symbol+tfs[j]+"tema",  10); }
 
            if(temas[0] <= temas[1])  {GlobalVariableSet(_Symbol+tfs[j]+"tema", -10); }
 
 
            if(demas[0] >  demas[1])  {GlobalVariableSet(_Symbol+tfs[j]+"dema",  10); }
 
            if(demas[0] <= demas[1])  {GlobalVariableSet(_Symbol+tfs[j]+"dema", -10); }
 
            //
            if(iVolume(_Symbol,tf[j],0) >  iVolume(_Symbol,tf[j],1))  {GlobalVariableSet(_Symbol+tfs[j]+"volume",  10); } // can't get arraycopy to work..... this does.....
 
            if(iVolume(_Symbol,tf[j],0) <  iVolume(_Symbol,tf[j],1))  {GlobalVariableSet(_Symbol+tfs[j]+"volume", -10); }
 
//------

//------

View attachment 31854
You think that iRealVolume() and iVolume() are indicator functions (like iMA()), but they aren't. They are access functions, like iHigh() and iLow(). That's why you cannot copy any buffers from them.
 

hayseed

Master Trader
Jul 27, 2010
1,220
287
149
usa
.....h
//----
 

Attachments

  • mql5book.pdf
    13.6 MB · Views: 1
  • Expert Advisor Programming for MetaTrader 5.pdf
    5 MB · Views: 1