Limit orders same price, short orders never triggered
Author: alsilva86
Creation Date: 1/10/2017 6:19 PM
profile picture

alsilva86

#1
Hello!

Please could you help?

I am having some problems with my limit orders, they all go with same price no matter what I input as their price and my short orders are never triggered.

Waiting for your word.


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

Eugene

#2
Hi,

Here are some observations re: your code:

1. It's positively not surprising that short trades are never triggered. Likely because you didn't code them. ;) SellAtLimit exits from long positions whereas your intention was to use ShortAt* instead. Strike F11 key to load the QuickRef and see the proper syntax of trading methods.
2. It's not clear to me why your supposed short entries have the "LastPosition" in them. Just in case I provided two versions of code: a) long-only system that uses SellAtLimit as exits and b) trading from the short side as well.
3. The main (trading) loop should start at least from GetTradingLoopStartBar(Per20 * 3), not bar==1. For the whys and whereabouts please refer to the WealthScript Programming Guide > Indicators > Stability of Indicators.
4. To understand the handling of multiple positions, check out the same Guide > Programming Trading Strategies > Multi-Position Strategies.

a)
CODE:
Please log in to see this code.


b)
CODE:
Please log in to see this code.