Skip to content

Commit

Permalink
fixed no trade bug in bubble algorithm(C#)
Browse files Browse the repository at this point in the history
  • Loading branch information
jingwu74 committed Sep 26, 2017
1 parent 5ecc182 commit 9a6a224
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Algorithm.CSharp/BubbleAlgorithm.cs
Expand Up @@ -131,13 +131,13 @@ public void OnData(TradeBars data)
//During market hours, stock is trading, and sufficient cash
if (Securities[stock].Holdings.Quantity == 0 && _rsiDic[stock] < 70
&& Securities[stock].Price != 0 && Portfolio.Cash > Securities[stock].Price * 100
&& Time.Hour == 9 && Time.Minute == 30)
&& Time.Hour == 9 && Time.Minute == 31)
{
Buy(stock);
}
//Utilize RSI for overbought territories and liquidate that stock
if (_rsiDic[stock] > 70 && Securities[stock].Holdings.Quantity > 0
&& Time.Hour == 9 && Time.Minute == 30)
&& Time.Hour == 9 && Time.Minute == 31)
{
Sell(stock);
}
Expand All @@ -152,14 +152,14 @@ public void OnData(TradeBars data)

//Sell stock based on MACD
if (Securities[stock].Holdings.Quantity > 0 && _rsiDic[stock] > 30
&& Time.Hour == 9 && Time.Minute == 30)
&& Time.Hour == 9 && Time.Minute == 31)
{
Sell(stock);
}
//Utilize RSI and MACD to understand oversold territories
else if (Securities[stock].Holdings.Quantity == 0 && _rsiDic[stock] < 30
&& Securities[stock].Price != 0 && Portfolio.Cash > Securities[stock].Price * 100
&& Time.Hour == 9 && Time.Minute == 30)
&& Time.Hour == 9 && Time.Minute == 31)
{
Buy(stock);
}
Expand Down

0 comments on commit 9a6a224

Please sign in to comment.