NexusFi: Find Your Edge


Home Menu

 





Convert an OTA indicator from TS to ToS


Discussion in ThinkOrSwim

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




 
Search this Thread

Convert an OTA indicator from TS to ToS

  #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?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Exit Strategy
NinjaTrader
Better Renko Gaps
The Elite Circle
How to apply profiles
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
18 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 Twitter 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


© 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