Position.Priority to Sort Alerts
Author: CemCalim
Creation Date: 10/14/2014 4:19 PM
profile picture

CemCalim

#1
Hy,

I would like the position priority for my Bollinger Band. I am not sure thats correct. I need it for sort my alerts. What is strange, in my Backtest there is much more Short Trades as Long Trades. Could they please check my code.




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

Eugene

#2
Looks OK on the surface. I haven't found any serious errors, only room for enhancements. Among its minor errors:

1. This parameter has the default value out of range:
CODE:
Please log in to see this code.


2. For short trades, most of your strategy parameter are defined in an incorrect manner:
CODE:
Please log in to see this code.

The minimum value should not be greater than the maximum value.

3. This should better be replaced with...
CODE:
Please log in to see this code.

...because your strategy parameter values for indicator periods can take values exceeding the start bar (#20).
profile picture

LenMoz

#3
Hi CemCalim,

Today is your lucky day. Your strategy caught my eye partly because it seemed promising, but mostly because of having 14 parameters and a very large solution space, impossible for the exhaustive optimizer. This made it a good strategy to test my new WL AddIn Particle Swarm Optimizer. (Advertisement: http://www.wealth-lab.com/Extensions/Details/56)

But your strategy had some logic problems, so I thought I'd try to fix it. Here's what I did...
1. Gave Slider1-14 meaningful tags and reworked Default/Start/Stop/Step values
2. Conditioned Sell vs. Cover by "if( LastPosition.PositionType == PositionType.Long ) {"
3. Restructured a few ifs and elses, especially to fix long/short imbalance
4. Incorporated Eugene's "for(int bar = GetTradingLoopStartBar(20); ..." (TODO "20" should be at least max of indicator periods)
5. Pre-calculated ATR.Series, unstead of using ATR.Value (long and short) for efficiency
6. Ran my new PSO optimizer (optimizing :Net Profit" on 430 S&P 500 non-financial symbols for 10 years)

Best parameters so far (it's still running) {8,0.3,16,26,178.1,24,19,17,19.5,13,16,69.4,12,-54}

Here is the source after my changes:
CODE:
Please log in to see this code.

profile picture

CemCalim

#4
Hy,

LenMoz: I do not know exactly what you did, because my C # is not so good. I look at it more detail at.


thanks for the help Eugen und LenMoz.
profile picture

CemCalim

#5
Hy ,

I would like in my strategy to use the priority. It should prioritize the signals in the alerts." See Image". How can I do that ?

CODE:
Please log in to see this code.




profile picture

CemCalim

#6
Here is the Image.

profile picture

Eugene

#7
QUOTE:
I would like in my strategy to use the priority. It should prioritize the signals in the alerts." See Image". How can I do that ?


For example,
CODE:
Please log in to see this code.


It depends on how exactly you want to get the signals prioritized.
profile picture

CemCalim

#8
Hy Eugene,

i need it for my Bollinger Strategy.

QUOTE:
It depends on how exactly you want to get the signals prioritized.


Here I have an example from my RSI strategy.

CODE:
Please log in to see this code.


I don't know, how i do this in the Bollinger strategy.



profile picture

Eugene

#9
By analogy.
profile picture

CemCalim

#10
Ok, I try it out.

thanks Eugen.