Question about if statement/expressions - futures io
futures io



Question about if statement/expressions


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one bb117 with 3 posts (0 thanks)
    2. looks_two Daytrader999 with 1 posts (1 thanks)
    3. looks_3 kevinkdog with 1 posts (0 thanks)
    4. looks_4 Mich62 with 1 posts (1 thanks)
    1. trending_up 273 views
    2. thumb_up 2 thanks given
    3. group 4 followers
    1. forum 6 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Question about if statement/expressions

(login for full post details)
  #1 (permalink)
bb117
Miami, Florida
 
 
Posts: 3 since Nov 2021
Thanks: 1 given, 0 received

I'm thinking of creating several conditions and if they are all true, have an arrow painted on the screen. But there's a problem.
What I'm using is Thinkscript from Thinkorswim and it's saying that it expected an 'else block' where it says 'if', and I just don't get it, nor understand why that if statement is wrong.

def con1 = (MovAvgExponential("length" = 9)."AvgExp" crosses above
MovAvgExponential("length" = 20)."AvgExp" within 2 bars);

plot signal = if con1 is true
then SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

Reply With Quote

Can you help answer these questions
from other members on futures io?
pay for programmer coding a custom indicator
Traders Hideout
Google Keyword Search Alerts
Traders Hideout
how to avoid these type of trades in algo
NinjaTrader
NT 8 Strateg Builder issue I am baffled! Anyone?
NinjaTrader
Does anyone have the code for Anchored Vwap to use in Qu …
Traders Hideout
 
 
(login for full post details)
  #2 (permalink)
 kevinkdog   is a Vendor
 
 
Posts: 3,132 since Jul 2012
Thanks: 1,666 given, 6,207 received


bb117 View Post
I'm thinking of creating several conditions and if they are all true, have an arrow painted on the screen. But there's a problem.
What I'm using is Thinkscript from Thinkorswim and it's saying that it expected an 'else block' where it says 'if', and I just don't get it, nor understand why that if statement is wrong.

def con1 = (MovAvgExponential("length" = 9)."AvgExp" crosses above
MovAvgExponential("length" = 20)."AvgExp" within 2 bars);

plot signal = if con1 is true
then SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

You are posting in the Tradestation EasyLanguage forum. Maybe a mod will move this to the TOS section.

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #3 (permalink)
 Daytrader999 
Site Moderator
Ilsede, Germany
 
Experience: Advanced
Platform: NinjaTrader 8
Broker: Rithmic / CQG / Ninja Trader Brokerage
Trading: NQ
 
Daytrader999's Avatar
 
Posts: 1,429 since Sep 2011
Thanks: 1,817 given, 2,146 received



kevinkdog View Post
You are posting in the Tradestation EasyLanguage forum. Maybe a mod will move this to the TOS section.


Done....

"If you don't design your own life plan, chances are you'll fall into someone else's plan. And guess what they have planned for you? Not much." - Jim Rohn
Reply With Quote
The following user says Thank You to Daytrader999 for this post:
 
(login for full post details)
  #4 (permalink)
bb117
Miami, Florida
 
 
Posts: 3 since Nov 2021
Thanks: 1 given, 0 received

Yeah sorry about that, first time here and didn't even realize the ThinkOrSwim sub-forum, I created the account and this thread all while I was in a different page that had another coding question I had, answered, and it was under the EasyLanguage sub-forum and forgot to check/change the forum I was in.

Reply With Quote
 
(login for full post details)
  #5 (permalink)
 Mich62 
Netherlands
 
Experience: Advanced
Platform: NinjaTrader 8
Broker: NinjaTrader Brokerage
Trading: Commodities, (crypto)currencies & equities
 
Mich62's Avatar
 
Posts: 347 since May 2012
Thanks: 410 given, 601 received

Note that in thinkScript®, the "else" block is mandatory.

Try to add "ELSE" with no expression like:

plot signal = if con1 is true then SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP) ELSE ;

or use a dummy statement like:

plot signal = if con1 is true then SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP) ELSE dummy=0;

It wants to know what to do in case con1 is false.

Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to Mich62 for this post:
 
(login for full post details)
  #6 (permalink)
bb117
Miami, Florida
 
 
Posts: 3 since Nov 2021
Thanks: 1 given, 0 received

thank you for your reply in the end I tried something different, just gotta tweak the parameters and conditions until I get the result I want.

Reply With Quote
 
(login for full post details)
  #7 (permalink)
Jern
Eastern NC
 
 
Posts: 4 since Oct 2021
Thanks: 12 given, 4 received

It's probably looking for Double.NaN, which means Not a Number. It doesn't plot anything when the condition is false.

Here is some code I've used before.

plot arrowAddUp = if con1 then low else Double.NaN;
plot arrowAddDn = if con2 then high else Double.NaN;


And then this defines the plot.

arrowAddUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
arrowAddUp.SetDefaultColor(CreateColor(143, 239, 191));
arrowAddUp.SetLineWeight(1);

arrowAddDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
arrowAddDn.SetDefaultColor(CreateColor(255, 126, 156));
arrowAddDn.SetLineWeight(1);

Reply With Quote


futures io Trading Community Platforms and Indicators ThinkOrSwim > Question about if statement/expressions


Last Updated on November 24, 2021


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts