Ошибка no data for testing

stringo писал (а):

Сгенерированный файл при этом не удаляется?

Попробуйте убрать галку «Использовать дату».

Файл fxt с папки tester/history/… не удаляется.

Попробовал запустить без галочки «использовать дату».
Надпись в журнале «no data for testing» исчезла, но появилась новая
картина:

При тестировании на fxt файле, сгенерированном из csv файла тиковой
истории, постоянно идет сообщение «invalid price». Не открывается
ни одной сделки, журнал выглядит так:

При тестировании на fxt файле созданном при помощи обычной истории
минуток все нормально работает. На демо тоже все нормально работает,
никаких «invalid price» нет. Журнал выглядит так:

Чтобы убедится что проблема не в коде эксперта, протестировал
еще одного, который у меня работает болле 2-х месяцес на счете,
и делает 10-25 сделок в сутки. При тестировании на обычной минутной
истории эксперт нормально работал. А при тестировании на fxt
файле сгенерированом при помощи simple_csv2fxt.mq4 эксперт не сделал
ни одной сделки. Хотя по алгоритму эксперта он должен был выставить
отложенный ордер в случае если iOpen(NULL,0,1)!=iClose(NULL,0,1). Создается
впечетление, как будто тики есть, а баров нет, или каждый тик
является отдельным баром. И еще, при запуске с визуализацией
на сгенерированном fxt файле, никакие бары не рисуются, черный
экран, и линия «бид» прыгает в соответствии с тиками.

У меня есть 4 варианта:
1. Я что-то не так делаю.
2. У меня какой-то глючный файл истории.
3. Неправильно работает simple_csv2fxt.mq4
4. Неправильно работает тестер стратегий.

Прикрепляю fxt файл сгенерированный при помощи simple_csv2fxt из файла
csv тиковой истории. Файл csv прикрепить не получается, 6 Мб в заархивированном
виде. Посмотрите пожалуйста, ничего не могу понять. Может у меня
руки, а может и что-то серьезнее.

Спасибо.

This page is obsolete, no longer maintained and its content only applies to Tick Data Suite v1.x. The Tick Data Suite has been rewritten from scratch to allow a much easier operation. Please head to the support page and browse the support articles for information regarding Tick Data Suite v2. In particular, you can take a look at the Quick Start Guide.

Table of contents

  • Converting to FXT
    1. When running CSV2FXT, I get the message “Could not open input file”. What should I do?
    2. How can I change the fixed spread in an existing FXT file?
    3. How can I change [some other setting] in an existing FXT file?
    4. I cannot find the resulting FXT and HST files. Where are they?!
    5. Backtesting an EA with my newly created FXT results in Order Send Error 131. Why?
    6. What do I do if I get an alert saying Bad CSV Format when I try to convert the CSV I exported from JForex?
    7. Is it possible to append tick data to an existing FXT file (and the accompanying HST files)?
    8. Is it possible to append tick data to an existing CSV file?
    9. Why does the CSV2FXT script get stuck as soon as it is started? The progress indicator is not displayed on the chart and the only message displayed in the experts log is “The date column appears to be 0. Sample…”
    10. How can I change the timeframe of an existing FXT file?
    11. Can I create range bars or Renko bars with CSV2FXT?
  • Using the tick data
    1. Why are my FXT files being overwritten?
    2. Why is my terminal creating an FXT file when I start backtesting?
    3. My backtest runs but I do not get 99% modeling quality. Why?
    4. My backtest stops as soon as I click the start button. The backtesting journal tab displays TestGenerator: internal error because the file not opened. What is wrong?
    5. Why does my terminal crash as soon as I press “start” in the backtest user interface?
    6. Why do I get a red bar at the end of the backtest even though my modeling quality is 99%?
    7. What can I do if my optimization results window is empty even though MT4 appears to run multiple passes correctly?
    8. I am getting empty results (no trades) in all my optimization passes when using the Walk Forward Analyzer. Is there a workaround?
    9. Why are all the volumes in my tick data backtest smaller than 1?
    10. Why are all the volumes in my tick data backtest huge numbers?
    11. Why does my backtest fail as soon as I attempt to start it with the backtest journal saying No data for testing.?
    12. My backtest stops somewhere in the middle, even though the FXT file I created spans a longer time period. How can I fix this?
    13. How come my backtest results differ from an optimization cycle results if I am using the same parameters?

Converting to FXT

1. When running CSV2FXT, I get the message “Could not open input file”. What should I do?

That can only be caused by the script trying to open a file that is not there so you either copied the CSV to the wrong folder, named it incorrectly or typed its name incorrectly. Check the following things:

  • You are using the correct CSV2FXT version. v0.43 and below are only suited for MT4 builds 509 and below. You must use a newer CSV2FXT with MT4 builds 545 or higher.
  • You put the CSV file in the correct folder (expertsfiles for MT4 build 509 or lower respectively MQL4Files for MT4 builds 545+).
  • If using MT4 build 509 or earlier, you put the CSV file in the correct MT4 installation folder (if you have more than one).
  • If using MT4 build 545+, you put the CSV file in the correct MT4 data folder (head to File -> Open Data Folder to find out where it is).
  • If you left the CsvFile field blank, check that the file is named as your pair and has a csv extension.
  • If you typed something in the CsvFile field, make sure that you typed the full file name including its extension.
  • If your explorer is configured to hide the file extension for known files, your file might be named EURUSD.CSV.CSV and explorer might just show EURUSD.CSV, or your file might be correctly named EURUSD.CSV and your explorer might just show EURUSD. In Windows 7, to work around this issue you can hit ALT in an explorer window, click Tools -> Folder options -> View then uncheck “Hide extensions for known file types”. The procedure is similar for other Windows versions.
  • If you are using Vista with MT4 build 509 or earlier and your MT4 installation is in Program Files, I suggest making a copy somewhere else (for instance on your Desktop) and working from that one instead. Vista has something called UAC that can be a royal pain in the ass. You can also disable UAC if you wish, read a few paragraphs below on how to do that.

2. How can I change the fixed spread in an existing FXT file?

Use a hex editor (e.g. WinHex, Neo Hex Editor) and change it at offset 0xFC. Note that it’s going to be displayed in hexadecimal so you’ll probably have to use a calculator.

3. How can I change [some other setting] in an existing FXT file?

Look up the offset in FXTHeader.mqh, it’s displayed next to each setting. Use a hex editor. Note that all values are in little endian format, meaning that if you have a value that exceeds one byte you have to fill in the bytes to its right. For instance, if you want to write 300 in the file you will have to write it as 2C 01.

4. I cannot find the resulting FXT and HST files. Where are they?!

For MT4 builds 509 or earlier, this is typical for Windows 7 / Windows Vista users that run MT4 from their Program Files folder. The issue is caused by the fact that UAC is enabled and these operating systems use folder virtualization. For Windows 7, the resulting files can be found in c:ProgramData typically, while for Windows Vista they can be found in c:UsersusernameAppDataLocalVirtualStoreProgram Files. If they’re not there, just search for *.FXT, they must be somewhere. To get around this problem, either copy your MT4 folder in a location that’s not protected by UAC (e.g. your desktop) or simply disable UAC (type UAC in the start->search box thing and follow the on-screen process).

For MT4 build 545 or later, head to File -> Open Data Folder and look in MQL4Files.

5. Backtesting an EA with my newly created FXT results in Order Send Error 131. Why?

This might be caused by the lack of a MIN_LOT and LOT_STEP for the symbol in the resulted FXT file. This happens when generating the FXT file with a MT4 client that wasn’t connected to the broker when the script was started. As specified above, your terminal should be connected to your broker when generating an FXT file.

6. What do I do if I get an alert saying Bad CSV Format when I try to convert the CSV I exported from JForex?

This is in all likelihood because you either failed to select a delimiter or selected a dot (.) as the delimiter, so the solution is easy: you go back to JForex, select comma (,) as the delimiter and export the CSV once more. This should be much faster than the first time since the data is cached. If you’re uncertain about the other parameters, take another look at the JForex downloading guide.

7. Is it possible to append tick data to an existing FXT file (and the accompanying HST files)?

No.

8. Is it possible to append tick data to an existing CSV file?

Yes. The CSV2FXT script will disregard duplicate information and even the JForex header line if it is encountered in the middle of the CSV file.

If you are using JForex, you should start your CSV from the time your older CSV ends. You can delete the header row from the new CSV file before concatenating or you can simply skip this step, in which case the CSV2FXT script will skip that line and warn you about it in the experts log. When the export is finished, simply append the new CSV to the older one.

If you are using the PHP scripts, it is ideal to stop your processing at the end of a month. The processing script automatically appends to an existing file so if you resume from the start of the next month your CSV will be perfect. However, you can stop your processing even during the month; for example, if you have a file named EURUSD.csv that ends on 19.03.2012 and then append data starting from 01.03.2012 and ending with 02.04.2012 (e.g. by typing php process_dukascopy_data.php EURUSD 201203 201205 EURUSD.csv), the new data will be appended to your existing CSV and the data between 01.03 and 19.03 will be in your CSV twice. In such a case, the CSV2FXT script will output about 20 errors in your log and spit out an alert about older ticks, but it is smart enough to skip the duplicated data so the resulting FXT should be perfectly fine (although it will take a little bit longer because it has to skip the duplicated period).

9. Why does the CSV2FXT script get stuck as soon as it is started? The progress indicator is not displayed on the chart and the only message displayed in the experts log is “The date column appears to be 0. Sample…”

Most likely this is because you exported the CSV file using JForex but failed to select the comma (,) as the field delimiter as mentioned in the guide. Since for some reason that I fail to grasp the default JForex setting is to use a space as field separator and put several commas at the end of each line, your CSV file is useless and has to be regenerated. The good news is that JForex caches the data so you don’t have to wait for the download once more.

10. How could I change the timeframe of an existing FXT file?

Two steps:

  1. Since the file name contains the timeframe, for instance EURUSD15_0.FXT for an M15 EURUSD FXT file, you have to rename (or copy) the file for the desired timeframe. Assuming you’d want to make it H4, you translate that to minutes (4 hours = 240 minutes) and you rename the file to EURUSD240_0.FXT
  2. Next you have to grab a hex editor and edit the file at offset 0xD0. Change the number to the same one used in the file name in the previous step (but make sure you convert it to hex; using our example above, 240 is 0xF0 so you would have to change it from 0x0F – which is 15 – to 0xF0).

One thing to note that if you perform this change is that the bar count displayed in the results is going to be wrong and indicators running on the backtest timeframe will be misleading because the ticks are stored as part of bars and the bars will be for a different timeframe. Essentially, if your EA has any indicators running on the backtest timeframe, this method is not safe to use.

11. Can I create range bars or Renko bars with CSV2FXT?

Not with the version I created. However, Artur from AZ-Invest has developed a version of the script that works with Renko bars.

Using the tick data

1. Why are my FXT files being overwritten?

You probably didn’t start the MT4 terminal via the Tick Data Suite and your FXT files are not read-only for some reason.

2. Why is my terminal creating an FXT file when I start backtesting?

  • Did you create the FXT file for the currency pair & timeframe that you are trying to use in your backtest?
  • If the answer to the above is yes, did you copy it to the correct location (in recent MT4 builds, head to File -> Open Data Folder to find the right place)?
  • Also see the answer for question #1 above.

3. My backtest runs but I do not get 99% modeling quality. Why?

This is in fact the same question as #2 above.

4. My backtest stops as soon as I click the start button. The backtesting journal tab displays TestGenerator: internal error because the file not opened. What is wrong?

That’s MT4’s way of notifying you that it refuses to overwrite an FXT file that is set read-only and it happens with MT4 builds 509 or earlier. You need to close the MT4 terminal and start it via the Tick Data Suite shortcut.

5. Why does my terminal crash as soon as I press “start” in the backtest user interface?

If you’re not using the latest MT4 build, it’s most likely because the EA was compiled with a build newer than yours and Metaquotes did not think it wise to add ex4 versioning. You can tell this is the problem if attaching the same EA to a chart will also result in a crash. The solution is to use the latest build or get the EA compiled with your build.

6. Why do I get a red bar at the end of the backtest even though my modeling quality is 99%?

Because the FXT you are using was created with an older script. It’s nothing to worry about, though – you can safely ignore it.

7. What can I do if my optimization results window is empty even though MT4 appears to run multiple passes correctly?

That means the results you obtained were not profitable. If you wish to see them nonetheless, you can select the Optimization Results tab, right click inside it and deselect “Skip Useless Results”.

8. I am getting empty results (no trades) in all my optimization passes when using the Walk Forward Analyzer. Is there a workaround?

This only happens with some EAs that need the Metatrader 4 terminal to be connected to the broker even when backtesting, for instance Wallstreet Forex Robot or FAP Turbo. To put it simply, since the FXT is already there, the backtest starts too fast. The only solution for this problem is to add an artificial delay, which can be done by using the Configuration program installed with the Tick Data Suite. Just fire up Configuration and increase the Backtest delay factor to something like 3. This will start the backtest with a sensible delay which should be enough for the terminal to connect to the broker. In case it isn’t, feel free to increase it to something like 10. Set it back to 0 once you’re done with that particular EA unless you want to have a permanent delay when backtesting or optimizing with tick data. Note that this option will not have an effect on Metatrader 4 terminals that are already running and you will need to restart these to take advantage of it.

9. Why are all the volumes in my tick data backtest smaller than 1?

It’s because you are using real spread when creating your FXT with MT4 build 509 or earlier. When enabling this option, the spread is stored in the volume field. If your strategy makes use of the volume number (which is simply the number of ticks in MT4), you need to use fixed spread or employ other strategies such as counting the number of ticks and storing it in an array.

10. Why are all the volumes in my tick data backtest huge numbers?

Same reason as for the previous question, but it only applies to MT4 builds 545 or higher. To get the actual volume, simply apply a bitwise AND 0xFFFFFFFF like this:


volume = Volume[0] & 0xFFFFFFFF;

11. Why does my backtest fail as soon as I attempt to start it with the backtest journal saying “No data for testing.”?

This typically happens when you enabled Use date and the start and end dates you selected are outside the range covered by your FXT.

12. My backtest stops somewhere in the middle, even though the FXT file I created spans a longer time period. How can I fix this?

This typically happens when you’re using MT4 build 600 or higher, you created an FXT file larger than 4GB and you forgot to run MT4 via the Tick Data Suite (the MT4 window title bar should say “… with Tick Data Suite vX.XX”).

If this happens and none of the above are the causes, you should first attempt to backtest the MACD EA using your FXT and if it stops at the same point, you should investigate the source CSV in that range and check the log of the CSV2FXT script for any potential errors.

13. How come my backtest results differ from an optimization cycle results if I am using the same parameters?

This only happens when you are using a start/end date for your optimization and you’re using MT4 build 509 or earlier. Sadly, this is a bug in Metatrader 4: only the first pass of an optimization uses the start and end date you selected; subsequent runs use the full range available in the FXT. This bug was fixed starting with MT4 build 545.

In any case, with MT4 builds 509 and earlier, to get the same outcome when backtesting with the parameters for one of the optimization results, you can either make an FXT that spans exactly the period that you want to optimize for, or alternatively you can simply disable Use date when running the backtest for the selected optimization results (if it’s not the parameters for the first run, that is).

Jim57

Posts: 13
Joined: Wed Apr 13, 2011 4:58 am
Location: GB

No Data error

#1 Postby Jim57 » Fri Aug 22, 2014 2:56 am

I have downloaded data in the Data Center, generated ticks.

The chart looks fine in the History Mode, but when I open the same chart in Testing Mode I get no candles just the message «NO DATA (Start new test)»

Why is there no data?

Also, I can see no option anywhere to «Start new test» — what does it therefore mean?

Thank you.


FX Helper

Posts: 1424
Joined: Mon Apr 01, 2013 3:55 am

Re: No Data error

#2 Postby FX Helper » Mon Aug 25, 2014 4:57 am

Hello,

It is ok that Forex Tester shows “No Data” in Testing Mode. It is just the result of the previous test but if you did not do any test before on some currency pairs it will show “No Data”.
You just need to start a new test to replace “No Data” message with quotes. Do not forget to unpause the testing.

But if you started a test and the chart is still empty then probably you have different data periods for different symbols. For example, you may have data for AUDUSD starting from 01.01.2001 and data for GBPUSD starting from 01.01.2002, in this case when you start a test GBPUSD chart will be empty until the testing date reaches 01.01.2002.

So please start a test from the date where you have data for all pairs or please import more data in Data Center and re-generate ticks.

Let us know if you still have problems with this.


Jim57

Posts: 13
Joined: Wed Apr 13, 2011 4:58 am
Location: GB

Re: No Data error

#3 Postby Jim57 » Fri Sep 12, 2014 2:12 am

Thank you. I sorted it out and it worked.

Much appreciated.

ps My big problem now with Forextester is the lack of indices etc available from yourselves, for simple downloading and using easily in FT2, without messing around. Most brokers seem to offer a choice of all kinds of nice instruments now, other than forex. Hope you can catch up with the times!! ;-) Thanks again!




Return to “Bug reports”

Who is online

Users browsing this forum: No registered users and 0 guests

This page is obsolete, no longer maintained and its content only applies to Tick Data Suite v1.x. The Tick Data Suite has been rewritten from scratch to allow a much easier operation. Please head to the support page and browse the support articles for information regarding Tick Data Suite v2. In particular, you can take a look at the Quick Start Guide.

Table of contents

  • Converting to FXT
    1. When running CSV2FXT, I get the message “Could not open input file”. What should I do?
    2. How can I change the fixed spread in an existing FXT file?
    3. How can I change [some other setting] in an existing FXT file?
    4. I cannot find the resulting FXT and HST files. Where are they?!
    5. Backtesting an EA with my newly created FXT results in Order Send Error 131. Why?
    6. What do I do if I get an alert saying Bad CSV Format when I try to convert the CSV I exported from JForex?
    7. Is it possible to append tick data to an existing FXT file (and the accompanying HST files)?
    8. Is it possible to append tick data to an existing CSV file?
    9. Why does the CSV2FXT script get stuck as soon as it is started? The progress indicator is not displayed on the chart and the only message displayed in the experts log is “The date column appears to be 0. Sample…”
    10. How can I change the timeframe of an existing FXT file?
    11. Can I create range bars or Renko bars with CSV2FXT?
  • Using the tick data
    1. Why are my FXT files being overwritten?
    2. Why is my terminal creating an FXT file when I start backtesting?
    3. My backtest runs but I do not get 99% modeling quality. Why?
    4. My backtest stops as soon as I click the start button. The backtesting journal tab displays TestGenerator: internal error because the file not opened. What is wrong?
    5. Why does my terminal crash as soon as I press “start” in the backtest user interface?
    6. Why do I get a red bar at the end of the backtest even though my modeling quality is 99%?
    7. What can I do if my optimization results window is empty even though MT4 appears to run multiple passes correctly?
    8. I am getting empty results (no trades) in all my optimization passes when using the Walk Forward Analyzer. Is there a workaround?
    9. Why are all the volumes in my tick data backtest smaller than 1?
    10. Why are all the volumes in my tick data backtest huge numbers?
    11. Why does my backtest fail as soon as I attempt to start it with the backtest journal saying No data for testing.?
    12. My backtest stops somewhere in the middle, even though the FXT file I created spans a longer time period. How can I fix this?
    13. How come my backtest results differ from an optimization cycle results if I am using the same parameters?

Converting to FXT

1. When running CSV2FXT, I get the message “Could not open input file”. What should I do?

That can only be caused by the script trying to open a file that is not there so you either copied the CSV to the wrong folder, named it incorrectly or typed its name incorrectly. Check the following things:

  • You are using the correct CSV2FXT version. v0.43 and below are only suited for MT4 builds 509 and below. You must use a newer CSV2FXT with MT4 builds 545 or higher.
  • You put the CSV file in the correct folder (expertsfiles for MT4 build 509 or lower respectively MQL4Files for MT4 builds 545+).
  • If using MT4 build 509 or earlier, you put the CSV file in the correct MT4 installation folder (if you have more than one).
  • If using MT4 build 545+, you put the CSV file in the correct MT4 data folder (head to File -> Open Data Folder to find out where it is).
  • If you left the CsvFile field blank, check that the file is named as your pair and has a csv extension.
  • If you typed something in the CsvFile field, make sure that you typed the full file name including its extension.
  • If your explorer is configured to hide the file extension for known files, your file might be named EURUSD.CSV.CSV and explorer might just show EURUSD.CSV, or your file might be correctly named EURUSD.CSV and your explorer might just show EURUSD. In Windows 7, to work around this issue you can hit ALT in an explorer window, click Tools -> Folder options -> View then uncheck “Hide extensions for known file types”. The procedure is similar for other Windows versions.
  • If you are using Vista with MT4 build 509 or earlier and your MT4 installation is in Program Files, I suggest making a copy somewhere else (for instance on your Desktop) and working from that one instead. Vista has something called UAC that can be a royal pain in the ass. You can also disable UAC if you wish, read a few paragraphs below on how to do that.

2. How can I change the fixed spread in an existing FXT file?

Use a hex editor (e.g. WinHex, Neo Hex Editor) and change it at offset 0xFC. Note that it’s going to be displayed in hexadecimal so you’ll probably have to use a calculator.

3. How can I change [some other setting] in an existing FXT file?

Look up the offset in FXTHeader.mqh, it’s displayed next to each setting. Use a hex editor. Note that all values are in little endian format, meaning that if you have a value that exceeds one byte you have to fill in the bytes to its right. For instance, if you want to write 300 in the file you will have to write it as 2C 01.

4. I cannot find the resulting FXT and HST files. Where are they?!

For MT4 builds 509 or earlier, this is typical for Windows 7 / Windows Vista users that run MT4 from their Program Files folder. The issue is caused by the fact that UAC is enabled and these operating systems use folder virtualization. For Windows 7, the resulting files can be found in c:ProgramData typically, while for Windows Vista they can be found in c:UsersusernameAppDataLocalVirtualStoreProgram Files. If they’re not there, just search for *.FXT, they must be somewhere. To get around this problem, either copy your MT4 folder in a location that’s not protected by UAC (e.g. your desktop) or simply disable UAC (type UAC in the start->search box thing and follow the on-screen process).

For MT4 build 545 or later, head to File -> Open Data Folder and look in MQL4Files.

5. Backtesting an EA with my newly created FXT results in Order Send Error 131. Why?

This might be caused by the lack of a MIN_LOT and LOT_STEP for the symbol in the resulted FXT file. This happens when generating the FXT file with a MT4 client that wasn’t connected to the broker when the script was started. As specified above, your terminal should be connected to your broker when generating an FXT file.

6. What do I do if I get an alert saying Bad CSV Format when I try to convert the CSV I exported from JForex?

This is in all likelihood because you either failed to select a delimiter or selected a dot (.) as the delimiter, so the solution is easy: you go back to JForex, select comma (,) as the delimiter and export the CSV once more. This should be much faster than the first time since the data is cached. If you’re uncertain about the other parameters, take another look at the JForex downloading guide.

7. Is it possible to append tick data to an existing FXT file (and the accompanying HST files)?

No.

8. Is it possible to append tick data to an existing CSV file?

Yes. The CSV2FXT script will disregard duplicate information and even the JForex header line if it is encountered in the middle of the CSV file.

If you are using JForex, you should start your CSV from the time your older CSV ends. You can delete the header row from the new CSV file before concatenating or you can simply skip this step, in which case the CSV2FXT script will skip that line and warn you about it in the experts log. When the export is finished, simply append the new CSV to the older one.

If you are using the PHP scripts, it is ideal to stop your processing at the end of a month. The processing script automatically appends to an existing file so if you resume from the start of the next month your CSV will be perfect. However, you can stop your processing even during the month; for example, if you have a file named EURUSD.csv that ends on 19.03.2012 and then append data starting from 01.03.2012 and ending with 02.04.2012 (e.g. by typing php process_dukascopy_data.php EURUSD 201203 201205 EURUSD.csv), the new data will be appended to your existing CSV and the data between 01.03 and 19.03 will be in your CSV twice. In such a case, the CSV2FXT script will output about 20 errors in your log and spit out an alert about older ticks, but it is smart enough to skip the duplicated data so the resulting FXT should be perfectly fine (although it will take a little bit longer because it has to skip the duplicated period).

9. Why does the CSV2FXT script get stuck as soon as it is started? The progress indicator is not displayed on the chart and the only message displayed in the experts log is “The date column appears to be 0. Sample…”

Most likely this is because you exported the CSV file using JForex but failed to select the comma (,) as the field delimiter as mentioned in the guide. Since for some reason that I fail to grasp the default JForex setting is to use a space as field separator and put several commas at the end of each line, your CSV file is useless and has to be regenerated. The good news is that JForex caches the data so you don’t have to wait for the download once more.

10. How could I change the timeframe of an existing FXT file?

Two steps:

  1. Since the file name contains the timeframe, for instance EURUSD15_0.FXT for an M15 EURUSD FXT file, you have to rename (or copy) the file for the desired timeframe. Assuming you’d want to make it H4, you translate that to minutes (4 hours = 240 minutes) and you rename the file to EURUSD240_0.FXT
  2. Next you have to grab a hex editor and edit the file at offset 0xD0. Change the number to the same one used in the file name in the previous step (but make sure you convert it to hex; using our example above, 240 is 0xF0 so you would have to change it from 0x0F – which is 15 – to 0xF0).

One thing to note that if you perform this change is that the bar count displayed in the results is going to be wrong and indicators running on the backtest timeframe will be misleading because the ticks are stored as part of bars and the bars will be for a different timeframe. Essentially, if your EA has any indicators running on the backtest timeframe, this method is not safe to use.

11. Can I create range bars or Renko bars with CSV2FXT?

Not with the version I created. However, Artur from AZ-Invest has developed a version of the script that works with Renko bars.

Using the tick data

1. Why are my FXT files being overwritten?

You probably didn’t start the MT4 terminal via the Tick Data Suite and your FXT files are not read-only for some reason.

2. Why is my terminal creating an FXT file when I start backtesting?

  • Did you create the FXT file for the currency pair & timeframe that you are trying to use in your backtest?
  • If the answer to the above is yes, did you copy it to the correct location (in recent MT4 builds, head to File -> Open Data Folder to find the right place)?
  • Also see the answer for question #1 above.

3. My backtest runs but I do not get 99% modeling quality. Why?

This is in fact the same question as #2 above.

4. My backtest stops as soon as I click the start button. The backtesting journal tab displays TestGenerator: internal error because the file not opened. What is wrong?

That’s MT4’s way of notifying you that it refuses to overwrite an FXT file that is set read-only and it happens with MT4 builds 509 or earlier. You need to close the MT4 terminal and start it via the Tick Data Suite shortcut.

5. Why does my terminal crash as soon as I press “start” in the backtest user interface?

If you’re not using the latest MT4 build, it’s most likely because the EA was compiled with a build newer than yours and Metaquotes did not think it wise to add ex4 versioning. You can tell this is the problem if attaching the same EA to a chart will also result in a crash. The solution is to use the latest build or get the EA compiled with your build.

6. Why do I get a red bar at the end of the backtest even though my modeling quality is 99%?

Because the FXT you are using was created with an older script. It’s nothing to worry about, though – you can safely ignore it.

7. What can I do if my optimization results window is empty even though MT4 appears to run multiple passes correctly?

That means the results you obtained were not profitable. If you wish to see them nonetheless, you can select the Optimization Results tab, right click inside it and deselect “Skip Useless Results”.

8. I am getting empty results (no trades) in all my optimization passes when using the Walk Forward Analyzer. Is there a workaround?

This only happens with some EAs that need the Metatrader 4 terminal to be connected to the broker even when backtesting, for instance Wallstreet Forex Robot or FAP Turbo. To put it simply, since the FXT is already there, the backtest starts too fast. The only solution for this problem is to add an artificial delay, which can be done by using the Configuration program installed with the Tick Data Suite. Just fire up Configuration and increase the Backtest delay factor to something like 3. This will start the backtest with a sensible delay which should be enough for the terminal to connect to the broker. In case it isn’t, feel free to increase it to something like 10. Set it back to 0 once you’re done with that particular EA unless you want to have a permanent delay when backtesting or optimizing with tick data. Note that this option will not have an effect on Metatrader 4 terminals that are already running and you will need to restart these to take advantage of it.

9. Why are all the volumes in my tick data backtest smaller than 1?

It’s because you are using real spread when creating your FXT with MT4 build 509 or earlier. When enabling this option, the spread is stored in the volume field. If your strategy makes use of the volume number (which is simply the number of ticks in MT4), you need to use fixed spread or employ other strategies such as counting the number of ticks and storing it in an array.

10. Why are all the volumes in my tick data backtest huge numbers?

Same reason as for the previous question, but it only applies to MT4 builds 545 or higher. To get the actual volume, simply apply a bitwise AND 0xFFFFFFFF like this:


volume = Volume[0] & 0xFFFFFFFF;

11. Why does my backtest fail as soon as I attempt to start it with the backtest journal saying “No data for testing.”?

This typically happens when you enabled Use date and the start and end dates you selected are outside the range covered by your FXT.

12. My backtest stops somewhere in the middle, even though the FXT file I created spans a longer time period. How can I fix this?

This typically happens when you’re using MT4 build 600 or higher, you created an FXT file larger than 4GB and you forgot to run MT4 via the Tick Data Suite (the MT4 window title bar should say “… with Tick Data Suite vX.XX”).

