Coding volume with regression data

jrowe

New member
Very new to this coding thing :). I have the start of a code I'm writing and for the life of me cant get this to work. Been running some correlations and linear regression test on all the data I've tracked and am trying to test some theories.

Any help would be greatly appreciated. I'm trying to code in where I could multiply the volume I'm getting for a time period by different numbers I'm getting from my regression data.

Code:
def startCounter = SecondsFromTime(startTime);
def endCounter = SecondsTillTime(endTime);
plot targetPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;
rec volumeTotal = if targetPeriod and !targetPeriod[1] then volume else if targetPeriod then volumeTotal[1] + volume else volumeTotal[1];

AddLabel(yes, Concat("Target Period Volume: ", volumeTotal), Color.GRAY);
 
Last edited by a moderator:

rad14733

Well-known member
VIP
Is that the extent of your code...??? You haven't defined startTime or endTime, for starters...

Edited to add: The use of Concat() in Thinkscript is somewhat superfluous in my experience... Concat("Target Period Volume: ", volumeTotal) can be replaced with "Target Period Volume: " + volumeTotal and the result will be the same... Compared to other languages I haven't found the benefit...
 
Last edited:

jrowe

New member
Is that the extent of your code...??? You haven't defined startTime or endTime, for starters...

Edited to add: The use of Concat() in Thinkscript is somewhat superfluous in my experience... Concat("Target Period Volume: ", volumeTotal) can be replaced with "Target Period Volume: " + volumeTotal and the result will be the same... Compared to other languages I haven't found the benefit...
Good to know! It is for now, I change the time periods. Ive just been trying to figure out how to get it to where i can multiply the volumetotal for whatever timeframe by whatever numbers i come up with from tracking data. I just cant seem to get it, and figured i'd ask.
 

rad14733

Well-known member
VIP
Working with periods of time is one of the trickiest concepts to nail down in TOS, along with a few complex and seldom used functions... Refer to a few other Studies for examples of how others have done things... I also use the Thinkscript Collection by Jim Shingler, based off work started by StanL... A resource well worth bookmarking...
 

Similar threads

Top