# Improving the readability of formulas through the formula’s variables

If Subx team enter such an object as *formula’s variables* in the QM, then the formulas will become much easier to write and read. For example, it could be implemented like this.

The formula editor will allow an optional section with the definition of *formula’s variables* according to this scheme:

*

‘**[**‘ – the opening tag of the f*ormula’s variables* definition section;

**Set Variables**: **$a** = definition of the variable ‘**a**‘ through the QM functions;

…………………..**$b** = definition of the variable ‘**b**‘ using the QM function;

……………………………………………………………………………………….;

…………………..**$n** = definition of the variable ‘**n**‘ through the QM functions;

‘**]**‘ – the closing tag of the *formula’s variables* definition section.

*

Now, let’s look at the imaginary application of the *formula’s variables* in the formula from this forum.

*

Pay attention to how much easier it became to read **If**() logic. Imagine that you need to slightly to change the parameters of **Select**() – you will only do this once.

*

It would be interesting to hear your feedback on this proposal, so please speak out.

Tahir, *the formula’s variables* should be an **optional feature**, despite the fact that in the second picture it is written “AS IT SHOULD BE”. Who wants to and to whom it is convenient, he will use *the formula’s variables*. The QM’s formula editor just needs to get this **optional feature**, and it’s up to the Modeler how to use it. Important, this option will significantly reduce the editing time and debugging time of complex and very complex formulas. The simple formulas can be written traditionally.

*

**

***

**

*

1. // This is my realy working formula. Who can quickly understand its logic?

: =

ClearZero( -If( Sum( Select( InvBuying::Qty, InvBuying::ByNum, #BuyLst ), If( #SellLst > 1, SellLst[1] .. SellLst[~PREV], 0 ) ) <

Sum( Select( InvSelling::Qty, InvSelling::SlNum, #SellLst ), If( #BuyLst > 1, BuyLst[1] .. BuyLst[~PREV], 0 ) ),

Sum( Select( InvBuying::Qty, InvBuying::ByNum, #BuyLst ), If( #SellLst > 1, SellLst[1] .. SellLst[~PREV], 0 ) ),

Sum( Select( InvSelling::Qty, InvSelling::SlNum, #SellLst ), If( #BuyLst > 1, BuyLst[1] .. BuyLst[~PREV], 0 ) )))

*

**

***

**

*

So, Anyone who likes this possible option, vote it.

Good luck.