NexusFi: Find Your Edge


Home Menu

 





TradeStation EL -> thinkScript Conversion


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one StockJock with 5 posts (1 thanks)
    2. looks_two optntdr13 with 4 posts (6 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 cbritton with 1 posts (1 thanks)
    1. trending_up 13,975 views
    2. thumb_up 8 thanks given
    3. group 6 followers
    1. forum 14 posts
    2. attach_file 1 attachments




 
Search this Thread

TradeStation EL -> thinkScript Conversion

  #1 (permalink)
StockJock
Chicago + Illinois/USA
 
Posts: 256 since Aug 2010
Thanks Given: 15
Thanks Received: 154

I'm trying to get a zigzag indicator for TOS and it seems like I'll have to go through a translation from another platform language. I found a simple Easy Language script for TradeStation that possibly someone can help me with.

TradeStation ZigZag

 
Code
Inputs: STR(1);
vars: Switch(0); 
if Switch = 0 then begin
if high[1] > high[2] and high[1] > high then begin
plot1[1](high[1], "ZigUp");
Switch = 1;
end;
end;
if Switch = 1 then begin
if low[1] < low[2] and low[1] < low then begin
plot1[1](low[1], "ZigUp");
Switch = 0;
end;
end;
Here's my first attempt at translation, but how do you draw lines between highs and lows and how can I change the period length between highs and lows?
 
Code
declare upper;
def ConditionUP = high[1] > high[2] and high[1] > high;
def ConditionDown = low[1] < low[2] and low[1] < low;
AddChartBubble(ConditionUP,High[1], "ZZUp", Color.Green,Yes);
AddChartBubble(def ConditionDown,Low[1], "ZZDn", Color.Red,Yes);

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
Cheap historycal L1 data for stocks
Stocks and ETFs
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
 
  #3 (permalink)
 
cbritton's Avatar
 cbritton 
Atlanta, Georgia
 
Experience: Intermediate
Platform: NT
Broker: DDT
Trading: ZN, ZB
Posts: 230 since Mar 2010
Thanks Given: 152
Thanks Received: 256


Try this one:

 
Code
                            
declare upper;
def ConditionUP high[0] > high[1] and high[0] > high[-1];
def ConditionDown low[0] < low[1] and low[0] < low[-1];
AddChartBubble(ConditionUP,High[0], "ZZUp"Color.Green,Yes);
AddChartBubble(ConditionDown,Low[0], "ZZDn"Color.Red,no); 
Regards,
-C

“Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat.” - Sun Tzu
Reply With Quote
Thanked by:
  #4 (permalink)
StockJock
Chicago + Illinois/USA
 
Posts: 256 since Aug 2010
Thanks Given: 15
Thanks Received: 154

Thanks. I'm getting closer to a zigzag.

Reply With Quote
  #5 (permalink)
 optntdr13 
Glyndon, Maryland, USA
 
Experience: Advanced
Platform: TOS
Trading: options
Posts: 24 since Sep 2010
Thanks Given: 6
Thanks Received: 49

declare upper;
input n = 2.0;
input p = open;
input offset = 1;
input average = yes;

plot zig = reference zigZagpercent("reversal amount" = n, "price" = p);
zig.EnableApproximation();
def sign = reference zigZagtrendpercent("reversal amount" = n, "price" = p);
def new = if !IsNaN(zig) then 1 else 0;
rec count = if new then 1 else count[1] + 1;
rec vol = if new then volume else vol[1] + volume;
def avgvol = if average then roundDown(vol[1] / count[1], 0) else vol[1];
def up = if new and sign > 0 then 1 else 0;
def down = if new and sign < 0 then 1 else 0;
AddChartBubble(up, high + offset, concat(avgvol, ""), color.blue, yes);
AddChartBubble(down, low - offset, concat(avgvol, ""), color.black, no);

Reply With Quote
Thanked by:
  #6 (permalink)
StockJock
Chicago + Illinois/USA
 
Posts: 256 since Aug 2010
Thanks Given: 15
Thanks Received: 154

optntdr13,

Thanks for your code. I eventually want to use this to develop two other codes, if I can get TOS to do them. They are to adapt zigzag for Fibonacci levels and adapt zigzag for parallel offset lines to show trend channels with overbought and oversold zones (a little like Andrew's Pitchfork ). I'm thinking of using the standard deviation to plot the offset lines. Could you tell me which part of the code determines the end points of each of the zigzag lines and how I can capture their values for my new codes?

I've tried to make the trend channel code, but its not working. Any ideas?

 
Code
declare upper;
input n = 2.0;
input p = open;
input offset = 1;
input average = yes;
input Deviation1 = 2.0;
input Deviation2 = 1.0;
plot zigzag = reference zigZagpercent("reversal amount" = n, "price" = p);
zigzag.EnableApproximation();
def sign = reference zigZagtrendpercent("reversal amount" = n, "price" = p);
def new = if !IsNaN(zigzag) then 1 else 0;
rec count = if new then 1 else count[1] + 1;
rec vol = if new then volume else vol[1] + volume;
def avgvol = if average then roundDown(vol[1] / count[1], 0) else vol[1];
def up = if new and sign > 0 then 1 else 0;
def down = if new and sign < 0 then 1 else 0;
#  AddChartBubble(up, high + offset, concat(avgvol, ""), color.blue, yes);
#  AddChartBubble(down, low - offset, concat(avgvol, ""), color.black, no);
def sDev = stdev(zigzag);
plot UpperBand1 = zigzag + Deviation1 * sDev;
plot UpperBand2 = zigzag + Deviation2 * sDev;
plot LowerBand2 = zigzag - Deviation2 * sDev;
plot LowerBand1 = zigzag - Deviation1 * sDev;

Reply With Quote
  #7 (permalink)
 optntdr13 
Glyndon, Maryland, USA
 
Experience: Advanced
Platform: TOS
Trading: options
Posts: 24 since Sep 2010
Thanks Given: 6
Thanks Received: 49

At first glance, it looks likme it should work but I will be more than happy to play with it after the trading day to see what I can come up with. I would like to attempt to use it myself for TDDwave...since I am told it can't be done I think I will try.

Reply With Quote
Thanked by:
  #8 (permalink)
 optntdr13 
Glyndon, Maryland, USA
 
Experience: Advanced
Platform: TOS
Trading: options
Posts: 24 since Sep 2010
Thanks Given: 6
Thanks Received: 49

Do me a favor, draw on this image I am posting below what it is you want to do in the above...

2011-03-11_1414 - optntdr13's library

Reply With Quote
Thanked by:
  #9 (permalink)
StockJock
Chicago + Illinois/USA
 
Posts: 256 since Aug 2010
Thanks Given: 15
Thanks Received: 154

Interesting image you posted. What are all those indicators on it?

Reply With Quote
  #10 (permalink)
 optntdr13 
Glyndon, Maryland, USA
 
Experience: Advanced
Platform: TOS
Trading: options
Posts: 24 since Sep 2010
Thanks Given: 6
Thanks Received: 49


2 seperate versions / time-frame implementations of Time-Segmented Volume turned into a copy of the 3C indicator used by trade-guild.net or at least my versions. They encompass the two crazy lines are I use them as leading indicators of institutional money flows. Then, I have TD Propulsion and TD Setup for trend as well as TD Price Flips. Yes, I do use them all and sometimes even more and quite well too

Reply With Quote
Thanked by:




Last Updated on October 27, 2012


© 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