Indicator Indicator::operator()(const Indicator& ind) { if (!m_imp) return Indicator(); if (!ind.getImp()) return Indicator(m_imp); IndicatorImpPtr p = m_imp->clone(); p->add(IndicatorImp::OP, IndicatorImpPtr(), ind.getImp()); return p->calculate(); }
Indicator HKU_API MACD(int n1, int n2, int n3) { IndicatorImpPtr p = make_shared<Macd>(); p->setParam<int>("n1", n1); p->setParam<int>("n2", n2); p->setParam<int>("n3", n3); return Indicator(p); }
Indicator HKU_API SAFTYLOSS(int n1, int n2, double p) { IndicatorImpPtr result = make_shared<SaftyLoss>(); result->setParam<int>("n1", n1); result->setParam<int>("n2", n2); result->setParam<double>("p", p); return Indicator(result); }
Indicator Indicator::getResult(size_t num) const { if (!m_imp) { HKU_WARN("indicator imptr is null! [Indicator::getResult]"); return Indicator(); } return m_imp->getResult(num); }
HKU_API Indicator operator+(const Indicator& ind1, const Indicator& ind2) { if (!ind1.getImp() || !ind2.getImp()) { return Indicator(); } IndicatorImpPtr p = make_shared<IndicatorImp>(); p->add(IndicatorImp::ADD, ind1.getImp(), ind2.getImp()); return p->calculate(); }
Indicator HKU_API WEAVE(const Indicator& ind1, const Indicator& ind2) { if (!ind1.getImp() || !ind2.getImp()) { HKU_ERROR("ind1 or ind2 is Null Indicator! [WEAVE]"); return Indicator(); } IndicatorImpPtr p = make_shared<IndicatorImp>(); p->add(IndicatorImp::WEAVE, ind1.getImp(), ind2.getImp()); return p->calculate(); }
Indicator HKU_API IF(const Indicator& ind1, const Indicator& ind2, const Indicator& ind3) { if (!ind1.getImp() || !ind2.getImp() || !ind3.getImp()) { HKU_ERROR("Exists null indicator! [IF]"); return Indicator(); } IndicatorImpPtr p = make_shared<IndicatorImp>(); p->add_if(ind1.getImp(), ind2.getImp(), ind3.getImp()); return p->calculate(); }
Indicator HKU_API WEAVE(const Indicator& ind) { IndicatorImpPtr p = make_shared<Weave>(); p->calculate(ind); return Indicator(p); }
Indicator HKU_API WEAVE() { IndicatorImpPtr p = make_shared<Weave>(); return Indicator(p); }
Indicator HKU_API LLV(const Indicator& ind, int n =20) { IndicatorImpPtr p = make_shared<LowLine>(); p->setParam<int>("n", n); p->calculate(ind); return Indicator(p); }
Indicator HKU_API DIFF(const Indicator& data) { IndicatorImpPtr p = make_shared<Diff>(); p->calculate(data); return Indicator(p); }
Indicator HKU_API REF(int n) { IndicatorImpPtr p = make_shared<RightShift>(); p->setParam<int>("n", n); return Indicator(p); }
Indicator HKU_API PRICELIST(int result_index) { IndicatorImpPtr p = make_shared<IPriceList>(); p->setParam<int>("result_index", result_index); return Indicator(p); }
Indicator HKU_API LLVBARS(int n) { IndicatorImpPtr p = make_shared<ILowLineBars>(); p->setParam<int>("n", n); return Indicator(p); }
Indicator HKU_API FLOOR() { return Indicator(make_shared<IFloor>()); }
int main(void) { DDRA=0; PORTA=0; DDRB=0xb2; PORTB |= 0xf3;// Control UAB DDRC=0x2a; PORTC |=0x2a; DDRD=0xc7; PORTD=0xff;/*Reset=on*/ // INIT SPI SPSR=0;//f/64 SPCR=0x72; SPCR |=0x80;//enable Int SPI InitAd(); TCCR1A=0;//0x82; TCCR1B=0x2;//0.5mks // TIMSK=TIMSK | 0x20;//enable Int capture1 TIMSK=TIMSK | 0x4;//enable Int overlowT1 /*Interrupt1*/ // MCUCR=0x8;// Log1>0 Int1 // GICR |=(1<<INT1);/*Enable INT1*/ /*Timer0*/ TCCR0=0x61;//0x61;//1;//1; OCR0=0xe0; // TIMSK |=1;/*Enable Int Overlow Timer0*/ /*Timer2*/ TCCR2=0x4; TIMSK |=(1<<TOIE2);/*Enable Int Overlow Timer2*/ CtSetka=0; _SEI(); RegimWork=0; ResetError(); CtStart=50; RevunOff=0; // ClearRomReceive(); /*Work program*/ while(1) { _WDR(); if(!CtIndAd) { // IndicatorAd(2); CtIndAd=30; } ReadKn(); if(RegS & 0x10) ResetError(); ChangeRegim(); ControlRevun(); ControlMPP(); ControlPogar(); ControlNorma(); Indicator(); IndicatorAll(); SetRegimError(); SetError(); // DecSegm(RegS); // IndicatorSegment(); if(Error) PORTD |=0x40;//Error else PORTD &=0xbf;//Norma } }
Indicator HKU_API REVERSE() { return Indicator(make_shared<IReverse>()); }
Indicator HKU_API REF(const Indicator& ind, int n) { IndicatorImpPtr p = make_shared<RightShift>(); p->setParam<int>("n", n); p->calculate(ind); return Indicator(p); }
Indicator HKU_API PRICELIST(price_t *data, size_t total) { return data ? PRICELIST(PriceList(data, data+total), 0) : Indicator(make_shared<IPriceList>()); }
Indicator HKU_API CVAL(double value, size_t len, size_t discard) { IndicatorImpPtr p = make_shared<ConstantValue>(value, len, discard); return Indicator(p); }
Indicator HKU_API NOT() { return Indicator(make_shared<INot>()); }
Indicator HKU_API SIN() { return Indicator(make_shared<ISin>()); }
Indicator HKU_API SQRT() { return Indicator(make_shared<ISqrt>()); }
Indicator HKU_API VARP(int n) { IndicatorImpPtr p = make_shared<IVarp>(); p->setParam<int>("n", n); return Indicator(p); }
Indicator HKU_API CVAL(const Indicator& ind, double value) { IndicatorImpPtr p = make_shared<ConstantValue>(); p->setParam<double>("value", value); p->calculate(ind); return Indicator(p); }
Indicator HKU_API ROUND(int ndigits) { IndicatorImpPtr p = make_shared<IRound>(); p->setParam<int>("ndigits", ndigits); return Indicator(p); }
Indicator HKU_API DIFF() { return Indicator(IndicatorImpPtr(new Diff())); }
Indicator HKU_API ABS() { return Indicator(make_shared<IAbs>()); }
Indicator HKU_API CVAL(const Indicator& ind, double value, int discard) { IndicatorImpPtr p = make_shared<ConstantValue>(); p->setParam<double>("value", value); p->setParam<int>("discard", discard); return Indicator(p)(ind); }
Indicator HKU_API LLV(int n =20) { IndicatorImpPtr p = make_shared<LowLine>(); p->setParam<int>("n", n); return Indicator(p); }