Information

Username: phamvanthanh
Member since: 07 Oct 2012
Last login: 06 Mar 2013
Status: Active

Activity

Where Created Comments
Algorithms 2 2
Forum Topics 15 33
Jobs 0 0

Last Algorithm Comments

PH
phamvanthanh · 11 years ago
Hi kkostaki, I am trying to use zigzag as trend like others but I do not know why it is not working right. Could you please help me? below is my code protected override void OnStart() { // _matype = MovingAverageType.Simple; _zigZag = Indicators.GetIndicator(Source, ZzDepth , ZzDeviation, ZzBackStep); } protected override void OnBar() { if (Trade.IsExecuting) return; int lastindex = _zigZag.Result.Count - 2; int previndex = _zigZag.Result.Count - 3; lastValue = _zigZag.Result[lastindex]; prevValue = _zigZag.Result[previndex]; bool isLongPositionOpen = position != null && position.TradeType == TradeType.Buy; bool isShortPositionOpen = position != null && position.TradeType == TradeType.Sell; if (lastValue > prevValue && !isLongPositionOpen) { ClosePosition(); Buy(); } if (lastValue < prevValue && !isShortPositionOpen) { ClosePosition(); Sell(); } } thanks in advance
PH
phamvanthanh · 11 years ago
Hi, please help me with these codes if (_position == null || _position.TradeType == TradeType.Sell) { Trade.Close(_position) } these codes close short position of any position I intend to close short or long axactly but I am not sure thanks