Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 258

 
gyfto:

experts/files/trx_rowa.vbs

It's an evil, unshaven, unknown to science trojan. Devlala, you have googol at a mouse's distance, can't you figure out the source code? Change IE.visible = false to IE.visible = true, run it and see. The script parses your calendar and writes everything in Cyrillic in a text file. Open it and look, it reads fine.


'On Error Resume Next
Dim IE : Set IE = WSCript.CreateObject("InternetExplorer.Application")
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim fTxtName : fTxtName = Left(WSCript.ScriptFullName,len(WSCript.ScriptFullName)-3) & "txt"
Set TxtFile = objFSO.OpenTextFile(fTxtName, 2, True)'открываем файл для записи
IE.visible = false' браузер в фоновом режиме
IE.navigate "http://www.fxteam.ru/forex/economic-calendar/2013_49.html"
Do While IE.Busy
        WSCript.Sleep 500
loop
Do While IE.document.getElementsByClassName("tr1 rowa").Item(0).getElementsByTagName("TD").Item(4) is Nothing' пока этот элемент страницы не загрузится
        WSCript.Sleep 500' будем ждать загрузки страницы
loop
Set tr1_rowa = IE.document.getElementsByClassName("tr1 rowa")
For i = 0 to tr1_rowa.length - 1
        TxtFile.WriteLine tr1_rowa.Item(i).getElementsByTagName("TD").Item(4).InnerText
Next
Set tr0_rowa = IE.document.getElementsByClassName("tr0 rowa")
For i = 0 to tr0_rowa.length - 1
        TxtFile.WriteLine tr0_rowa.Item(i).getElementsByTagName("TD").Item(4).InnerText
Next
Set IE = Nothing' закрываем браузер
TxtFile.Close
WSCript.Quit()

I seriously don't understand what kind of text this is. Let's start with,

1. I can download the site into a file.

2. Further options:

2a) Run it through the recoding function(unreadable characters will disappear, and there will be an error in the log - which is annoying), and parse the Russian letters(annoying errors, in the log, but they do not affect the work ).

2b) Leave things as they are, and make some trouble with keywords (like monday = "РџÐЅÐµÐґÐµÐ "ÑЊÐЅÐє"), and get information out.

2c) Write a function that translates "Monday" to "РџÐѕÐЅÐµÐґÐµÐ "ÑЊÐЅÐøє", and pull out what is needed.

Tried to write a function, but something I obviously don't know about encodings :) Here's what I got, below is the original.

string win_utf8(string s) { 
   string outputi = "";
   string other1 = "Ё";
   string other2 = "ё";
   string other3 = "Є";
   string other4 = "є";
   string other5 = "I";
   string other6 = "i";
   string other7 = "Ї";
   string other8 = "ї";
   for (int i = 0; i < StringLen(s); i++)
   {
      if (StringGetChar(s,i) > 191) 
      {
         int output=StringGetChar(s,i)+848;
      }
         else 
         {
            if (StringSubstr(s,i,1) != other1)output=StringGetChar(s,i);
            else output=1025; 
            if (StringSubstr(s,i,1) != other2)output=StringGetChar(s,i);
            else output=1105; 
            if (StringSubstr(s,i,1) != other3)output=StringGetChar(s,i);
            else output=1028; 
            if (StringSubstr(s,i,1) != other4)output=StringGetChar(s,i);
            else output=1108; 
            if (StringSubstr(s,i,1) != other5)output=StringGetChar(s,i);
            else output=1030; 
            if (StringSubstr(s,i,1) != other6)output=StringGetChar(s,i);
            else output=1110; 
            if (StringSubstr(s,i,1) != other7)output=StringGetChar(s,i);
            else output=1031; 
            if (StringSubstr(s,i,1) != other8)output=StringGetChar(s,i);
            else output=1111; 
            }
   outputi=outputi+StringSetChar("",0,output);
   }
   
   return (outputi);
}
function win_utf8($in_text) { 
   $output = "";
   $other[1025] = "Ё";
   $other[1105] = "ё";
   $other[1028] = "Є";
   $other[1108] = "є";
   $other[1030] = "I";
   $other[1110] = "i";
   $other[1031] = "Ї";
   $other[1111] = "ї";
   for ($i = 0; $i < strlen($in_text); $i++){
      if (ord($in_text{$i}) > 191) {
         $output.="&#".(ord($in_text{$i})+848).";";
      }else {
         if (array_search($in_text{$i}, $other)===false){
            $output.=$in_text{$i};
         }else {
            $output.="&#".array_search($in_text{$i}, $other).";";
         }
      }
   }
   return $output;
}
 
mzk_3om6u:

I seriously don't understand what kind of text it is where to put it in.


I have uncommented it there, see. Copy this code into notepad, save notepad as trx_rowa.vbs (not txt), get vbs-script. Transfer the script to expert files. You can check it first, run it, or you can immediately write its call from mql4-code. How to call it is given. It creates a txt file with the same name as itself, and all your Cyrillic is there. The only thing is, sleep won't be called from your induke, you'll have to work it out. You could do it like this:

datetime myTimer = TimeCurrent() + 60;
while(TimeCurrent() < myTimer){}
//дальше код...

but it's unlikely to work. There was a WinAPI timer on the forum.

 
gyfto:

I uncommented there, look. This code you copy to notepad, notepad save as trx_rowa.vbs (not txt), get vbs-script. Transfer the script to expert files. You can check it first, run it, or you can immediately write its call from mql4-code. How to call it is given. It creates a txt file with the same name as itself and all your Cyrillic is there.


I see your point! Thanks for the way to pull out the Cyrillic, but the main task is to get the time/country/importance, but the importance is there as a picture, and it can only be caught in Latin, and so I'll keep an alternative way to download pages.

Thanks:)

 
mzk_3om6u:


the main objective is to get the time/country/importance


Time - .getElementsByTagName("TD").item(0).InnerText

country - .getElementsByTagName("TD").item(1).InnerText

importance - .getElementsByTagName("TD").item(2).InnerHTML, and there you can find out which number is in the /i/calendar/impact1.png line

 

Is there any limitation on the use of indicators?

If I use an indicator in my EA, then when the programme finishes testing, the indicator is drawn.

If I use the same indicator but with different parameters - then two indicators are drawn.

I want to include an indicator with dynamic parameters in my EA - when I stop it, it starts working very slowly and displays armageddon instead of a chart (I have 30 attached indicators - so many indicators can display on a chart).

The question is if it only displays 30 - does it understand the rest inside the script?

 
tiiga:

Is there any limitation on the use of indicators?

If I use an indicator in my EA, then when the programme finishes testing, the indicator is drawn.

If I use the same indicator but with different parameters - then two indicators are drawn.

I want to include an indicator with dynamic parameters in my EA - the EA starts working very slowly and when I stop it, it shows armageddon instead of a chart.

I would like to transfer the main function of the indicator to my EA - it will work faster and there will be no Armageddon.

Transferring of the indicator code to Expert Advisor code. Structure of the indicator.

Transferring of the indicator code to the Expert Advisor code. General Scheme of Construction of Expert Advisors and Indicator Functions

Transferring indicator code to expert code. Conclusion
 
thank you! your link is not clicking
 
tiiga:

Is there any limitation on the use of indicators?

If I use an indicator in my EA, then when the programme finishes testing, the indicator is drawn.

If I use the same indicator but with different parameters - then two indicators are drawn.

I want to include an indicator with dynamic parameters in my EA - when I stop it, it starts working very slowly and when I stop it, it shows armageddon instead of a chart (I have 30 attached indicators - so many indicators can display on a chart).

The question is if it only displays 30 - does it understand the rest inside the script?


void HideTestIndicators( bool hide)

The function sets flag to hide indicators called by the Expert Advisor. When opening a chart after testing, the indicators marked with the hide flag will not be displayed on the test chart. Before each call, the indicator is marked with the current hiding flag set.
It should be noted that only those indicators that are directly called from the Expert Advisor under test can be shown in the testing chart.
Parameters:
hide - TRUE - if you want to hide indicators, otherwise FALSE.
Example:
  HideTestIndicators(true); MaCurrent=iMA(NULL,0,56,0,MODE_EMA,PRICE_CLOSE,0); MaPrevious=iMA(NULL,0,56,0,MODE_EMA,PRICE_CLOSE,1); HideTestIndicators(false);
 

What is the correct way to find the drawdown percentage?

(DoubleToStr(AccountBalance(), 2) - DoubleToStr(AccountFreeMargin(), 2)) * 100

 
Zolotai:

What is the correct way to find the drawdown percentage?

(DoubleToStr(AccountBalance(), 2) - DoubleToStr(AccountFreeMargin(), 2)) * 100


Comment ("Profit/Loss % = " DoubleToStr ((AccountProfit()/ AccountBalance()* 100),2)";

It's more or less like this
Reason: