NexusFi: Find Your Edge


Home Menu

 





Convert an OTA indicator from TS to ToS


Discussion in ThinkOrSwim

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




 
Search this Thread
  #1 (permalink)
speigo
Huntington Beach, CA, USA
 
Posts: 3 since May 2019
Thanks Given: 1
Thanks Received: 0

Hi,
I have looked at the available ToS downloads and some of the threads regarding converting scripts from one platform to another. I also looked in the Online Trading Academy (OTA) posts but didn't see anything there.

I would like to convert the floating ATR capability that is a download from OTA. If anyone can help that would be great. Here is the code and the picture of what it looks like in TradeStation. Thanks in advance.

****** OTA Floating ATR
****** This tool displays the Daily ATR on the chart as well as 10% and 2% of the Daily ATR.

****** Easy Language Code
inputs: PosX( 40 ), PosY( 97 ), TextColor( Black );

var: tsdata.marketdata.PriceSeriesProvider dPSP( NULL );
method override void InitializeComponent() begin
dPSP = new tsdata.marketdata.PriceSeriesProvider;
dPSP.Symbol = GetSymbolName;
dPSP.Interval.ChartType = tsdata.marketdata.DataChartType.Bars;
dPSP.Interval.IntervalType = tsdata.marketdata.DataIntervalType.Daily;
dPSP.Interval.IntervalSpan = 1;
dPSP.Interval.Name = "(Unknown name)";
dPSP.Range.Type = tsdata.marketdata.DataRangeType.Months;
dPSP.Range.Months = 2;
dPSP.Range.Name = "(Unknown name)";
dPSP.IncludeVolumeInfo = false;
dPSP.IncludeTicksInfo = false;
//dPSP.UseNaturalHours = false;
dPSP.Realtime = true;
//dPSP.TimeZone = tsdata.common.TimeZone.exchange;
dPSP.Load = true;
dPSP.Name = "dPSP";
end;

vars: IntrabarPersist FirstTickOfBar( False ),
x( 0 ), ATR( 0 ), HalfATR( 0 ), QuarterATR( 0 ), TenthATR( 0 ), TwoPctATR( 0 ), ATRText( 0 ), Dec( 0 ), Add( 0 );


ATR = 0;
for x = 0 to 13 begin
if dPSP.Count > 14 then
ATR = ATR + ( iff(dPSP.Close[x+1] astype double > dPSP.High[x] astype double, dPSP.Close[x+1] astype double, dPSP.High[x] astype double)
- iff(dPSP.Close[x+1] astype double < dPSP.Low[x] astype double, dPSP.Close[x+1] astype double, dPSP.Low[x] astype double) );
end;
ATR = ATR / 14;

if Category = 2 then Dec = 2
else if Category = 12 then begin if MidStr(Symbol, 4, 3) = "JPY" then ATR = ATR * 100 else ATR = ATR * 10000; Dec = 0; end
else if Category = 0 then
if SymbolRoot="EC" OR SymbolRoot="JY" OR SymbolRoot="BP" OR SymbolRoot="AD" OR SymbolRoot="CD" OR SymbolRoot="SF" then begin ATR = ATR * 10000; Dec = 0; end
else Dec = 3;
if Dec = 0 then Add = 1 else Add = MinMove * 0.01;
HalfATR = (Round((ATR*0.5/Add),0)+1) * Add; QuarterATR = (Round((ATR*0.25/Add),0)+1) * Add; TenthATR = (Round((ATR*0.1/Add),0)+1) * Add; TwoPctATR = (Round((ATR*0.02/Add),0)+1) * Add;

if ATRText <> 0 AND FirstTickOfBar then Value1 = Text_Delete( ATRText );
ATRText = Text_New( Date, Time, Close, "[dATR]:"+NumToStr(ATR,Dec)+" [10%]:"+NumToStr(TenthATR,Dec)+" [2%]:"+NumToStr(TwoPctATR,Dec) );
Value1 = Text_SetColor( ATRText, TextColor ); Value1 = Text_Float( ATRText, PosX, PosY );

FirstTickOfBar = BarStatus(1) = 2;


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Hormuz Completely Closed: US Strikes Day 2, Iran Shoots …
Traders Hideout
Iran Update May 8: Still Reviewing MOU, Demands Reparati …
Traders Hideout
Irans Answer Due Today: Peace Surges to 33.5%, Invasion …
Prediction Markets & Event Contracts
April FOMC Minutes: Most Divided Fed Since 1992 -- Many …
Traders Hideout
White House Drops First Alien Files Today -- Market Says …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
10 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
 kjhosken 
Seattle, WA/USA
 
Experience: Intermediate
Platform: TOS, TS
Trading: Forex, crude
Posts: 96 since Sep 2016
Thanks Given: 7
Thanks Received: 35

There are some ATR labels available for free on the interwebs that might do the trick. No screenshot, so not sure if this will work for ya, but try this one:

 
Code
input ATRLength = 14;
def ATR = Round(AvgTrueRange(high, close, low, ATRLength), 2);
def ATR10 = ATR * .1;
def ATR02 = ATR * .02;
addLabel(yes,concat(“ATR=”, ATR), color.Yellow);
addLabel(yes,concat(” ATR10=”, ATR10), color.White);
addLabel(yes,concat(” ATR02=”, ATR02), color.Green);


Follow me on X Reply With Quote
Thanked by:
  #3 (permalink)
speigo
Huntington Beach, CA, USA
 
Posts: 3 since May 2019
Thanks Given: 1
Thanks Received: 0


Thank you for the response. I will give this code a try.


Reply With Quote




Last Updated on June 14, 2019


© 2026 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 - Downloads - Top
no new posts