699
edits
Line 184: | Line 184: | ||
This signal '''Portfolio_SpreadTradingSystem.Slave Signal''' is calculated for the second instrument of the pair. It monitors all entries and exits generated by the previous signal '''Portfolio_SpreadTradingSystem.Master Signal''' for the main instrument of the pair and trades in the opposite direction. Firstly, all synchronization is done when '''MPMoney''' variable returned by master strategy changes. | This signal '''Portfolio_SpreadTradingSystem.Slave Signal''' is calculated for the second instrument of the pair. It monitors all entries and exits generated by the previous signal '''Portfolio_SpreadTradingSystem.Master Signal''' for the main instrument of the pair and trades in the opposite direction. Firstly, all synchronization is done when '''MPMoney''' variable returned by master strategy changes. | ||
<syntaxhighlight>value1 = pmms_from_portfolio_currency( pmm_get_my_named_num("MPMoney") );</syntaxhighlight> | <syntaxhighlight>value1 = pmms_from_portfolio_currency(pmm_get_my_named_num("MPMoney") );</syntaxhighlight> | ||
We extract this variable and convert it from portfolio currency into instrument currency. Then, based on its value, we calculate the number of contracts for potential entry positions: | We extract this variable and convert it from portfolio currency into instrument currency. Then, based on its value, we calculate the number of contracts for potential entry positions: | ||
Line 215: | Line 215: | ||
If it has closed, we’ll close the position for the second instrument as well. If the main instrument has an open position, then we will determine the position’s direction for the second instrument: | If it has closed, we’ll close the position for the second instrument as well. If the main instrument has an open position, then we will determine the position’s direction for the second instrument: | ||
<syntaxhighlight>if 0 < value1 then begin // | <syntaxhighlight>if 0 < value1 then begin // buy</syntaxhighlight> | ||
Value1 > 0 means that to synchronize the positions we should buy. There can be two cases: | Value1 > 0 means that to synchronize the positions we should buy. There can be two cases: |