Suneido

Integrated Application Platform

  • Home
  • Learning
    • Suneido Manual
    • Beginners
      • Inside Suneido
      • The Suneido Programming Language
      • The Suneido Database
      • Installing Suneido
      • Building Suneido
      • IDE Go To Tour
      • Upgrading To A New Release
    • Advanced
      • Canvas Control
      • DrawControl Part 1
      • DrawControl Part 2
      • DrawControl Part 3
      • SAX Like XML Processing
      • A Plug-In Architecture
      • A Simple Wizard Framework
      • An HTML Include Facility
      • An RSS 2 Feed Creator
      • MIME Generation
      • A New Add-on Facility
      • Workspace Improvement Hack
    • Mockito for Suneido
    • The Suneido Task Scheduler
    • Contributing To Suneido
    • Contributor Assignment of Copyright
    • Language Translation
    • Future Directions
    • Interview With Andrew Mckinlay
  • Forum
    • Announcements
    • Internals & Enhancements
    • Cookbook
    • General
  • FAQ
  • Screenshots
  • Downloads
  • Links

Re: Re: Error while updating

Integrated Application Platform › Forums › General › Error while updating › Re: Re: Error while updating

November 30, 2012 at 1:10 pm #949
ajith
Participant

Hello Andrew,

Thanks for the help. I am doing fine. I was doing my postgraduation and then job and family – no time to play around with computer. Hope you, your friends and family are doing good.

As you said, I stopped using Query1 inside the QueryApplyMulti and instead stored the previousEMA in the variable and the problem is corrected. The prevEMA for the first record was to be calculated in a different way and it could be done outside the loop.
Now the code is

	if TableExists?(stockname)
{
firstrec = QueryFirst(stockname $ ' where date >= ' $ Display(from ) $ ' and date <= ' $ Display(till) $ ' sort date ')
prevEMA = QueryMean(stockname $ ' where serialno > '$ Display((firstrec.serialno - period)-1) $ ' and serialno <= ' $ Display(firstrec.serialno-1), price)
QueryApply(stockname $ ' where date >= ' $ Display(from ) $ ' sort date ', update:true)
{|rec|
if (QueryCount(stockname $ ' where serialno <=' $ Display(rec.serialno)) > (period + 1))
{
ema = (((rec[price] - prevEMA) * multiplier) + prevEMA).Round(2)
}
else
ema = ""
Print(ema, rec_date: rec.date,rec_price: rec[price],prev_EMA: prevEMA,difference: (rec[price] - prevEMA))
rec[output] = ema
rec.Update()
prevEMA =ema
}
return QueryLast(stockname $ ' where date >= ' $ Display(from ) $ ' sort date').ema
}

.

Exponential Moving AVerages are calculated by giving different weightage to different member values. In case of the stock prices, that I am dealing with now, the price for the most recent date is given more weightage. The weightage factor calculated from the period that user supplies is multiplied [for a 5 period ema, the weightage would be 5/(1+2+3+4+5)] by the most recent price and 1-weightage is multiplied with the previous EMA. For the first record, there is no previous EMA and hence a simple average is calculated and is used in place of previous EMA. I was not sure how to deal with these calculations and so I had posted another thread on the forum – “Accessing previous record from current record”. Hope you will guide me on that also.

Thanks once again,
ajith

BTW, hello to ferguson and others at Suneido!

Search Forums

Log In
Welcome to the new Suneido Web Site and Forum.
Register
Lost Password
users of the previous PHPBB Forum should be able to log in with their previous username and password.

Recent Topics

  • Alpha copy of gSuneido to play with
  • how to start jsuneido ?
  • Problem Starting Suneido…
  • Dialog not showing buttons
  • New link for Suneidojo

Contact Us | Legal Statement | Privacy Statement | SiteMap

Copyright © 2023 Axon® Development Corporation. All Rights Reserved. - Open Source Integrated Database and Programming Language