Midcandle colum for watchlist

joker12

New member
Hi guys, started to program from yesterday, just went through basics in learning center and now stucked.
My first goal is create column in watchlist to show "10" for tickers after 2 conditions are met (range of previous candle more then 10% up and current price is just above 50% level of previous day) else show 0..errors which tos highlighted me are in bold: (looks like I wrongly defined open and close of the day, probably DAY parameter I cant use like this?..Also what is the definition of last price? I found it like 'price', but looks like its not..and about error below, I have no idea....Many thanx for any help...
btw. what resources yo use to study?



def opicka= open(DAY)[1];
def zachodik= close(DAY)[1];

#calculate 50% of candle
def midik= (opicka+zachodik)/2;

#measure range of yesterday
def rangik=(close-open)/open*100;

#compare last price with midcandle
def porovnavacka= (price/midik-1)*100;

#3 conditions
def condition1 = porovnavacka > 0;
def condition2 = porovnavacka < 3;
def condition3 = rangik > 10;
def totalik = condition1+condition2+condition3;
def pravda =10;
def loz=0;

#if all 3 conditions are true then show 10 else 0
def vysledok= If (totalik=0,pravda,loz);
plot vysledok;

**************************************

No such parameter: totalik at 23:15
No default value for parameter 'condition' on if at 23:15
Identifier Already Used: vysledok at 24:6
Expected class com.devexperts.tos.thinkscript.data.SymbolType at 2:13
Expected class com.devexperts.tos.thinkscript.data.SymbolType at 3:15
Expected double
No such variable: DAY at 2:18
No such variable: DAY at 3:21
No such variable: price at 12:20
 
Hi guys, started to program from yesterday, just went through basics in learning center and now stucked.
My first goal is create column in watchlist to show "10" for tickers after 2 conditions are met (range of previous candle more then 10% up and current price is just above 50% level of previous day) else show 0..errors which tos highlighted me are in bold: (looks like I wrongly defined open and close of the day, probably DAY parameter I cant use like this?..Also what is the definition of last price? I found it like 'price', but looks like its not..and about error below, I have no idea....Many thanx for any help...
btw. what resources yo use to study?



def opicka= open(DAY)[1];
def zachodik= close(DAY)[1];

#calculate 50% of candle
def midik= (opicka+zachodik)/2;

#measure range of yesterday
def rangik=(close-open)/open*100;

#compare last price with midcandle
def porovnavacka= (price/midik-1)*100;

#3 conditions
def condition1 = porovnavacka > 0;
def condition2 = porovnavacka < 3;
def condition3 = rangik > 10;
def totalik = condition1+condition2+condition3;
def pravda =10;
def loz=0;

#if all 3 conditions are true then show 10 else 0
def vysledok= If (totalik=0,pravda,loz);
plot vysledok;

**************************************

No such parameter: totalik at 23:15
No default value for parameter 'condition' on if at 23:15
Identifier Already Used: vysledok at 24:6
Expected class com.devexperts.tos.thinkscript.data.SymbolType at 2:13
Expected class com.devexperts.tos.thinkscript.data.SymbolType at 3:15
Expected double
No such variable: DAY at 2:18
No such variable: DAY at 3:21
No such variable: price at 12:20

here is an example of setting a 2nd aggregation.
https://tlc.thinkorswim.com/center/...tants/AggregationPeriod/AggregationPeriod-DAY

plot is like def, in that it needs a variable = to something.
try this
plot z = vysledok;
 
here is an example of setting a 2nd aggregation.
https://tlc.thinkorswim.com/center/...tants/AggregationPeriod/AggregationPeriod-DAY

plot is like def, in that it needs a variable = to something.
try this
plot z = vysledok;

Thank you..this plot helped:)..period I set up outside of code- there is some option by column name I noticed (I didnt have it there-not sure why- but then I just took old script and added there my code)-I hope it will work..any idea how the best define current price?.i tried last, price- it doesnt work..looks like "ask" is working...in any case its withoult errors now so I can test it, at least
Ruby:
def opicka= open[1];
def zachodik= close[1];
#calculate 50% of candle
def midik= (opicka+zachodik)/2;
#measure range of yesterday
def rangik=(close-open)/open*100;
#compare last price with midcandle
def c= ask;
def porovnavacka= (ask/midik-1)*100;
#3 conditions
def condition1 = porovnavacka > 0;
def condition2 = porovnavacka < 3;
def condition3 = rangik > 10;
def tot = condition1+condition2+condition3;
def pravda =10;
def loz=0;
#if all 3 conditions are true then show 10 else 0
def vysledok= if tot==0 then pravda else loz;
plot z=vysledok;
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
457 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top