If this happens and none of the above are the causes, you should first attempt to backtest the MACD EA using your FXT and if it stops at the same point, you should investigate the source CSV in that range and check the log of the CSV2FXT script for any potential errors.

13. How come my backtest results differ from an optimization cycle results if I am using the same parameters?

This only happens when you are using a start/end date for your optimization and you’re using MT4 build 509 or earlier. Sadly, this is a bug in Metatrader 4: only the first pass of an optimization uses the start and end date you selected; subsequent runs use the full range available in the FXT. This bug was fixed starting with MT4 build 545.

In any case, with MT4 builds 509 and earlier, to get the same outcome when backtesting with the parameters for one of the optimization results, you can either make an FXT that spans exactly the period that you want to optimize for, or alternatively you can simply disable Use date when running the backtest for the selected optimization results (if it’s not the parameters for the first run, that is).

I wrote a strategy in Pine Script in order to backtest it on Trading View. It seems it compiles with no error but when backtesting it says «No Data».
I can’t figure out what is wrong with my code and I will show to you. The Strategy consists of two indicator: Support & Resistance and Awesome Oscillator. The first indicator has been copied from another script and it works (plotting), the second is a simple Awesome Oscillator and obviously it works (plotting).

I added some function in order to get entry signals thanks to Awesome Oscillator and Take Profit and Stop Loss levels thanks to Support & Resistance.

The problem is, even if the script has no recognizable error, it doesn’t place any order.

I tried to play another strategy script to see if it’s a Trading View issue, but indeed an other public strategy works.

The only thing I’ve modified is to move when parameter in a if(condition). No change, still «No Data» error in the Strategy Tester section.

Searching for the Internet result in no answer.

Here my strategy code. The first (longest) part is copied and it works well (Support & Resistance). In the second part I added an Awesome Oscillator, functions and code to execute the strategy.

//@version=4
// Support and Resistance Levels + Zones for 3 time frames, based on volume at fractal levels 
// Original script is thanks to synapticex I have just migrated to version 3, heavily modified it and added Support and Resistance Zones
strategy(title="Consiglio Strategy", shorttitle="Consiglio", overlay=true, format=format.inherit, precision=1, scale=scale.none, pyramiding=0, calc_on_order_fills=true, calc_on_every_tick=true)

risk = input(1, title="% Risk per Trade", minval = 0.01, step=0.1)

// Inputs
// 136 version
// Time Frame 1 = TF1 = Current Time Frame

TF1_Menu        = input(title='Current', defval='S/R Zones', options=['S/R', 'S/R Zones', 'N/A'], type=input.string)
TF1_VolMA1Input = input(title="Current - Volume MA - Threshold",   type=input.integer, defval=6)

TF1 = timeframe.period

// Time Frame 2 = TF2 = Custom 1 Time Frame

TF2_Menu        = input(title='Custom 1', defval='S/R Zones', options=['S/R', 'S/R Zones', 'N/A'], type=input.string)
TF2             = input(title="Custom 1 - Timeframe", type=input.resolution, defval = "240")
TF2_VolMA1Input = input(title="Custom 1 - Volume MA - Threshold",  type=input.integer, defval=6)


// Time Frame 3 = TF3 = Custom 2 Time Frame

TF3_Menu        = input(title='Custom 2', defval='S/R Zones', options=['S/R', 'S/R Zones', 'N/A'], type=input.string)
TF3             = input(title="Custom 2 - Timeframe", type=input.resolution, defval = "1D")
TF3_VolMA1Input = input(title="Custom 2 - Volume MA - Threshold",  type=input.integer, defval=6)

InvertColors       = input(false, title = "Invert Colors - Support / Resistance")


// S/R - Current Time Frame = Time Frame 1 = TF1

TF1_Vol   = security(syminfo.tickerid,TF1, volume)
TF1_VolMA = sma(TF1_Vol, TF1_VolMA1Input)
TF1_High  = security(syminfo.tickerid,TF1, high)
TF1_Low   = security(syminfo.tickerid,TF1, low)
TF1_Open  = security(syminfo.tickerid,TF1, open)
TF1_Close = security(syminfo.tickerid,TF1, close)

TF1_Up     = TF1_High[3] > TF1_High[4] and TF1_High[4] > TF1_High[5] and TF1_High[2] < TF1_High[3] and TF1_High[1] < TF1_High[2] and (TF1_Vol[3] > TF1_VolMA[3]) // or volume[3] > VolMA2Current[3])
TF1_Down   = TF1_Low[3]  < TF1_Low[4]  and TF1_Low[4]  < TF1_Low[5]  and TF1_Low[2]  > TF1_Low[3]  and TF1_Low[1]  > TF1_Low[2]  and (TF1_Vol[3] > TF1_VolMA[3]) // or volume[3] > VolMA2Current[3])


TF1_CalcFractalUp()=>
    TF1_FractalUp =    0.0
    TF1_FractalUp :=   TF1_Up   ? TF1_High[3] : TF1_FractalUp[1] 

TF1_CalcFractalDown()=>
    TF1_FractalDown =  0.0
    TF1_FractalDown := TF1_Down ? TF1_Low[3]  : TF1_FractalDown[1]


TF1_FractalUp   = security(syminfo.tickerid,TF1, TF1_CalcFractalUp())
TF1_FractalDown = security(syminfo.tickerid,TF1, TF1_CalcFractalDown())


// Zones - Current Time Frame = Time Frame 1 = TF1

// Fractal Up Zones

TF1_CalcFractalUpLowerZone()=>
    TF1_FractalUpLowerZone =  0.0
    TF1_FractalUpLowerZone := TF1_Up and TF1_Close[3] > TF1_Open[3] ? TF1_Close[3] : TF1_Up and TF1_Close[3] < TF1_Open[3] ? TF1_Open[3] : TF1_FractalUpLowerZone[1] 

TF1_CalcFractalUpUpperZone()=>
    TF1_FractalUpUpperZone =  0.0
    TF1_FractalUpUpperZone := TF1_Up and TF1_Close[3] > TF1_Open[3] ? (TF1_High[3] - TF1_Close[3]) + TF1_High[3] : TF1_Up and TF1_Close[3] < TF1_Open[3] ? (TF1_High[3] - TF1_Open[3]) + TF1_High[3] : TF1_FractalUpUpperZone[1] 


TF1_FractalUpLowerZone   = security(syminfo.tickerid, TF1, TF1_CalcFractalUpLowerZone())
TF1_FractalUpUpperZone   = security(syminfo.tickerid, TF1, TF1_CalcFractalUpUpperZone())

TF1_ResistanceUpperZone  = TF1_FractalUpUpperZone
TF1_ResistanceLowerZone  = TF1_FractalUpLowerZone


// Fractal Down Zones


TF1_CalcFractalDownUpperZone()=>
    TF1_FractalDownUpperZone =  0.0
    TF1_FractalDownUpperZone := TF1_Down and TF1_Close[3] > TF1_Open[3] ? TF1_Open[3] : TF1_Down and TF1_Close[3] < TF1_Open[3] ? TF1_Close[3] : TF1_FractalDownUpperZone[1]


TF1_CalcFractalDownLowerZone()=>
    TF1_FractalDownLowerZone =  0.0
    TF1_FractalDownLowerZone := TF1_Down and TF1_Close[3] > TF1_Open[3] ? TF1_Low[3] + (TF1_Low[3] - TF1_Open[3]) : TF1_Down and TF1_Close[3] < TF1_Open[3] ? TF1_Low[3] + (TF1_Low[3] - TF1_Close[3]) : TF1_FractalDownLowerZone[1]


