Assigning Position.Priority
Author: kyokushin
Creation Date: 2/11/2014 2:46 PM
profile picture

kyokushin

#1
I tried to assign position priority to my strategy like in the example in the user guide. I'm facing trouble passing the priority value as the signalName parameter in the entry signal to use it for trading. I always get errors when compiling. Could you help me coding this?

CODE:
Please log in to see this code.
profile picture

Cone

#2
The script compiles fine for me, but technically, the priority shouldn't be set for the LastPosition unless you're absolutely sure that you've created a position (as shown in the QuickRef) ;

CODE:
Please log in to see this code.


What's the point of using priority for the entry signal? You won't be able to use fixed exit logic that looks for a specific RSI value, if that's the intention. Otherwise, explain what the goal is.
profile picture

kyokushin

#3
The point is to have a priority when more trade alerts are created then there is buying power for all trades.
profile picture

kyokushin

#4
What else can I do to assign priority and sort the trade alerts when too much alerts are created?
profile picture

Cone

#5
Okay, so you want the priority in the signal name in order to sort the Alerts. That's fine. Then you just have to remove the if (p.EntrySignal.Contains("Group1|")) statement so that the exit logic can trigger .
profile picture

kyokushin

#6
Thanks, Cone
profile picture

mikesblack

#7
I am having a hard time assigning priority to the following system. I have a system that is very similar but it runs with Priority. Both systems compile without error. Is there anything that I'm missing? Thanks.
System that won't run:
CODE:
Please log in to see this code.


System that runs:

CODE:
Please log in to see this code.
profile picture

Eugene

#8
How many more times do I have to answer this question? I already showed you how to assign Position.Priority to the very same code (post #10), you understood (see your own follow-up post #12), and now you again don't?

Trade name based on indicator value

Let me know that you've read it and I'll delete the duplicate question. And I'd appreciate if for requesting minor modifications of this code you'd reuse that (original) thread. Thanks.
profile picture

mikesblack

#9
It was a simple fix. I has SellAtMarket(bar + 1, p, Bars.FormalValue(atrp[bar])) , when I should have had p1. Same careless mistake. Sorry:(
profile picture

Eugene

#10
That does not fix the Position.Priority assignment.
profile picture

mikesblack

#11
I thought it did. Could you provide further explanation?
profile picture

Eugene

#12
Position.Priority is assigned at the time of its creation, not exit. Whatever you fixed with the SellAtMarket did not apply. Re-examine your own code referenced in my post #8 above.
profile picture

mikesblack

#13
I'm not sure how I didn't assign Position.Priority at time of creation. Having looked at example in post #8 and I'm still unclear what you are instructing me to do.

Please look at the code below . Am I not assigning Position.Priority here?:
CODE:
Please log in to see this code.
profile picture

Eugene

#14
You are but it's not entirely correct. If you carefully re-examine the QuickRef example for Position.Priority or your own code referenced in my post #8, you'll see what you're missing. Specifically, if a Position wasn't created due to insufficient capital, you will still attempt the property assignment for LastActivePosition which may cause a runtime error.
profile picture

mikesblack

#15
Does that mean I should write if position.priority is not null then LastActivePosition.Priority = ATRP.Series(Bars,4)[bar];
profile picture

Cone

#16
Almost. Only set Position Priority if the trading signal returns a Position (i.e., NOT null)... like the example....

CODE:
Please log in to see this code.
profile picture

mikesblack

#17
I see, Thanks Robert. I'll try that.

Actually, Looking back I had that commented out.
CODE:
Please log in to see this code.

Removing that comment actually prevents the program fro running. Is the order incorrect or should I exclude one of these lines of code? When I run the program with this line commented out the program does run and shows up as expected as position name on the Trades tab.

I was able to demonstrate what Eugene stated in #14 by starting with $500 starting capitol creating a run time error. So I guess at this point I am hung up on the syntax.

EDIT
Disregard the attachment

EDIT
I believe this is correct. No runtime error with $100 starting capitol.

CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).