strange issue - while and if issues - page 2

 
William Roeder:

Why? Nothing is changing. Return from OnTick/OnCalculate and wait to be called when something does change.

those functions i tried few years back - not good results... maybe i had no idea how to do it. any good documentation in this respect ? appreciated.
 
Seng Joo Thio:
LOL... I still don't know what you mean by 'doesn't work'... If you seriously want a solution, and if you really don't want to share your code here, feel free to private message me - I'll try to help you figure out what could be wrong. 
the conditions are not applied - while is not looping... ifs are not applied...
 
Seng Joo Thio:
LOL... I still don't know what you mean by 'doesn't work'... If you seriously want a solution, and if you really don't want to share your code here, feel free to private message me - I'll try to help you figure out what could be wrong. 

ok - if i cut this code from my code - things are starting to work... this piece of code is at the end of my own code...   

 

  //////////////////////////////////////////////////////////////////////END OF BUBBLE SORTS ////////////////////////////////////////////////////////////////////

   data = "=========================================================AVERAGE TREND=========AVERAGE SCORE===========================================================";

   FileWrite (fileRHandle, data);

   

   //Alert ("Maximum Poz.Q:::", MaxScore,":::Maximum Poz.Putere:::", MaxTrend, ":::Average Poz.Q.:::",AvgScore,":::Average Poz.Putere:::", AvgTrend); // culege valorile maxime din bubble sorturile de mai sus

   Alert ("Threshold Min:::", TxThreshold," Threshold Max:::", TxThreshold2," Max QQ:::", MaxQQ," Min QQ:::", MinQQ," Avg QQ:::", AvgQQ," Arithmetic Avg QQ:::", ArtAvgQQ," Maximum Poz.Q:::", MaxScore,":::Maximum Poz.Putere:::", MaxTrend, ":::Average Poz.Q.:::",AvgScore,":::Average Poz.Putere:::", AvgTrend); // culege valorile maxime din bubble sorturile de mai sus



   data = "Maximum Score" + "," + MaxScore + "," + "Maximum TREND" + "," + MaxTrend + "," +  "AVG TREND"+ "," + AvgTrend + "," + "AVG Score" + "," + AvgScore;

   FileWrite (fileRHandle, data); FileWrite (fileDHandle, data);

   

   

   //CALCUL DOMINANCE PE DEPISTARE DE SIMBOL - afisare rezultate pe matricile filtrate pe symbols - incarcate in XLS !!!!  - vezi labelul mai jos !!!



  data = "=========================================================EUR DOMINANCE TREND ANALIZOR=========EUR DOMINANCE TREND ANALIZOR===========================================================";

   FileWrite (fileRHandle, data); 

       

       Dominance =0; TrendDominance = 0;

       

   for (xt=0; xt<EUR1i; xt++) {

   

   data = "Symbol"+ "," + EUR1S[xt] + "," + "TREND" + "," + EUR1[xt][0]+ "," + "EUR1i" + "," + EUR1i + "," + "Tuu" + "," + EUR1[xt][1] + "," + "Tdd" + "," + EUR1[xt][2] + "," + "PositionScore" + "," + EUR1[xt][3];

   FileWrite (fileRHandle, data);

   

   if (EUR1[xt][0] == "11111111"){

   Dominance = Dominance + 1; TrendDominance = TrendDominance + TTTREND;

   }

   

   }

  

   for (xt=0; xt<EUR2i; xt++) {

   

   data = "Symbol"+ "," + EUR2S[xt] + "," + "TREND" + "," + EUR2[xt][0]+ "," + "EUR2i" + "," + EUR2i + "," + "Tuu" + "," + EUR2[xt][1] + "," + "Tdd" + "," + EUR2[xt][2] + "," + "PositionScore" + "," + EUR2[xt][3];

   FileWrite (fileRHandle, data);

   

   if (EUR2[xt][0] == "10000001"){

   Dominance = Dominance + 1; TrendDominance = TrendDominance + TTTREND;

   }

   

   }

   

   Alert ("EUR:::Dominance Procent:::",100*Dominance/(EUR1i+EUR2i),":::TrendPwr:::",TrendDominance,":::FxMarkets:::",(EUR1i+EUR2i) );

   data = "EUR" + "," + ":::Dominance Procent:::"+ "," + 100*Dominance/(EUR1i+EUR2i)  + "," + ":::TrendPwr:::" + "," + TrendDominance  + "," + ":::FxMarkets:::" + "," + (EUR1i+EUR2i);

   FileWrite (fileRHandle, data);  FileWrite (fileDHandle, data);



  data = "=========================================================USD DOMINANCE TREND ANALIZOR=========USD DOMINANCE TREND ANALIZOR===========================================================";

   FileWrite (fileRHandle, data); 

       

    Dominance =0; TrendDominance = 0;

       

   for (xt=0; xt<USD1i; xt++) {

   

   data = "Symbol"+ "," + USD1S[xt] + "," + "TREND" + "," + USD1[xt][0]+ "," + "USD1i" + "," + USD1i + "," + "Tuu" + "," + USD1[xt][1] + "," + "Tdd" + "," + USD1[xt][2] + "," + "PositionScore" + "," + USD1[xt][3];

   FileWrite (fileRHandle, data);

   

   if (USD1[xt][0] == "11111111"){

   Dominance = Dominance + 1; TrendDominance = TrendDominance + TTTREND;

   }

   

   }

  

   for (xt=0; xt<USD2i; xt++) {

   

   data = "Symbol"+ "," + USD2S[xt] + "," + "TREND" + "," + USD2[xt][0]+ "," + "USD2i" + "," + USD2i + "," + "Tuu" + "," + USD2[xt][1] + "," + "Tdd" + "," + USD2[xt][2] + "," + "PositionScore" + "," + USD2[xt][3];

   FileWrite (fileRHandle, data);

   

   if (USD2[xt][0] == "10000001"){

   Dominance = Dominance + 1; TrendDominance = TrendDominance + TTTREND;

   }

   

   }

   

   Alert ("USD:::Dominance Procent:::",100*Dominance/(USD1i+USD2i),":::TrendPwr:::",TrendDominance,":::FxMarkets:::",(USD1i+USD2i));

   data = "USD" + "," + ":::Dominance Procent:::"+ "," + 100*Dominance/(USD1i+USD2i)+ "," + ":::TrendPwr:::" + "," + TrendDominance  + "," + ":::FxMarkets:::" + "," + (USD1i+USD2i);

   FileWrite (fileRHandle, data);  FileWrite (fileDHandle, data);



      

  data = "=========================================================GBP DOMINANCE TREND ANALIZOR=========GBP DOMINANCE TREND ANALIZOR===========================================================";

   FileWrite (fileRHandle, data); 

     

     Dominance =0; TrendDominance = 0;

       

   for (xt=0; xt<GBP1i; xt++) {

   

   data = "Symbol"+ "," + GBP1S[xt] + "," + "TREND" + "," + GBP1[xt][0]+ "," + "GBP1i" + "," + GBP1i + "," + "Tuu" + "," + GBP1[xt][1] + "," + "Tdd" + "," + GBP1[xt][2] + "," + "PositionScore" + "," + GBP1[xt][3];

   FileWrite (fileRHandle, data);

   

   if (GBP1[xt][0] == "11111111"){

   Dominance = Dominance + 1; TrendDominance = TrendDominance + TTTREND;

   }

   

   }

  

   for (xt=0; xt<GBP2i; xt++) {

   

   data = "Symbol"+ "," + GBP2S[xt] + "," + "TREND" + "," + GBP2[xt][0]+ "," + "GBP2i" + "," + GBP2i + "," + "Tuu" + "," + GBP2[xt][1] + "," + "Tdd" + "," + GBP2[xt][2] + "," + "PositionScore" + "," + GBP2[xt][3];

   FileWrite (fileRHandle, data);

   

   if (GBP2[xt][0] == "10000001"){

   Dominance = Dominance + 1; TrendDominance = TrendDominance + TTTREND;

   }

   

   }

   

   Alert ("GBP:::Dominance Procent:::",100*Dominance/(GBP1i+GBP2i),":::TrendPwr:::",TrendDominance,":::FxMarkets:::",(GBP1i+GBP2i));

   data = "GBP" + "," + ":::Dominance Procent:::"+ "," + 100*Dominance/(GBP1i+GBP2i) + "," + ":::TrendPwr:::" + "," + TrendDominance + "," + ":::FxMarkets:::" + "," + (GBP1i+GBP2i);

   FileWrite (fileRHandle, data);  FileWrite (fileDHandle, data);



  data = "=========================================================CHF DOMINANCE TREND ANALIZOR=========CHF DOMINANCE TREND ANALIZOR===========================================================";

   FileWrite (fileRHandle, data); 

       

       Dominance =0; TrendDominance = 0;

       

   for (xt=0; xt<CHF1i; xt++) {

   

   data = "Symbol"+ "," + CHF1S[xt] + "," + "TREND" + "," + CHF1[xt][0]+ "," + "CHF1i" + "," + CHF1i + "," + "Tuu" + "," + CHF1[xt][1] + "," + "Tdd" + "," + CHF1[xt][2] + "," + "PositionScore" + "," + CHF1[xt][3];

   FileWrite (fileRHandle, data);



   if (CHF1[xt][0] == "11111111"){

   Dominance = Dominance + 1; TrendDominance = TrendDominance + TTTREND;

   }

      

   }

  

   for (xt=0; xt<CHF2i; xt++) {

   

   data = "Symbol"+ "," + CHF2S[xt] + "," + "TREND" + "," + CHF2[xt][0]+ "," + "CHF2i" + "," + CHF2i + "," + "Tuu" + "," + CHF2[xt][1] + "," + "Tdd" + "," + CHF2[xt][2] + "," + "PositionScore" + "," + CHF2[xt][3];

   FileWrite (fileRHandle, data);

   

   if (CHF2[xt][0] == "10000001"){

   Dominance = Dominance + 1; TrendDominance = TrendDominance + TTTREND;

   }

   

   }

   

   Alert ("CHF:::Dominance Procent:::",100*Dominance/(CHF1i+CHF2i),":::TrendPwr:::",TrendDominance,":::FxMarkets:::",(CHF1i+CHF2i));

   data = "CHF" + "," + ":::Dominance Procent:::"+ "," + 100*Dominance/(CHF1i+CHF2i) + "," + ":::TrendPwr:::" + "," + TrendDominance + "," + ":::FxMarkets:::" + "," + (CHF1i+CHF2i);

   FileWrite (fileRHandle, data);  FileWrite (fileDHandle, data);

   

  data = "=========================================================JPY DOMINANCE TREND ANALIZOR=========JPY DOMINANCE TREND ANALIZOR===========================================================";

   FileWrite (fileRHandle, data); 

  

     DominanceJPY =0; TrendDominanceJPY = 0;

  

   for (xt=0; xt<JPY2i; xt++) {

   

   data = "Symbol"+ "," + JPY2S[xt] + "," + "TREND" + "," + JPY2[xt][0]+ "," + "JPY2i" + "," + JPY2i + "," + "Tuu" + "," + JPY2[xt][1] + "," + "Tdd" + "," + JPY2[xt][2] + "," + "PositionScore" + "," + JPY2[xt][3];

   FileWrite (fileRHandle, data);

   

   if (JPY2[xt][0] == "10000001"){ //ca e pe pozitia 2

   DominanceJPY = DominanceJPY + 1; TrendDominanceJPY = TrendDominanceJPY + TTTREND;

   }

   

   }

   

   Alert ("JPY:::Dominance Procent:::",100*DominanceJPY/(JPY2i),":::TrendPwr:::",TrendDominanceJPY,":::FxMarkets:::",JPY2i);

   data = "JPY" + "," + ":::Dominance Procent:::"+ "," + 100*Dominance/(JPY2i) + "," + ":::TrendPwr:::" + "," + TrendDominance + "," + ":::FxMarkets:::" + "," + JPY2i;

   FileWrite (fileRHandle, data);  FileWrite (fileDHandle, data);

  

  data = "=========================================================CAD DOMINANCE TREND ANALIZOR=========CAD DOMINANCE TREND ANALIZOR===========================================================";

   FileWrite (fileRHandle, data); 

       

   Dominance =0; TrendDominance = 0;

       

   for (xt=0; xt<CAD1i; xt++) {

   

   data = "Symbol"+ "," + CAD1S[xt] + "," + "TREND" + "," + CAD1[xt][0]+ "," + "CAD1i" + "," + CAD1i + "," + "Tuu" + "," + CAD1[xt][1] + "," + "Tdd" + "," + CAD1[xt][2] + "," + "PositionScore" + "," + CAD1[xt][3];

   FileWrite (fileRHandle, data);

   

   if (CAD1[xt][0] == "11111111"){

   Dominance = Dominance + 1; TrendDominance = TrendDominance + TTTREND;

   }

      

   }

  

   for (xt=0; xt<CAD2i; xt++) {

   

   data = "Symbol"+ "," + CAD2S[xt] + "," + "TREND" + "," + CAD2[xt][0]+ "," + "CAD2i" + "," + CAD2i + "," + "Tuu" + "," + CAD2[xt][1] + "," + "Tdd" + "," + CAD2[xt][2] + "," + "PositionScore" + "," + CAD2[xt][3];

   FileWrite (fileRHandle, data);

   

   if (CAD2[xt][0] == "10000001"){

   Dominance = Dominance + 1; TrendDominance = TrendDominance + TTTREND;

   }    

   }

   Alert ("CAD:::Dominance Procent:::",100*Dominance/(CAD1i+CAD2i),":::TrendPwr:::",TrendDominance,":::FxMarkets:::",(CAD1i+CAD2i));

   data = "CAD" + "," + ":::Dominance Procent:::"+ "," + 100*Dominance/(CAD1i+CAD2i) + "," + ":::TrendPwr:::" + "," + TrendDominance + "," + ":::FxMarkets:::" + "," + (CAD1i+CAD2i);

   FileWrite (fileRHandle, data);  FileWrite (fileDHandle, data);  

  

   data = "=========================================================AUD DOMINANCE TREND ANALIZOR=========AUD DOMINANCE TREND ANALIZOR===========================================================";

  

   FileWrite (fileRHandle, data); // AUD2[AUD2i][1]=Tuu;AUD2[AUD2i][2]=Tdd;AUD2[AUD2i][3]=PositionScore

       

   Dominance =0; TrendDominance = 0;

   

   for (xt=0; xt<AUD1i; xt++) {

   data = "Symbol"+ "," + AUD1S[xt] + "," + "TREND" + "," + AUD1[xt][0]+ "," + "AUD1i" + "," + AUD1i + "," + "Tuu" + "," + AUD1[xt][1] + "," + "Tdd" + "," + AUD1[xt][2] + "," + "PositionScore" + "," + AUD1[xt][3];

   FileWrite (fileRHandle, data); 

   

   if (AUD1[xt][0] == "11111111"){

   Dominance = Dominance + 1; TrendDominance = TrendDominance + TTTREND;

   }

   

   }

  

   for (xt=0; xt<AUD2i; xt++) {

   

   data = "Symbol"+ "," + AUD2S[xt] + "," + "TREND" + "," + AUD2[xt][0]+ "," + "AUD2i" + "," + AUD2i + "," + "Tuu" + "," + AUD2[xt][1] + "," + "Tdd" + "," + AUD2[xt][2] + "," + "PositionScore" + "," + AUD2[xt][3];

   FileWrite (fileRHandle, data); 

   

   if (AUD2[xt][0] == "10000001"){

   Dominance = Dominance + 1; TrendDominance = TrendDominance + TTTREND;

   }

   

   }

   

   Alert ("AUD:::Dominance Procent:::",100*Dominance/(AUD1i+AUD2i),":::TrendPwr:::",TrendDominance,":::FxMarkets:::",(AUD1i+AUD2i));

   data = "AUD" + "," + ":::Dominance Procent:::"+ "," + 100*Dominance/(AUD1i+AUD2i) + "," + ":::TrendPwr:::" + "," + TrendDominance + "," + ":::FxMarkets:::" + "," + (AUD1i+AUD2i);

   FileWrite (fileRHandle, data);  FileWrite (fileDHandle, data);

  



  data = "=========================================================NZD DOMINANCE TREND ANALIZOR=========NZD DOMINANCE TREND ANALIZOR===========================================================";

   FileWrite (fileRHandle, data); 

       

       Dominance =0; TrendDominance = 0;

       

   for (xt=0; xt<NZD1i; xt++) {

   

   data = "Symbol"+ "," + NZD1S[xt] + "," + "TREND" + "," + NZD1[xt][0]+ "," + "NZD1i" + "," + NZD1i + "," + "Tuu" + "," + NZD1[xt][1] + "," + "Tdd" + "," + NZD1[xt][2] + "," + "PositionScore" + "," + NZD1[xt][3];

   FileWrite (fileRHandle, data);

   

   if (NZD1[xt][0] == "11111111"){

   Dominance = Dominance + 1; TrendDominance = TrendDominance + TTTREND;

   }

   

   }

  

   for (xt=0; xt<NZD2i; xt++) {

   

   data = "Symbol"+ "," + NZD2S[xt] + "," + "TREND" + "," + NZD2[xt][0]+ "," + "NZD2i" + "," + NZD2i + "," + "Tuu" + "," + NZD2[xt][1] + "," + "Tdd" + "," + NZD2[xt][2] + "," + "PositionScore" + "," + NZD2[xt][3];

   FileWrite (fileRHandle, data);

   

   if (NZD2[xt][0] == "10000001"){

   Dominance = Dominance + 1; TrendDominance = TrendDominance + TTTREND;

   }

   

   }

   

   Alert ("NZD:::Dominance Procent:::",100*Dominance/(NZD1i+NZD2i),":::TrendPwr:::",TrendDominance,":::FxMarkets:::",(NZD1i+NZD2i));

   data = "NZD" + "," + ":::Dominance Procent:::"+ "," + 100*Dominance/(NZD1i+NZD2i) + "," + ":::TrendPwr:::" + "," + TrendDominance + "," + ":::FxMarkets:::" + "," + (NZD1i+NZD2i);

   FileWrite (fileRHandle, data);  FileWrite (fileDHandle, data);

   



  data = "=========================================================XAU DOMINANCE TREND ANALIZOR=========XAU DOMINANCE TREND ANALIZOR===========================================================";

   FileWrite (fileRHandle, data); 

     

   Dominance =0; TrendDominance = 0;

       

   for (xt=0; xt<XAU1i; xt++) {

   

   data = "Symbol"+ "," + XAU1S[xt] + "," + "TREND" + "," + XAU1[xt][0]+ "," + "XAU1i" + "," + XAU1i + "," + "Tuu" + "," + XAU1[xt][1] + "," + "Tdd" + "," + XAU1[xt][2] + "," + "PositionScore" + "," + XAU1[xt][3];

   FileWrite (fileRHandle, data);

   

   if (XAU1[xt][0] == "11111111"){

   Dominance = Dominance + 1; TrendDominance = TrendDominance + TTTREND;

   }

   

   }

   

   Alert ("XAU:::Dominance Procent:::",100*Dominance/(XAU1i),":::TrendPwr:::",TrendDominance,":::FxMarkets:::",XAU1i);

   data = "XAU" + "," + ":::Dominance Procent:::"+ "," + 100*Dominance/(XAU1i) + "," + ":::TrendPwr:::" + "," + TrendDominance + "," + ":::FxMarkets:::" + "," + XAU1i;

   FileWrite (fileRHandle, data);  FileWrite (fileDHandle, data);

   

   

   

 
