Permalink
Browse files

cosmetics, MACD decision only on 59 minute

  • Loading branch information...
1 parent 5c9ae5d commit 0428813a92430233b9efc59e61699b5a5b172460 Evgeniy Sokolov committed Sep 29, 2011
@@ -62,20 +62,20 @@ public function setSecurity(Security $security)
public function simpleHandle($value)
{
+ if (DateTimeManager::me()->getNow()->format('i') != 59)
+ return $this;
+
$indicatorValue = $this->indicator->getValue();
if (
- $this->prevValue !== null
- && $this->prevValue >= 0
- && $indicatorValue < 0
- )
- $this->openPosition($value, OrderType::sell());
- else if (
- $this->prevValue !== null
- && $this->prevValue <= 0
- && $indicatorValue > 0
- )
- $this->openPosition($value, OrderType::buy());
+ $this->canOpenPosition()
+ && $this->prevValue !== null
+ ) {
+ if ($this->prevValue >= 0 && $indicatorValue < 0)
+ $this->openPosition($value, OrderType::sell());
+ else if ($this->prevValue <= 0 && $indicatorValue > 0)
+ $this->openPosition($value, OrderType::buy());
+ }
$this->prevValue = $indicatorValue;
@@ -107,7 +107,7 @@ private function openPosition($price, OrderType $orderType)
)
);
- if ($count && $this->canOpenPosition()) {
+ if ($count) {
$position =
Position::create()->
setCount($count)->
@@ -39,15 +39,15 @@
addIndicator($MACDSignal)->
addIndicator($MACDHistogramm);
- $seriesCounter = \tradeSystem\SeriesCounter::create();
-
$strategy =
new \tradeSystem\MACDHistogrammReverseStrategy(
new \tradeSystem\EndStrategy()
);
$security = \tradeSystem\Security::create()->setId('SBER3');
+ $seriesCounter = \tradeSystem\SeriesCounter::create();
+
$strategy->
setSeriesCounter($seriesCounter)->
setIndicator($MACDHistogramm)->

0 comments on commit 0428813

Please sign in to comment.