[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 32

 

Dear Professionals! I have recently become interested in trading commodity calendar and intercontract spreads in the futures market. In this regard, there is a need for synthetic instrument charts. The idea is to build a candlestick chart calculated using OHLC price difference between petrol (XRB) and heating oil (HO), for example. I tried to solve this task using my own resources since the calculation formula is simple - one has only to calculate the difference between the prices of the instruments and save the obtained values in a history file and use them in an autonomous mode applying various indicators to them. Fortunately, there are several ready-made scripts for writing synthetic charts, such as PeriodConverter. I decided to start with a simple one. I tried to add the code to the specified script which subtracts prices of another symbol from the chart prices of which the script is applied to corresponding bars (with the same opening time). In order not to avoid writing code for synchronizing the bars of two instruments by their open time, I introduced a parameter which blocks only the last, say, 50 bars for calculation since in most cases these last bars should not be synchronized either by their open time or by their indexation as they are already synchronized. I have intentionally combined the tools in such a way that negative price values are not obtained during the calculations because, as far as I know, the terminal does not display them on the chart. Here is what I have got. When opening a synthetic chart obtained using the upgraded script in the stand-alone mode, the terminal cannot display more than half of the calculated bars! However, if the price subtraction operation is replaced with the addition operation in the script, all calculated bars are plotted. What is the difference between the addition and subtraction operations? The same is true for the operations of multiplication and division - when multiplying the relevant prices, the bars on the synthetic chart are displayed normally, but when dividing, less than half of the bars are displayed again! You can say that perhaps a zero got into the denominator during division. But I checked the calculated arrays with the Comment function and it outputs correct values every time, i.e. the division by zero operation was not present in my tests. And now I'm stumped, don't know what to do with it.

If you are not difficult esteemed professionals, please advise in what lies the dog! I spread the attachment and his work. Look at the code, please, what you need to add or change to make the script work normally. I should at least get some standalone charts, it doesn't need to be updated in real time, because spread trading is usually done on medium term, in terms of days to weeks, so the speed of drawing charts is not critical. Or perhaps the idea of creating such charts is not feasible at all?

 
hoz:

So, how will the logic change by moving the bracket down a line? After all, the code structure will remain the same and so will the logic...

this is true, but this concise variant differs not in this way. In the first case, first we were looking at the value of the n variable and then at ind. The difference is that after comparing n we will anyway check the value of ind. But if we start by checking ind and then n, then number of operations will fall by 45-49%, because ind is empty in most cases.
 
Guys, remind me where to look at the New Year trading schedule and trading conditions... spreads will probably increase by 5 times and margin requirements
 

Does anyone know how to make free spreadsheet editors like OpenOffice or LibreOffice not delete the first zero in the text format?

I've read everything I can on the web. Not found anything. Why all similar editors are set in such a way? Moreover, in all editors it is written that the text format outputs everything as written.

 
Zhunko:

Does anyone know how to make free spreadsheet editors like OpenOffice or LibreOffice not delete the first zero in the text format?

I've read everything I can on the web. Not found anything. Why all similar editors are set in such a way? Moreover, in all editors it is written that the text format outputs everything as written.


Maybe write in inverted commas? ""
 
keep87:

This is true, but this is not what is different in the concise version. In the first case we first look at the value of n and then ind. and in the second case it is the other way around. The difference is that after comparing n we will anyway check the value of ind. But if we start by checking ind and then n, number of operations will fall by 45-49%, because ind is empty in most cases.

Exactly! I'm surprised, indeed. I get it all now, thank you.
 
Replikant:

Thank you!!!

but I'm afraid "a little" won't work))) - I have a three-storey boolean formula with 16 bool-type parameters)

What a load you've got... Take int as many as 16 bits and go through every bit...

//|                                                         test.mq4 |
//|                              Copyright © 2012 Mikhail Kozhemyako |
//|                                               ua3xcm@obninsk.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012 Mikhail Kozhemyako"
#property link      "ua3xcm@obninsk.com"
extern  int Биты=0;
bool СработалоУсловие№_i;
int init()
  {
   return(0);
  }
int deinit()
  {
   return(0);
  }
int start()
  {
   int i;
   int Сдвиг=1;
// Гденить здесь нужно определиться с вашими условиями
   for(i=0;i<=15;i++)
    {
     if(СработалоУсловие№_i)
      {
       Биты=Биты | Сдвиг;
      }
     Сдвиг=Сдвиг << 1; 
    }
   for(i=0;i<=15;i++)
    {
     if(0x0001 & Биты == 1)
      {
       // Делать что-то по условию i
      }
     Биты = Биты >> 1;
    }
   return(0);
  }

And in the tester, set the bit variable perobore from 0 to 65535 in increments of 1.

I don't know, I've done it, I think it should work....

 
Good evening! Tell me, on the screenshot of the test it says the percentage of winning short trades0. These are sells, aren't they? So I take it none of them were profitable? Does this indicate a steep imbalance?
 
Dimka-novitsek:
Good evening! Tell me, on the screenshot of the test it says the percentage of winning short trades0. These are sells, aren't they? So I take it none of them were profitable? Does this indicate a steep imbalance?

Yes, it does Short-Sell-Short. But maybe you just didn't have them open for some reason.
 
chief2000:

Should I write it in quotes? ""

How do you process this? A special format for crooked programmes? Some of the information is in inverted commas, some without... Or is everything in quotes?

It's somehow wrong to write zeros in quotes if it's text. In CSV files everything is text. It's the user who decides what and how to process, not the editor.

For Excel, there is an option to put an apostrophe in front of the text. Solves all visualization problems, but not the content. Why the extra character?

Reason: