Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Whats under the hood? #981

Unanswered
MrDenfish asked this question in Q&A
Discussion options

Love this program! I'm very new (as my question will substantiate),please forgive me if the answer is glaringly obvious:

I was writing my own indicators in order to help me understand the program and came across something I perceived to be odd.
When I have a few indicators (self.I) I noticed that the first trade will not happen until the indicator with the largest length as been met, even if that indicator is not used as a condition to open or close a trade. In my case I have the following indicators and their lengths; sma/14, rsi/14,ema/50 and ema/200.
If I run with all indicators active (not commented out) the first trade will not happen until the 200th bar, with ema/200 deactive first trade happens at the 63rd bar, and if the ema 50 and ema200 indicators are both deactivated then the first trade happens correctly at the 29th bar. Why do the ema indicators affect when the first trade happens, even when they are not a condition of the trade?
Clear as mud I'm sure , so I hope some code and output snippets will help.

np_close = np.array(GOOG.Close)
self.sma_pine = self.I(pine_sma,np_close,14,name="Pine-SMA", overlay=True, color='Orange', plot=True)
self.rising = self.I(pine_rising,GOOG.Close,self.sma_pine,self.barsback)
self.pine_rsi = self.I(pine_rsi,GOOG,14,name="Pine-RSI",overlay=False,color="Blue",plot=True)
self.ema50 = self.I(pine_ema,GOOG.Close.to_numpy(),50,name="EMA-50", overlay=True, color='Blue', plot=True)
self.ema200 = self.I(pine_ema,GOOG.Close.to_numpy(),200,name="EMA-200", overlay=True, color='Purple', plot=True)
`
self.overbought = crossover(70,self.pine_rsi)
if self.position and self.overbought:
 self.position.close()
elif not self.position and self.rising:
 self.buy()
`

with ema 200 active this makes sense if the ema 200 is part of the trade condition, but it is not.

 Size EntryBar ExitBar EntryPrice ExitPrice PnL ReturnPct EntryTime ExitTime Duration
0 3.0 200 202 291.696444 279.56 -36.409332 -0.041606 2005年06月06日 2005年06月08日 2 days
1 3.0 203 204 287.054406 282.50 -13.663218 -0.015866 2005年06月09日 2005年06月10日 1 days
2 3.0 205 217 283.485150 292.72 27.704550 0.032576 2005年06月13日 2005年06月29日 16 days
3 3.0 218 233 294.914790 302.40 22.455630 0.025381 2005年06月30日 2005年07月22日 22 days

with ema 50 active and ema 200 inactive

 Size EntryBar ExitBar EntryPrice ExitPrice PnL ReturnPct EntryTime ExitTime Duration
0 5.0 63 93 172.948500 192.79 99.207500 0.114725 2004年11月17日 2004年12月31日 44 days
1 5.0 94 202 203.237046 279.56 381.614770 0.375537 2005年01月03日 2005年06月08日 156 days
2 5.0 203 204 287.054406 282.50 -22.772030 -0.015866 2005年06月09日 2005年06月10日 1 days
3 5.0 205 217 283.485150 292.72 46.174250 0.032576 2005年06月13日 2005年06月29日 16 days

with ema50 and ema 200 inactive and sma/14 and rsi/14 active

 Size EntryBar ExitBar EntryPrice ExitPrice PnL ReturnPct EntryTime ExitTime Duration
0 7.0 29 43 129.936960 140.49 73.871280 0.081217 2004年09月30日 2004年10月20日 20 days
1 7.0 44 54 149.768388 184.70 244.521284 0.233238 2004年10月21日 2004年11月04日 14 days
2 7.0 55 93 169.790310 192.79 160.997830 0.135459 2004年11月05日 2004年12月31日 56 days
3 7.0 165 202 185.481000 279.56 658.553000 0.507216 2005年04月15日 2005年06月08日 54 days
You must be logged in to vote

Replies: 1 comment

Comment options

See #732, d7eaa45 (TBR).

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /