1 (edited by Popov 2021-11-27 11:07:15)

Topic: Forumlar to get back from magicnumber the strategynumber

Hi,

Can someone help? Now Magic Numbers formula is

int GetMagicNumber(int strategyIndex)
  {
   return 1000 * Base_Magic_Number + strategyIndex;
  }

I need Formular to get it reverse. So that I only get the strategy number

Re: Forumlar to get back from magicnumber the strategynumber

I think this will solve my problem as well.
Trying to figure out which strategy, portfolio is using, so need the strategy number...

Re: Forumlar to get back from magicnumber the strategynumber

The strategy number is in the "strategyIndex" variable.
Please note that the first strategy has an index 0.

The easiest way to have Magic Number equal to the strategy number is to change the formula to:

int GetMagicNumber(int strategyIndex)
  {
   return strategyIndex + 1;
  }

It will make the first strategy with magic number 1, the second with magic number 2, and so on.

Be careful to not override the magic number of one portfolio with another when they run on the same symbol.

The Portfolio Expert distinguishes the positions by symbols, so you can have the same magic number in different charts.

Re: Forumlar to get back from magicnumber the strategynumber

Ohh I probably misunderstood the questions.

If you ask how to convert a magic number to a strategy number, it is:

    int strategyIndex = magicNumber - 1000 * Base_Magic_Number;