Exemplo n.º 1
0
def timeUpdate(timeFrame):
    global macd
    global macdPrev
    global signalPrev
    if Factory.Debug:
        print "Update from Python"
        if Base.InPosition:
            Factory.Display.appendLine("Update for {0}, in position", Pair)

    lMacd = Base.getMACDasList(TimeFrame.m5, PriceComponent.BidClose, 12, 26, 9)
    print lMacd
    macd = lMacd[0]
    signal = lMacd[1]
    history = lMacd[2]
    Base.Log.debug(
        String.format(
            "timeUpdate({0}):{1}, macd={2}, signal={3}", Base.Factory.TimeFrameMap[timeFrame], Pair, macd, signal
        )
    )

    if macd < signal and macdPrev > signalPrev:
        Factory.Display.appendLine("SELL " + Pair)
        Base.Log.debug("SELL " + Pair)
    elif macd > signal and macdPrev < signalPrev:
        Factory.Display.appendLine("BUY " + Pair)
        Base.Log.debug("BUY " + Pair)

    macdPrev = macd
    signalPrev = signal
Exemplo n.º 2
0
def timeUpdate(timeFrame):
	global macdShort
	global macdPrev
	global signalPrev
	global macdLong
	global macdSignal
	global emaPeriods
	global amount
	global stopPips
	global limitPips
			
	lMacd = Base.getMACDasList(timeFrame, PriceComponent.BidClose, macdShort, macdLong, macdSignal)
	macd = lMacd[0]
	signal = lMacd[1]
	history = lMacd[2]
	Base.Log.debug(String.format("timeUpdate({0}):{1}, macd={2}, signal={3}",Base.Factory.TimeFrameMap[timeFrame], Pair,macd,signal))
	
	lastBid = Base.getLast(timeFrame, PriceComponent.BidClose)
	lastAsk = Base.getLast(timeFrame, PriceComponent.AskClose)
	ema = Base.getEMA(timeFrame, PriceComponent.BidClose, emaPeriods)


	if (not Base.InPosition
	and  ema > 0):

		if (macd < signal 
		and macdPrev > signalPrev
		and  macd > 0
		and signal > 0
		and lastBid < ema):
			entry = "SELL";
			Factory.Display.appendLine(String.Format("Open, {0}, {1}, price={2}", entry, Pair, lastBid))
			Base.enterPosition(entry, amount, lastBid, stopPips, limitPips)

		elif (macd > signal
		and macdPrev < signalPrev
		and  macd > 0
		and signal > 0
		and lastAsk > ema):
			entry = "BUY";
			Factory.Display.appendLine(String.Format("Open, {0}, {1}, price={2}", entry, Pair, lastAsk))
			Base.enterPosition(entry, amount, lastAsk, stopPips, limitPips)
		
	macdPrev = macd
	signalPrev = signal