TF1_FractalDownLowerZone   = security(syminfo.tickerid, TF1, TF1_CalcFractalDownLowerZone())
TF1_FractalDownUpperZone   = security(syminfo.tickerid, TF1, TF1_CalcFractalDownUpperZone())


TF1_SupportUpperZone       = TF1_FractalDownUpperZone
TF1_SupportLowerZone       = TF1_FractalDownLowerZone

// Colors - Current Time Frame = Time Frame 1 = TF1


TF1_ResistanceColor          = not InvertColors ? color.red  : color.green
TF1_SupportColor             = not InvertColors ? color.green : color.red


TF1_ResZoneColor             = (TF1_FractalUp != TF1_FractalUp[1])? na:color.red
TF1_ResZoneColorInverted     = (TF1_FractalUp != TF1_FractalUp[1])? na:color.green


TF1_SupZoneColor             = (TF1_FractalDown != TF1_FractalDown[1])? na:color.green
TF1_SupZoneColorInverted     = (TF1_FractalDown != TF1_FractalDown[1])? na:color.red


TF1_ResistanceZonesColor     = not InvertColors and TF1_Menu=='S/R Zones' ? TF1_ResZoneColor  : InvertColors and TF1_Menu=='S/R Zones' ? TF1_ResZoneColorInverted : na  // red  : lime
TF1_SupportZonesColor        = not InvertColors and TF1_Menu=='S/R Zones' ? TF1_SupZoneColor  : InvertColors and TF1_Menu=='S/R Zones' ? TF1_SupZoneColorInverted : na  // lime : red


// S/R & S/R Zone Plots - Current Time Frame = Time Frame 1 = TF1


TF1_ResistanceUpZone   = plot(TF1_Menu=='S/R Zones'? TF1_ResistanceUpperZone : na,  "Current Timeframe - Resistance - Upper Zone", color=TF1_ResistanceZonesColor, linewidth=1, style=plot.style_line, transp=45, offset=-3, join=false) // offset=-2
TF1_ResistanceDownZone = plot(TF1_Menu=='S/R Zones'? TF1_ResistanceLowerZone : na,  "Current Timeframe - Resistance - Lower Zone", color=TF1_ResistanceZonesColor, linewidth=1, style=plot.style_line, transp=45, offset=-3, join=false) // offset=-2
fill(TF1_ResistanceUpZone, TF1_ResistanceDownZone, color = TF1_ResistanceZonesColor, transp=93, title = "Current Timeframe - Resistance Zone Shading") 


plot((TF1_Menu=='S/R' or TF1_Menu=='S/R Zones')? TF1_FractalUp   : na, "Current Timeframe - Resistance", color=TF1_ResistanceColor, linewidth=1, style=plot.style_circles, transp=5, offset=-3, join=false)
plot((TF1_Menu=='S/R' or TF1_Menu=='S/R Zones')? TF1_FractalDown : na, "Current Timeframe - Support",    color=TF1_SupportColor,    linewidth=1, style=plot.style_circles, transp=5, offset=-3, join=false)


TF1_SupportUpZone   = plot(TF1_Menu=='S/R Zones'? TF1_SupportUpperZone       : na, "Current Timeframe - Support - Uper Zone",    color=TF1_SupportZonesColor,    linewidth=1, style=plot.style_line, transp=45, offset=-3, join=false)
TF1_SupportDownZone = plot(TF1_Menu=='S/R Zones'? TF1_SupportLowerZone       : na, "Current Timeframe - Support - Lower Zone",   color=TF1_SupportZonesColor,    linewidth=1, style=plot.style_line, transp=45, offset=-3, join=false)
fill(TF1_SupportUpZone, TF1_SupportDownZone, color =TF1_SupportZonesColor,          transp=93, title = "Current Timeframe - Support Zone Shading")



// S/R - Custom 1 Time Frame = Time Frame 2 = TF2

TF2_Vol   = security(syminfo.tickerid,TF2, volume)
TF2_VolMA = sma(TF2_Vol, TF2_VolMA1Input)
TF2_High  = security(syminfo.tickerid,TF2, high)
TF2_Low   = security(syminfo.tickerid,TF2, low)
TF2_Open  = security(syminfo.tickerid,TF2, open)
TF2_Close = security(syminfo.tickerid,TF2, close)

TF2_Up     = TF2_High[3] > TF2_High[4] and TF2_High[4] > TF2_High[5] and TF2_High[2] < TF2_High[3] and TF2_High[1] < TF2_High[2] and (TF2_Vol[3] > TF2_VolMA[3]) // or volume[3] > VolMA2Custom 1[3])
TF2_Down   = TF2_Low[3]  < TF2_Low[4]  and TF2_Low[4]  < TF2_Low[5]  and TF2_Low[2]  > TF2_Low[3]  and TF2_Low[1]  > TF2_Low[2]  and (TF2_Vol[3] > TF2_VolMA[3]) // or volume[3] > VolMA2Custom 1[3])


TF2_CalcFractalUp()=>
    TF2_FractalUp =    0.0
    TF2_FractalUp :=   TF2_Up   ? TF2_High[3] : TF2_FractalUp[1] 

TF2_CalcFractalDown()=>
    TF2_FractalDown =  0.0
    TF2_FractalDown := TF2_Down ? TF2_Low[3]  : TF2_FractalDown[1]


TF2_FractalUp   = security(syminfo.tickerid,TF2, TF2_CalcFractalUp())
TF2_FractalDown = security(syminfo.tickerid,TF2, TF2_CalcFractalDown())


// Zones - Custom 1 Time Frame = Time Frame 2 = TF2

// Fractal Up Zones

TF2_CalcFractalUpLowerZone()=>
    TF2_FractalUpLowerZone =  0.0
    TF2_FractalUpLowerZone := TF2_Up and TF2_Close[3] > TF2_Open[3] ? TF2_Close[3] : TF2_Up and TF2_Close[3] < TF2_Open[3] ? TF2_Open[3] : TF2_FractalUpLowerZone[1] 

TF2_CalcFractalUpUpperZone()=>
    TF2_FractalUpUpperZone =  0.0
    TF2_FractalUpUpperZone := TF2_Up and TF2_Close[3] > TF2_Open[3] ? (TF2_High[3] - TF2_Close[3]) + TF2_High[3] : TF2_Up and TF2_Close[3] < TF2_Open[3] ? (TF2_High[3] - TF2_Open[3]) + TF2_High[3] : TF2_FractalUpUpperZone[1] 


TF2_FractalUpLowerZone   = security(syminfo.tickerid, TF2, TF2_CalcFractalUpLowerZone())
TF2_FractalUpUpperZone   = security(syminfo.tickerid, TF2, TF2_CalcFractalUpUpperZone())

TF2_ResistanceUpperZone  = TF2_FractalUpUpperZone
TF2_ResistanceLowerZone  = TF2_FractalUpLowerZone


// Fractal Down Zones


TF2_CalcFractalDownUpperZone()=>
    TF2_FractalDownUpperZone =  0.0
    TF2_FractalDownUpperZone := TF2_Down and TF2_Close[3] > TF2_Open[3] ? TF2_Open[3] : TF2_Down and TF2_Close[3] < TF2_Open[3] ? TF2_Close[3] : TF2_FractalDownUpperZone[1]


TF2_CalcFractalDownLowerZone()=>
    TF2_FractalDownLowerZone =  0.0
    TF2_FractalDownLowerZone := TF2_Down and TF2_Close[3] > TF2_Open[3] ? TF2_Low[3] + (TF2_Low[3] - TF2_Open[3]) : TF2_Down and TF2_Close[3] < TF2_Open[3] ? TF2_Low[3] + (TF2_Low[3] - TF2_Close[3]) : TF2_FractalDownLowerZone[1]


TF2_FractalDownLowerZone   = security(syminfo.tickerid, TF2, TF2_CalcFractalDownLowerZone())
TF2_FractalDownUpperZone   = security(syminfo.tickerid, TF2, TF2_CalcFractalDownUpperZone())


TF2_SupportUpperZone       = TF2_FractalDownUpperZone
TF2_SupportLowerZone       = TF2_FractalDownLowerZone

// Colors - Custom 1 Time Frame = Time Frame 2 = TF2


TF2_ResistanceColor          = not InvertColors ? color.red : color.green
TF2_SupportColor             = not InvertColors ? color.green : color.red


TF2_ResZoneColor             = (TF2_FractalUp != TF2_FractalUp[1])? na:color.red
TF2_ResZoneColorInverted     = (TF2_FractalUp != TF2_FractalUp[1])? na:color.green


TF2_SupZoneColor             = (TF2_FractalDown != TF2_FractalDown[1])? na:color.green
TF2_SupZoneColorInverted     = (TF2_FractalDown != TF2_FractalDown[1])? na:color.red


TF2_ResistanceZonesColor     = not InvertColors and TF2_Menu=='S/R Zones' ? TF2_ResZoneColor  : InvertColors and TF2_Menu=='S/R Zones' ? TF2_ResZoneColorInverted : na  // fuchsia : green
TF2_SupportZonesColor        = not InvertColors and TF2_Menu=='S/R Zones' ? TF2_SupZoneColor  : InvertColors and TF2_Menu=='S/R Zones' ? TF2_SupZoneColorInverted : na  // green   : fuchsia


// S/R & S/R Zone Plots - Custom 1 Time Frame = Time Frame 2 = TF2


TF2_ResistanceUpZone   = plot(TF2_Menu=='S/R Zones'? TF2_ResistanceUpperZone : na,  "Custom 1 Timeframe - Resistance - Upper Zone", color=TF2_ResistanceZonesColor, linewidth=1, style=plot.style_line, transp=45, offset=-3, join=false) // offset=-2
TF2_ResistanceDownZone = plot(TF2_Menu=='S/R Zones'? TF2_ResistanceLowerZone : na,  "Custom 1 Timeframe - Resistance - Lower Zone", color=TF2_ResistanceZonesColor, linewidth=1, style=plot.style_line, transp=45, offset=-3, join=false) // offset=-2
fill(TF2_ResistanceUpZone, TF2_ResistanceDownZone, color = TF2_ResistanceZonesColor, transp=93, title = "Custom 1 Timeframe - Resistance Zone Shading") 


plot((TF2_Menu=='S/R' or TF2_Menu=='S/R Zones')? TF2_FractalUp   : na, "Custom 1 Timeframe - Resistance", color=TF2_ResistanceColor, linewidth=1, style=plot.style_circles, transp=5, offset=-3, join=false)
plot((TF2_Menu=='S/R' or TF2_Menu=='S/R Zones')? TF2_FractalDown : na, "Custom 1 Timeframe - Support",    color=TF2_SupportColor,    linewidth=1, style=plot.style_circles, transp=5, offset=-3, join=false)


TF2_SupportUpZone   = plot(TF2_Menu=='S/R Zones'? TF2_SupportUpperZone       : na,  "Custom 1 Timeframe - Support - Uper Zone",    color=TF2_SupportZonesColor,    linewidth=1, style=plot.style_line, transp=45, offset=-3, join=false)
TF2_SupportDownZone = plot(TF2_Menu=='S/R Zones'? TF2_SupportLowerZone       : na,  "Custom 1 Timeframe - Support - Lower Zone",   color=TF2_SupportZonesColor,    linewidth=1, style=plot.style_line, transp=45, offset=-3, join=false)
fill(TF2_SupportUpZone, TF2_SupportDownZone, color =TF2_SupportZonesColor,           transp=93, title = "Custom 1 Timeframe - Support Zone Shading")



// S/R - Custom 2 Time Frame = Time Frame 3 = TF3

TF3_Vol   = security(syminfo.tickerid,TF3, volume)
TF3_VolMA = sma(TF3_Vol, TF3_VolMA1Input)
TF3_High  = security(syminfo.tickerid,TF3, high)
TF3_Low   = security(syminfo.tickerid,TF3, low)
TF3_Open  = security(syminfo.tickerid,TF3, open)
TF3_Close = security(syminfo.tickerid,TF3, close)

TF3_Up     = TF3_High[3] > TF3_High[4] and TF3_High[4] > TF3_High[5] and TF3_High[2] < TF3_High[3] and TF3_High[1] < TF3_High[2] and (TF3_Vol[3] > TF3_VolMA[3]) // or volume[3] > VolMA2Custom 2[3])
TF3_Down   = TF3_Low[3]  < TF3_Low[4]  and TF3_Low[4]  < TF3_Low[5]  and TF3_Low[2]  > TF3_Low[3]  and TF3_Low[1]  > TF3_Low[2]  and (TF3_Vol[3] > TF3_VolMA[3]) // or volume[3] > VolMA2Custom 2[3])


TF3_CalcFractalUp()=>
    TF3_FractalUp =    0.0
    TF3_FractalUp :=   TF3_Up   ? TF3_High[3] : TF3_FractalUp[1] 

TF3_CalcFractalDown()=>
    TF3_FractalDown =  0.0
    TF3_FractalDown := TF3_Down ? TF3_Low[3]  : TF3_FractalDown[1]


TF3_FractalUp   = security(syminfo.tickerid,TF3, TF3_CalcFractalUp())
TF3_FractalDown = security(syminfo.tickerid,TF3, TF3_CalcFractalDown())


// Zones - Custom 2 Time Frame = Time Frame 3 = TF3

// Fractal Up Zones

TF3_CalcFractalUpLowerZone()=>
    TF3_FractalUpLowerZone =  0.0
    TF3_FractalUpLowerZone := TF3_Up and TF3_Close[3] > TF3_Open[3] ? TF3_Close[3] : TF3_Up and TF3_Close[3] < TF3_Open[3] ? TF3_Open[3] : TF3_FractalUpLowerZone[1] 

TF3_CalcFractalUpUpperZone()=>
    TF3_FractalUpUpperZone =  0.0
    TF3_FractalUpUpperZone := TF3_Up and TF3_Close[3] > TF3_Open[3] ? (TF3_High[3] - TF3_Close[3]) + TF3_High[3] : TF3_Up and TF3_Close[3] < TF3_Open[3] ? (TF3_High[3] - TF3_Open[3]) + TF3_High[3] : TF3_FractalUpUpperZone[1] 


TF3_FractalUpLowerZone   = security(syminfo.tickerid, TF3, TF3_CalcFractalUpLowerZone())
TF3_FractalUpUpperZone   = security(syminfo.tickerid, TF3, TF3_CalcFractalUpUpperZone())

TF3_ResistanceUpperZone  = TF3_FractalUpUpperZone
TF3_ResistanceLowerZone  = TF3_FractalUpLowerZone


// Fractal Down Zones


TF3_CalcFractalDownUpperZone()=>
    TF3_FractalDownUpperZone =  0.0
    TF3_FractalDownUpperZone := TF3_Down and TF3_Close[3] > TF3_Open[3] ? TF3_Open[3] : TF3_Down and TF3_Close[3] < TF3_Open[3] ? TF3_Close[3] : TF3_FractalDownUpperZone[1]


TF3_CalcFractalDownLowerZone()=>
    TF3_FractalDownLowerZone =  0.0
    TF3_FractalDownLowerZone := TF3_Down and TF3_Close[3] > TF3_Open[3] ? TF3_Low[3] + (TF3_Low[3] - TF3_Open[3]) : TF3_Down and TF3_Close[3] < TF3_Open[3] ? TF3_Low[3] + (TF3_Low[3] - TF3_Close[3]) : TF3_FractalDownLowerZone[1]


TF3_FractalDownLowerZone   = security(syminfo.tickerid, TF3, TF3_CalcFractalDownLowerZone())
TF3_FractalDownUpperZone   = security(syminfo.tickerid, TF3, TF3_CalcFractalDownUpperZone())


TF3_SupportUpperZone       = TF3_FractalDownUpperZone
TF3_SupportLowerZone       = TF3_FractalDownLowerZone

// Colors - Custom 2 Time Frame = Time Frame 3 = TF3


TF3_ResistanceColor          = not InvertColors ? color.red : color.green 
TF3_SupportColor             = not InvertColors ? color.red : color.green   


TF3_ResZoneColor             = (TF3_FractalUp != TF3_FractalUp[1])? na:color.red
TF3_ResZoneColorInverted     = (TF3_FractalUp != TF3_FractalUp[1])? na:color.green


TF3_SupZoneColor             = (TF3_FractalDown != TF3_FractalDown[1])? na:color.red
TF3_SupZoneColorInverted     = (TF3_FractalDown != TF3_FractalDown[1])? na:color.green


TF3_ResistanceZonesColor     = not InvertColors and TF3_Menu=='S/R Zones' ? TF3_ResZoneColor  : InvertColors and TF3_Menu=='S/R Zones' ? TF3_ResZoneColorInverted : na  // orange : blue
TF3_SupportZonesColor        = not InvertColors and TF3_Menu=='S/R Zones' ? TF3_SupZoneColor  : InvertColors and TF3_Menu=='S/R Zones' ? TF3_SupZoneColorInverted : na  // blue   : orange


// S/R & S/R Zone Plots - Custom 2 Time Frame = Time Frame 3 = TF3


TF3_ResistanceUpZone   = plot(TF3_Menu=='S/R Zones'? TF3_ResistanceUpperZone : na,  "Custom 2 Timeframe - Resistance - Upper Zone", color=TF3_ResistanceZonesColor, linewidth=1, style=plot.style_line, transp=45, offset=-3, join=false) // offset=-2
TF3_ResistanceDownZone = plot(TF3_Menu=='S/R Zones'? TF3_ResistanceLowerZone : na,  "Custom 2 Timeframe - Resistance - Lower Zone", color=TF3_ResistanceZonesColor, linewidth=1, style=plot.style_line, transp=45, offset=-3, join=false) // offset=-2
fill(TF3_ResistanceUpZone, TF3_ResistanceDownZone, color = TF3_ResistanceZonesColor, transp=93,  title = "Custom 2 Timeframe - Resistance Zone Shading") // ResistanceColorCustom 2)


plot((TF3_Menu=='S/R' or TF3_Menu=='S/R Zones')? TF3_FractalUp   : na, "Custom 2 Timeframe - Resistance", color=TF3_ResistanceColor, linewidth=1, style=plot.style_circles, transp=5, offset=-3, join=false)
plot((TF3_Menu=='S/R' or TF3_Menu=='S/R Zones')? TF3_FractalDown : na, "Custom 2 Timeframe - Support",    color=TF3_SupportColor,    linewidth=1, style=plot.style_circles, transp=5, offset=-3, join=false)


TF3_SupportUpZone   = plot(TF3_Menu=='S/R Zones'? TF3_SupportUpperZone       : na, "Custom 2 Timeframe - Support - Uper Zone",    color=TF3_SupportZonesColor,    linewidth=1, style=plot.style_line, transp=45, offset=-3, join=false)
TF3_SupportDownZone = plot(TF3_Menu=='S/R Zones'? TF3_SupportLowerZone       : na, "Custom 2 Timeframe - Support - Lower Zone",   color=TF3_SupportZonesColor,    linewidth=1, style=plot.style_line, transp=45, offset=-3, join=false)
fill(TF3_SupportUpZone, TF3_SupportDownZone, color =TF3_SupportZonesColor,           transp=93, title = "Custom 2 Timeframe - Support Zone Shading")

// AWESOME OSCILLATOR
src = close

AOthreshold = input(defval = 80, title="AO Threshold", type=input.float, minval=0, step=0.1)
AO = (sma(hl2,5) - sma(hl2,34)) / 2

// FUNCTIONS

RRR() => 
    rrr = (1 + (strategy.grossprofit / strategy.wintrades) / (strategy.grossloss / strategy.losstrades)) * (strategy.wintrades / (strategy.wintrades + strategy.losstrades)) - 1
    na(rrr) or rrr < 0 ? 1 : rrr

upperLimit() => min(TF1_ResistanceLowerZone, min(TF2_ResistanceLowerZone, TF3_ResistanceLowerZone))
lowerLimit() => max(TF1_SupportUpperZone, max(TF2_SupportUpperZone, TF3_SupportUpperZone))

entryPrice(takeProfit, stopLoss) => ((RRR() * stopLoss) + takeProfit) / (RRR() + 1)

safeVolumeLong(entry, stopLoss) => ((strategy.initial_capital + strategy.netprofit) * risk / 100) / (entry - stopLoss) * entry
safeVolumeShort(stopLoss, entry) => ((strategy.initial_capital + strategy.netprofit) * risk / 100) / (stopLoss - entry) * stopLoss

// SIGNALS

longCondition = false
shortCondition = false

if(AO > AOthreshold)
    longCondition = (AO[0] - AO[1]) > 0

if(AO < AOthreshold)
    shortCondition = (AO[0] - AO[1]) < 0

// EXECUTE STRATEGY
longEntryPrice = entryPrice(upperLimit(), lowerLimit())
shortEntryPrice = entryPrice(lowerLimit(), upperLimit())
volumeLong = safeVolumeLong(longEntryPrice, lowerLimit()) / longEntryPrice
volumeShort = safeVolumeShort(lowerLimit(), shortEntryPrice) / shortEntryPrice
if(longCondition)
    strategy.entry('Long entry', strategy.long, volumeLong, longEntryPrice, stop=na)
    strategy.entry('Short entry', strategy.short, volumeShort, shortEntryPrice, stop=na)
if(shortCondition)
    strategy.exit('Long exit', 'Long entry', qty=na, qty_percent=100.0, limit=upperLimit(), stop=lowerLimit())
    strategy.exit('Short exit', 'Short entry', qty=na, qty_percent=100.0, limit=lowerLimit(), stop=upperLimit())

I expect at least some orders being placed but no one shows up when backtesting. What’s wrong with my code?

Понравилась статья? Поделить с друзьями:
  • Ошибка no compatible graphics device found
  • Ошибка no bus что это такое
  • Ошибка no bootable device на ноутбуке lenovo
  • Ошибка no bootable device на ноутбуке acer что делать
  • Ошибка no bootable device на ноутбуке acer ноутбук