NexusFi: Find Your Edge


Home Menu

 





Thinkscript If Statement


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one newuse with 7 posts (1 thanks)
    2. looks_two growex with 2 posts (3 thanks)
    3. looks_3 mobiusrts with 2 posts (4 thanks)
    4. looks_4 shzhning with 1 posts (1 thanks)
      Best Posters
    1. looks_one mobiusrts with 2 thanks per post
    2. looks_two growex with 1.5 thanks per post
    3. looks_3 shzhning with 1 thanks per post
    4. looks_4 newuse with 0.1 thanks per post
    1. trending_up 16,789 views
    2. thumb_up 9 thanks given
    3. group 4 followers
    1. forum 11 posts
    2. attach_file 0 attachments




 
Search this Thread

Thinkscript If Statement

  #11 (permalink)
newuse
Atlanta
 
Posts: 9 since May 2015
Thanks Given: 4
Thanks Received: 1


mobiusrts View Post
I copied and pasted my original code from this forum and it plots the label fine. You likely missed some of the code in your copy and paste.

I realized I was using plot variables for the conditions instead of a conditional statement. Since plot variables contained conditions, I thought they contained yes, 1, no, or 0.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Exit Strategy
NinjaTrader
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
26 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Tao te Trade: way of the WLD
22 thanks
My NQ Trading Journal
16 thanks
HumbleTraders next chapter
9 thanks
  #12 (permalink)
newuse
Atlanta
 
Posts: 9 since May 2015
Thanks Given: 4
Thanks Received: 1


Following growex's advice I was able to get my code to work. However, it alerts me every 15 minutes and says no changes all the time.

 
Code
input minPips = 10;

input HTF = AggregationPeriod.HOUR;

input withinPips = 50;

input emaPeriod1 = 20;

input emaPeriod2 = 50;

def condLow =  
	close < low[1]
	and
	absvalue(open - close) >= minPips*10*ticksize()
	and
	absvalue(close - expaverage(close(period=HTF),emaPeriod1)) <= withinPips*10*ticksize()
	and
	close < expaverage(close(period=HTF),emaPeriod1)
	and
	expaverage(close(period=HTF),emaPeriod1) < expaverage(close(period=HTF),emaPeriod2);

def condHigh =  
	close > high[1]
	and
	absvalue(open - close) >= minPips*10*ticksize()
	and
	absvalue(close - expaverage(close(period=HTF),emaPeriod1)) <= withinPips*10*ticksize()
	and
	close > expaverage(close(period=HTF),emaPeriod1)
	and
	expaverage(close(period=HTF),emaPeriod1) > expaverage(close(period=HTF),emaPeriod2);

plot EMA20 = expaverage(close(period=HTF),emaPeriod1);

plot EMA50 = expaverage(close(period=HTF),emaPeriod2);

EMA20.hide();

EMA50.hide();

plot Decrease = condLow;
Decrease.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Decrease.SetDefaultColor(Color.RED);
Decrease.SetLineWeight(3);

plot Increase = condHigh;
Increase.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Increase.SetDefaultColor(Color.BLUE);
Increase.SetLineWeight(3);

Alert(condLow, "Decrease", Alert.Bar, Sound.bell);
Alert(condHigh, "Increase", Alert.Bar, Sound.bell);
Alert(!condLow and !condHigh, "No changes", Alert.Bar, Sound.bell);
I am not exactly sure why this is happening. The period is set to hour in the conditions.

**Just curious **
Is there a preset 15 minute period for the sink or swim program to run scripts?

**ALSO**
If this is not clear enough, please let me know. I check the thread everyday.

Sorry for not answering your post properly @mobiusrts.

Reply With Quote




Last Updated on May 18, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts