NexusFi: Find Your Edge


Home Menu

 





First Script Help


Discussion in ThinkOrSwim

Updated
    1. trending_up 1,102 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 0 posts
    2. attach_file 0 attachments




 
Search this Thread

First Script Help

  #1 (permalink)
samvent
Normal Il USA
 
Posts: 1 since Jul 2016
Thanks Given: 0
Thanks Received: 0

I am attempting to write my first script and need some help. A simple indicator to follow trend changes.
I want to adjust the timeframe independent of the chart, but can't seem to figure out how to add the time period to my plot. Any help would be appreciated.

declare lower;
input TimeFrame1 = {default "5 min", "10 min", "15 min", "20 min"};
def Aggregation1;
def range = (hl2[5] + hl2[4] + hl2[3] + hl2[2] + hl2[1] + hl2) / 6;
def uptrend = (if close > range then 1 else 0);
def downtrend = if close <= range then 1 else 0;

switch (TimeFrame1) {
case "5 min":
Aggregation1 = AggregationPeriod.FIVE_MIN;
case "10 min":
Aggregation1 = AggregationPeriod.TEN_MIN;
case "15 min":
Aggregation1 = AggregationPeriod.FIFTEEN_MIN;
case "20 min":
Aggregation1 = AggregationPeriod.TWENTY_MIN;
}

def timeFrame = GetAggregationPeriod();
def testTimeFrames = if timeFrame < Aggregation1 then yes else no;
AddLabel(yes, if testTimeFrames then "Time Frames Are Correct" else "Time Frames Are Wrong", if testTimeFrames then Color.GREEN else Color.RED);

plot Trend1 = if uptrend then 1 else Double.NaN;
plot Trend2 = if downTrend then 1 else Double.NaN;
Trend1.SetDefaultColor(Color.GREEN);
Trend2.SetDefaultColor(Color.RED);

Reply With Quote




Last Updated on July 5, 2016


© 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