Start working with "#property strict"

To add comments, please log in or register
Thierry Ramaniraka
542
Thierry Ramaniraka  
Heelo,
I want to start working with "#property strict".

I found this usefull idndicator on forex factory.
When i put "#property strict", i get some warnings.

What is the problem ?
//+------------------------------------------------------------------+
//|                                                  mn OHLC Data    +                
//+------------------------------------------------------------------+

#property indicator_chart_window
#property copyright "mn"

//#property strict

extern int  mFirstPrdCheck = 1,
            mBarsToCheck   = 2;
extern bool mPlotOC = true, 
            mPlotHL = true, 
            mPlotm1 = false, 
            mPlotm5 = false, 
            mPlotm15 = false, 
            mPlotm60 = false, 
            mPlotm240 = false, 
            mPlotm1440 = false, 
            mPlotm10080 = true, 
            mPlotm43200 = false;
extern color mCol1 = White, mCol2 = Red, mCol3 = Blue, mCol4 = Aqua,  mCol5 = Gold;            
extern int mWidth = 1;
            
double m1[][6], m5[][6], m15[][6], m60[][6], m240[][6], m1440[][6], m10080[][6], m43200[][6],
       m1_0p, m1_High, m1_Low, m1_Close,
       m5_0p, m5_High, m5_Low, m5_Close,
       m15_0p, m15_High, m15_Low, m15_Close,
       m60_0p, m60_High, m60_Low, m60_Close,
       m240_0p, m240_High, m240_Low, m240_Close,
       m1440_0p, m1440_High, m1440_Low, m1440_Close,
       m10080_0p, m10080_High, m10080_Low, m10080_Close,
       m43200_0p, m43200_High, m43200_Low, m43200_Close;
   
int init()
  {
  
   return(0);
  }
  
//-------------------------------------------------------- 
  
int deinit()
  {
   DeleteObjects();

   return(0);
  }
//--------------------------------------------------------- 

int start()
 {

  ArrayCopyRates(m1, Symbol(), 1);
  ArrayCopyRates(m5, Symbol(), 5);
  ArrayCopyRates(m15, Symbol(), 15);
  ArrayCopyRates(m240, Symbol(), 240);
  ArrayCopyRates(m1440, Symbol(), 1440);
  ArrayCopyRates(m10080, Symbol(), 10080);
  ArrayCopyRates(m43200, Symbol(), 43200);

  for(int i = mFirstPrdCheck; i < (mBarsToCheck + mFirstPrdCheck); i++)
    {
     m1_0p    = m1[i][1];
     m1_High  = m1[i][3];
     m1_Low   = m1[i][2];
     m1_Close = m1[i][4];

     m5_0p    = m5[i][1];
     m5_High  = m5[i][3];
     m5_Low   = m5[i][2];
     m5_Close = m5[i][4];

     m15_0p    = m15[i][1];
     m15_High  = m15[i][3];
     m15_Low   = m15[i][2];
     m15_Close = m15[i][4];

     m60_0p    = m60[i][1];
     m60_High  = m60[i][3];
     m60_Low   = m60[i][2];
     m60_Close = m60[i][4];

     m240_0p    = m240[i][1];
     m240_High  = m240[i][3];
     m240_Low   = m240[i][2];
     m240_Close = m240[i][4];

     m1440_0p    = m1440[i][1];
     m1440_High  = m1440[i][3];
     m1440_Low   = m1440[i][2];
     m1440_Close = m1440[i][4];

     m10080_0p    = m10080[i][1];
     m10080_High  = m10080[i][3];
     m10080_Low   = m10080[i][2];
     m10080_Close = m10080[i][4];
 
     m43200_0p    = m43200[i][1];
     m43200_High  = m43200[i][3];
     m43200_Low   = m43200[i][2];
     m43200_Close = m43200[i][4];
     
     mPlotLines(i);
    }

   return(0);
}

//--------------------------------------------------------
void mPlotLines(int j)
 {
 // DeleteObjects();
 // for(int j = 0; j < mBarsToCheck; j++)
    {
     if(mPlotm1)
      {
        if(mPlotOC)
         {
          ObjectCreate("mLinem1_Op"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem1_Op"+j, OBJPROP_PRICE1, m1_0p);
          ObjectSet("mLinem1_Op"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem1_Op"+j, OBJPROP_WIDTH, mWidth);
          ObjectCreate("mLinem1_Close"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem1_Close"+j, OBJPROP_PRICE1, m1_Close);
          ObjectSet("mLinem1_Close"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem1_Close"+j, OBJPROP_WIDTH, mWidth);
         }
        if(mPlotHL)
         {
          ObjectCreate("mLinem1_High"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem1_High"+j, OBJPROP_PRICE1, m1_High);
          ObjectSet("mLinem1_High"+j, OBJPROP_COLOR, mCol3);
          ObjectSet("mLinem1_High"+j, OBJPROP_WIDTH, mWidth);
          ObjectCreate("mLinem1_Low"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem1_Low"+j, OBJPROP_PRICE1, m1_Low);
          ObjectSet("mLinem1_Low"+j, OBJPROP_COLOR, mCol2);
          ObjectSet("mLinem1_Low"+j, OBJPROP_WIDTH, mWidth);
         }
      }
     
     if(mPlotm5)
      {
        if(mPlotOC)
         {
          ObjectCreate("mLinem5_Op"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem5_Op"+j, OBJPROP_PRICE1, m5_0p);
          ObjectSet("mLinem5_Op"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem5_Op"+j, OBJPROP_WIDTH, mWidth);
          ObjectCreate("mLinem5_Close"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem5_Close"+j, OBJPROP_PRICE1, m5_Close);
          ObjectSet("mLinem5_Close"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem5_Close"+j, OBJPROP_WIDTH, mWidth);
         }
        if(mPlotHL)
         {
          ObjectCreate("mLinem5_High"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem5_High"+j, OBJPROP_PRICE1, m5_High);
          ObjectSet("mLinem5_High"+j, OBJPROP_COLOR, mCol3);
          ObjectSet("mLinem5_High"+j, OBJPROP_WIDTH, mWidth);
          ObjectCreate("mLinem5_Low"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem5_Low"+j, OBJPROP_PRICE1, m5_Low);
          ObjectSet("mLinem5_Low"+j, OBJPROP_COLOR, mCol2);
          ObjectSet("mLinem1_Low"+j, OBJPROP_WIDTH, mWidth);
         }
      }

     if(mPlotm15)
      {
        if(mPlotOC)
         {
          ObjectCreate("mLinem15_Op"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem15_Op"+j, OBJPROP_PRICE1, m15_0p);
          ObjectSet("mLinem15_Op"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem15_Op"+j, OBJPROP_WIDTH, mWidth);
          ObjectCreate("mLinem15_Close"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem15_Close"+j, OBJPROP_PRICE1, m15_Close);
          ObjectSet("mLinem15_Close"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem15_Close"+j, OBJPROP_WIDTH, mWidth);
         }
        if(mPlotHL)
         {
          ObjectCreate("mLinem15_High"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem15_High"+j, OBJPROP_PRICE1, m15_High);
          ObjectSet("mLinem15_High"+j, OBJPROP_COLOR, mCol3);
          ObjectSet("mLinem15_High"+j, OBJPROP_WIDTH, mWidth);
          ObjectCreate("mLinem15_Low"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem15_Low"+j, OBJPROP_PRICE1, m15_Low);
          ObjectSet("mLinem15_Low"+j, OBJPROP_COLOR, mCol2);
          ObjectSet("mLinem15_Low"+j, OBJPROP_WIDTH, mWidth);
         }
      }

     if(mPlotm60)
      {
        if(mPlotOC)
         {
          ObjectCreate("mLinem60_Op"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem60_Op"+j, OBJPROP_PRICE1, m60_0p);
          ObjectSet("mLinem60_Op"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem60_Op"+j, OBJPROP_WIDTH, mWidth);
          ObjectCreate("mLinem60_Close"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem60_Close"+j, OBJPROP_PRICE1, m60_Close);
          ObjectSet("mLinem60_Close"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem60_Close"+j, OBJPROP_WIDTH, mWidth);
         }
        if(mPlotHL)
         {
          ObjectCreate("mLinem60_High"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem60_High"+j, OBJPROP_PRICE1, m60_High);
          ObjectSet("mLinem60_High"+j, OBJPROP_COLOR, mCol3);
          ObjectSet("mLinem60_High"+j, OBJPROP_WIDTH, mWidth);
          ObjectCreate("mLinem60_Low"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem60_Low"+j, OBJPROP_PRICE1, m60_Low);
          ObjectSet("mLinem60_Low"+j, OBJPROP_COLOR, mCol2);
          ObjectSet("mLinem60_Low"+j, OBJPROP_WIDTH, mWidth);
         }
      }

     if(mPlotm240)
      {
        if(mPlotOC)
         {
          ObjectCreate("mLinem240_Op"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem240_Op"+j, OBJPROP_PRICE1, m240_0p);
          ObjectSet("mLinem240_Op"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem240_Op"+j, OBJPROP_WIDTH, mWidth);
          ObjectCreate("mLinem240_Close"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem240_Close"+j, OBJPROP_PRICE1, m240_Close);
          ObjectSet("mLinem240_Close"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem240_Close"+j, OBJPROP_WIDTH, mWidth);
         }
        if(mPlotHL)
         {
          ObjectCreate("mLinem240_High"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem240_High"+j, OBJPROP_PRICE1, m240_High);
          ObjectSet("mLinem240_High"+j, OBJPROP_COLOR, mCol3);
          ObjectSet("mLinem240_High"+j, OBJPROP_WIDTH, mWidth);
          ObjectCreate("mLinem240_Low"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem240_Low"+j, OBJPROP_PRICE1, m240_Low);
          ObjectSet("mLinem240_Low"+j, OBJPROP_COLOR, mCol2);
          ObjectSet("mLinem240_Low"+j, OBJPROP_WIDTH, mWidth);
         }
      }

     if(mPlotm1440)
      {
        if(mPlotOC)
         {
          ObjectCreate("mLinem1440_Op"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem1440_Op"+j, OBJPROP_PRICE1, m1440_0p);
          ObjectSet("mLinem1440_Op"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem1440_Op"+j, OBJPROP_WIDTH, mWidth);
          ObjectCreate("mLinem1440_Close"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem1440_Close"+j, OBJPROP_PRICE1, m1440_Close);
          ObjectSet("mLinem1440_Close"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem1440_Close"+j, OBJPROP_WIDTH, mWidth);
         }
        if(mPlotHL)
         {
          ObjectCreate("mLinem1440_High"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem1440_High"+j, OBJPROP_PRICE1, m1440_High);
          ObjectSet("mLinem1440_High"+j, OBJPROP_COLOR, mCol3);
          ObjectSet("mLinem1440_High"+j, OBJPROP_WIDTH, mWidth);
          ObjectCreate("mLinem1440_Low"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem1440_Low"+j, OBJPROP_PRICE1, m1440_Low);
          ObjectSet("mLinem1440_Low"+j, OBJPROP_COLOR, mCol2);
          ObjectSet("mLinem1440_Low"+j, OBJPROP_WIDTH, mWidth);
         }
      }

     if(mPlotm10080)
      {
        if(mPlotOC)
         {
          ObjectCreate("mLinem10080_Op"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem10080_Op"+j, OBJPROP_PRICE1, m10080_0p);
          ObjectSet("mLinem10080_Op"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem10080_Op"+j, OBJPROP_WIDTH, mWidth+1);
          ObjectCreate("mLinem10080_Close"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem10080_Close"+j, OBJPROP_PRICE1, m10080_Close);
          ObjectSet("mLinem10080_Close"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem10080_Close"+j, OBJPROP_WIDTH, mWidth+1);
         }
        if(mPlotHL)
         {
          ObjectCreate("mLinem10080_High"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem10080_High"+j, OBJPROP_PRICE1, m10080_High);
          ObjectSet("mLinem10080_High"+j, OBJPROP_COLOR, mCol3);
          ObjectSet("mLinem10080_High"+j, OBJPROP_WIDTH, mWidth+1);
          ObjectCreate("mLinem10080_Low"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem10080_Low"+j, OBJPROP_PRICE1, m10080_Low);
          ObjectSet("mLinem10080_Low"+j, OBJPROP_COLOR, mCol2);
          ObjectSet("mLinem10080_Low"+j, OBJPROP_WIDTH, mWidth+1);
         }
      }

     if(mPlotm43200)
      {
        if(mPlotOC)
         {
          ObjectCreate("mLinem43200_Op"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem43200_Op"+j, OBJPROP_PRICE1, m43200_0p);
          ObjectSet("mLinem43200_Op"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem43200_Op"+j, OBJPROP_WIDTH, mWidth+2);
          ObjectCreate("mLinem43200_Close"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem43200_Close"+j, OBJPROP_PRICE1, m43200_Close);
          ObjectSet("mLinem43200_Close"+j, OBJPROP_COLOR, mCol1);
          ObjectSet("mLinem43200_Close"+j, OBJPROP_WIDTH, mWidth+2);
         }
        if(mPlotHL)
         {
          ObjectCreate("mLinem43200_High"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem43200_High"+j, OBJPROP_PRICE1, m43200_High);
          ObjectSet("mLinem43200_High"+j, OBJPROP_COLOR, mCol4);
          ObjectSet("mLinem43200_High"+j, OBJPROP_WIDTH, mWidth+2);
          ObjectCreate("mLinem43200_Low"+j, OBJ_HLINE, 0, 0, 0, 0);
          ObjectSet("mLinem43200_Low"+j, OBJPROP_PRICE1, m43200_Low);
          ObjectSet("mLinem43200_Low"+j, OBJPROP_COLOR, mCol5);
          ObjectSet("mLinem43200_Low"+j, OBJPROP_WIDTH, mWidth+2);
         }
      }
    } // for j
     
   return(0);
 }
 
//--------------------------------------------------------
void DeleteObjects()
 {
   string mObj;
   for(int m = ObjectsTotal()-1; m >= 0; m--)
    {
      mObj = ObjectName(m);
      if (StringFind(mObj,"mLinem", 0) > -1)
       ObjectDelete(mObj);
    }
  }
//+------------------------------------------------------------------+

Thank you for your help.
Regards.
Naguisa Unada
524
Naguisa Unada  

Line 325.

//return(0);  //delete

Line 120 ~ Line 320.

ObjectCreate("mLinem1_Op"+(string)j, OBJ_HLINE, 0, 0, 0, 0);  //j -> (string)j

Insert this one in Line 57.

ArrayCopyRates(m60, Symbol(), 60);
Thierry Ramaniraka
542
Thierry Ramaniraka  
Naguisa Unada:

Line 325.

Line 120 ~ Line 320.

Insert this one in Line 57.

It is PERFECT.
I don't understand all, but it morks.
Thank you very very much.

Thierry Ramaniraka
542
Thierry Ramaniraka  
In the same subject, I have this code, that i get from here https://www.mql5.com/en/forum/233876
int           time2                      =Time[0]+(Datas_BarShift_Time-1)*PeriodSeconds();
And It returns this warning


Can you please tell me what is wrong in this case ?
Vline 50 bars after the current time/bar
Vline 50 bars after the current time/bar
  • 2018.03.31
  • www.mql5.com
Hi there, I come to you to ask you : How can i draw a VLINE on the 50th (or Xth) bar in the future...
Naguisa Unada
524
Naguisa Unada  
datetime time2 = Time[0]+(Datas_BarShift_Time-1)*PeriodSeconds();

OR

int time2 = (int)Time[0]+(Datas_BarShift_Time-1)*PeriodSeconds();

Maybe los dos bring you same result.

Thierry Ramaniraka
542
Thierry Ramaniraka  
Naguisa Unada:

Maybe los dos bring you same result.

Ok, i begin to understand...
Thank you.

I tried your 2 solutions, both of them work fine.
Wich one is the best CPU calculation ?

Naguisa Unada
524
Naguisa Unada  

I don't think that it's necessary to consider it.

I usually adopt "datetime".

William Roeder
20210
William Roeder  
Thierry Ramaniraka: Can you please tell me what is wrong in this case ?
  1. Don't hijack other people's threads with your off topic post. Open your own.

  2. Don't double post!
              General rules and best pratices of the Forum. - General - MQL5 programming forum
Thierry Ramaniraka
542
Thierry Ramaniraka  
whroeder1:
  1. Don't hijack other people's threads with your off topic post. Open your own.

  2. Don't double post!
              General rules and best pratices of the Forum. - General - MQL5 programming forum

Hello,
I didn't intended such bad things. It was just a corelation on both thread.

https://www.mql5.com/en/forum/233876/unread#unread

https://www.mql5.com/en/forum/235106/unread#unread

Regards

Vline 50 bars after the current time/bar
Vline 50 bars after the current time/bar
  • 2018.03.31
  • www.mql5.com
Hi there, I come to you to ask you : How can i draw a VLINE on the 50th (or Xth) bar in the future...
Thierry Ramaniraka
542
Thierry Ramaniraka  
Naguisa Unada:

I don't think that it's necessary to consider it.

I usually adopt "datetime".

Ok ,
Thank you again for your appreciated help. : )

To add comments, please log in or register