CB:

ok - if i cut this code from my code - things are starting to work... this piece of code is at the end of my own code...

Since this is made up of sub-blocks for different currencies, have you tried putting sub-block by sub-block (i.e. currency by currency) back?

Another thing you can try is to put this whole block back, but remove the earlier parts (unless they're essential for this block to work?), just for testing.

 
CB: - if i cut this code from my code - things are starting to work... this piece of code is at the end of my own code...
When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
          General rules and best pratices of the Forum. - General - MQL5 programming forum
          Messages Editor
 
William Roeder:
When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
          General rules and best pratices of the Forum. - General - MQL5 programming forum
          Messages Editor

seeing this now. i cannot edit my initial message since the edit button is not there. sorry for inconvenience... my bad.

 
CB:

seeing this now. i cannot edit my initial message since the edit button is not there. sorry for inconvenience... my bad.

I have edited it for you this time.

 
lippmaje:
A loop body with 2000 lines is difficult to read and maintain. Even if only you are going to use it and no one else participates. Think what will happen when you didn't work with this code for half a year and then come back to reuse it. It would be much easier to maintain if you break the block into smaller pieces and make functions from it. Btw 'while(true)' is commonly used.

while (true) was the solution (the rest of 1>0 or others behave funny) - works now for the entire code. 

you are very helpful lippmaje !


thanks.


case closed.

Reason: