Trying to Make My User Defined Studies Compatible with the Conditional Wizard TS Editor


0
0

Can you put in def statements in it, Conditional Wizard TS Editor? If you can , how do you pose the condition? variable >0 does not do it. But the Main Question is what do you need to do to make your own home-made user defined scripts compatible with Conditional Wizard TS Editor? I did it with SimpleMovingAvg by just directly copying and creating another Study called ASimpleMvgAvg. This user-defined study works great, but my VWAP study. I call it AVWAP. It is exactly the same as the TOS proprietary VWAP but I just cut out about half the lines. It works fine in the Regular TOS Editor.  Of course, doing what I did for SimpleMvgAvg by copying it outright did not work, so perhaps a function that  Condition Wizard TS Editor does not like.  It goes like this

def isPeriodRolled = compoundValue(1, getyyyYMMDD() != GetYYYYMMDD()[1], yes);

def volumeSum;

def volumeVwapSum;

if (isPeriodRolled) {

volumeSum = volume;

volumeVwapSum = volume * vwap;

} else {

volumeSum = compoundValue(1, volumeSum[1] + volume, volume);

volumeVwapSum = compoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);

}

plot VVWAP= volumeVwapSum / volumeSum;

VVWAP.setDefaultColor(getColor(4));

VVWAP.setLineWeight(2);

RESOLVED
Marked as spam
Posted by (Questions: 13, Answers: 18)
Asked on December 29, 2017 1:44 pm
447 views
0

Ok so right there in your first line if code you run into the first problem. CompoundValue() is not supported in condition wizard. You can use the Study Alert to test things without creating conditional orders. Have you watched my video titled: Thinkorswim AutoTrading Almost? https://www.hahn-tech.com/thinkorswim-autotrade-almost/

( at December 29, 2017 8:14 pm)
0

I have tested and found no way to use VWAP indicator in the Study Alerts or the Conditional Order. So if you want to learn how to write thinkscript code that works in these tools I suggest you do so without the VWAP indicator.

( at December 29, 2017 8:22 pm)
0
Private answer

Just found that out on my own.  CompoundValue() is the culprit. Looking the definition up of CompoundValue(), I can see why.    I am going use the slope of  VWAP though someway.   Maybe as a  Long  Open secondary condition.

&& IsAscending(vwap(period=AggregationPeriod.Day),5)

( I checked it works, not as good but helpful).

Gee , I wished I read your response before trying it all.  But now I understand & believe  that there is very little difference between  Conditonal Wizard ThinkScript Editor and ThinkScript Editor, just  TOS Studies that have  Compound Value  or are Proprietary like Carter Studies and Piersen Studies.  Who knows there might be another function too that  the CW TS Editor can not take too.  Thanks again.

 

 

 

Marked as spam
Posted by (Questions: 13, Answers: 18)
Answered on January 1, 2018 2:18 pm
0

Replying in the comment section of your answer. A word of caution about that piece of code you posted. This does not match the output of the VWAP indicator that you would add to a chart.

( at January 1, 2018 2:39 pm)
0
Private answer

Yes, I have watched the Video. Really did not hear that CompoundValue() was a no-no.   I am so use to actual language manual, as in MTL4 or NinjaTrader.  Therefore, it is a step by step experimental process to learn ThinkScript and the in’s and out’s of the  TOS Platform.

I will will watch the “Almost Autotrading ” Video again.

Marked as spam
Posted by (Questions: 13, Answers: 18)
Answered on January 1, 2018 2:25 pm
0

Best to reply using the comment section instead of adding a new answer. So I take it you have not worked through the Thinkscript tutorial published by TD Ameritrade? You mention the lack of a language manual…. yet one does indeed exist.
Link to part one of the tutorial: http://toslc.thinkorswim.com/center/howToTos/tutorials/Basic.html
Link to part two: http://toslc.thinkorswim.com/center/howToTos/tutorials/Advanced.html

( at January 1, 2018 2:36 pm)