Hello,
I am trying to program a PMM Strategy where the entry of orders by symbol is limited regardless of the number of strategies that there are on that symbol. For example, if there is already a long strategy in gold that another strategy on gold can not enter long.
This is the way that has occurred to me but something is wrong:
variables: inLong(0), inShort(0);
arrays: strategiesLong[](-1), strategiesShort[](-1);
inLong = pmms_strategies_in_long_count(strategiesLong);
inShort = pmms_strategies_in_short_count(strategiesShort);
for idx = 0 to portfoliostrategies - 1
begin
simbolo1=pmms_strategy_symbol(idx);
simbolo[idx]=simbolo1;
end;
for idx = 0 to portfoliostrategies - 1
begin
value1=array_compare(simbolo,idx,simbolo,idx+1,portfoliostrategies);
if value1=0 then
begin
if inlong=0 then
begin
pmms_strategy_allow_long_entries(idx);
pmms_strategy_set_entry_contracts(idx,con[idx]);
end
else
pmms_strategy_deny_long_entries(idx);
end
else
pmms_strategy_allow_entries(idx);
end;
Can somebody tell me what fails?? Thanks!
[Portfolio] Pmm Strategy Programing Problem [SOLVED]
-
- Posts: 36
- Joined: 25 Aug 2007
- Has thanked: 6 times
- Been thanked: 1 time
Re: Pmm Strategy Programing Problem
You are trying to compare n=portfoliostrategies elements starting from an (increasing) element idx+1 - in an array that has a max number of portfoliostrategies elements.value1=array_compare(simbolo,idx,simbolo,idx+1,portfoliostrategies);
Try value1=array_compare(simbolo,idx,simbolo,idx+1,portfoliostrategies-idx-1);
This should fix this programming error, but I am not sure your logic is right.
-
- Posts: 36
- Joined: 25 Aug 2007
- Has thanked: 6 times
- Been thanked: 1 time
Re: Pmm Strategy Programing Problem
Thank you very much
Effectively, correct the error but as you say the logic is not right.
I miss a function that tells me the strategies position by symbol. That would make everything easier.
Regards
Effectively, correct the error but as you say the logic is not right.
I miss a function that tells me the strategies position by symbol. That would make everything easier.
Regards
Re: Pmm Strategy Programing Problem
One way would be to split one portfolio strategy applied on N symbols into separate N strategies. You can easily do this by setting up one, and then "cloning" (right-click -menu).
But in general be aware that when you "deny entry" at the portfolio level then this entry is 'skipped' also in the strategy itself.
So if your strategy logic assumes reversals - you will have problems.
Another way is to communicate positions to the portfolio signal via pmm_set(get)_strategy_named_num/str..
But in general be aware that when you "deny entry" at the portfolio level then this entry is 'skipped' also in the strategy itself.
So if your strategy logic assumes reversals - you will have problems.
Another way is to communicate positions to the portfolio signal via pmm_set(get)_strategy_named_num/str..