Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Updated September 28, 2020
Top Posters
looks_one
StockT8er
with 10 posts (1 thanks)
looks_two
vmodus
with 6 posts (2 thanks)
looks_3
kinkeadfx
with 3 posts (0 thanks)
looks_4
ABCTG
with 2 posts (0 thanks)
trending_up
4,969 views
thumb_up
5 thanks given
group
5 followers
forum
21 posts
attach_file
4 attachments
July 20th, 2020, 07:22 PM
ROY, Utah
Experience: Intermediate
Platform: TradeStation
Posts: 81 since Apr 2020
Thanks Given: 11
Thanks Received: 6
ThinkorSwim coding Thinkscript
It's one chart, to be in one strategy
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
July 20th, 2020, 08:39 PM
Somewhere, Delaware, USA
Experience: Intermediate
Platform: MultiCharts
Broker: Barchart.com
Trading: Everything, it all tastes like chicken
Posts: 1,271 since Feb 2017
Thanks Given: 2,958
Thanks Received: 2,853
StockT8er
ThinkorSwim coding Thinkscript
It's one chart, to be in one strategy
Just use the code from the DEMA indicator. Here is what I would do for a very simple crossover entry:
Code
inputs:
Price(Close),
DEMASlowLength(9),
DEMAFastLength(12)
;
vars:
DEMA_Fast(0),
DEMA_Slow(0)
;
DEMA_Slow = DEMA(Price, DEMASlowLength) ;
DEMA_Fast = DEMA(Price, DEMAFastLength) ;
if DEMA_Fast crosses over DEMA_Slow
and MarketPosition <> 1
then buy this bar at close ;
If DEMA_Slow crosses over DEMA_Fast
and MarketPosition <> -1
then sellshort this bar at close ;
~vmodus
~vmodus
Enjoy everything!
July 20th, 2020, 09:38 PM
ROY, Utah
Experience: Intermediate
Platform: TradeStation
Posts: 81 since Apr 2020
Thanks Given: 11
Thanks Received: 6
it's always the case, something very simple and Easy
July 27th, 2020, 09:02 PM
ROY, Utah
Experience: Intermediate
Platform: TradeStation
Posts: 81 since Apr 2020
Thanks Given: 11
Thanks Received: 6
How would I translate these to EasyLanguage
This is ThinkScript terminology
def price = close;
def length = 6;
def Displace = -1;
#above provided as inputs
#1
def isNaNPrice = IsNaN(price);
def varLength = Sum(!isNaNPrice, DMA_length);
def varSum = Sum(if isNaNPrice then 0 else price, DMA_length);
plot DMA = if IsNaN(price) or varLength == 0 then Double.NaN else varSum / varLength;
DMA.DefineColor("Displaced", CreateColor(0, 30, 30)); #Lt.Gray
DMA.DefineColor("Effective", CreateColor(0, 30, 30));
DMA.AssignValueColor(if isNaNdPrice then DMAH.Color("Effective") else DMA.Color("Displaced"));
DMA.SetStyle(Curve.SHORT_DASH);
#2
plot EMA = ExpAverage(price, EMA_lenght);
EMA.SetDefaultColor( CreateColor(0, 30, 30)); #Lt.Gray
EMA.SetStyle(Curve.SHORT_DASH);
#3
plot Displacer = price[Displace];
Displacer.SetDefaultColor( CreateColor(0, 30, 30)); #Lt.Gray
Displacer.SetStyle(Curve.SHORT_DASH);
July 27th, 2020, 11:56 PM
Somewhere, Delaware, USA
Experience: Intermediate
Platform: MultiCharts
Broker: Barchart.com
Trading: Everything, it all tastes like chicken
Posts: 1,271 since Feb 2017
Thanks Given: 2,958
Thanks Received: 2,853
StockT8er
How would I translate these to
EasyLanguage
This is ThinkScript terminology
def price = close;
def length = 6;
def Displace = -1;
#above provided as inputs
#1
def isNaNPrice = IsNaN(price);
def varLength = Sum(!isNaNPrice, DMA_length);
def varSum = Sum(if isNaNPrice then 0 else price, DMA_length);
plot DMA = if IsNaN(price) or varLength == 0 then Double.NaN else varSum / varLength;
DMA.DefineColor("Displaced", CreateColor(0, 30, 30)); #Lt.Gray
DMA.DefineColor("Effective", CreateColor(0, 30, 30));
DMA.AssignValueColor(if isNaNdPrice then DMAH.Color("Effective") else DMA.Color("Displaced"));
DMA.SetStyle(Curve.SHORT_DASH);
#2
plot EMA = ExpAverage(price, EMA_lenght);
EMA.SetDefaultColor( CreateColor(0, 30, 30)); #Lt.Gray
EMA.SetStyle(Curve.SHORT_DASH);
#3
plot Displacer = price[Displace];
Displacer.SetDefaultColor( CreateColor(0, 30, 30)); #Lt.Gray
Displacer.SetStyle(Curve.SHORT_DASH);
I don't think you need to code this. I don't know Thinkscript, but I am guessing what you want is this indicator: Mov Avg DEMA
It looks like it has the displacement you need, too.
~vmodus
Enjoy everything!
July 28th, 2020, 09:01 AM
ROY, Utah
Experience: Intermediate
Platform: TradeStation
Posts: 81 since Apr 2020
Thanks Given: 11
Thanks Received: 6
I tried DEMA it did not plot the same as Thinkorswim plots with the same numbers I used in TOS
and when I enter a negative number on EasyLaungage it errors
July 28th, 2020, 09:49 AM
Somewhere, Delaware, USA
Experience: Intermediate
Platform: MultiCharts
Broker: Barchart.com
Trading: Everything, it all tastes like chicken
Posts: 1,271 since Feb 2017
Thanks Given: 2,958
Thanks Received: 2,853
Negative displaces should not be a problem. I use them with the Alligator indicator (and variants). I was able to plot with a negative displace (TS 10):
Here is the DEMA code:
Code
inputs:
Price( Close ) [
DisplayName = "Price",
ToolTip = "Enter an EasyLanguage expression to use in the exponential moving average calculation."],
Length( 9 ) [
DisplayName = "Length",
ToolTip = "Enter the number of bars used in the calculation of the smoothing factor used in the calculation of the moving average."],
Displace( 0 ) [
DisplayName = "Displace",
ToolTip = "Displacement. Enter the number of bars by which plots will be displaced. Displacement may be positive (left) or negative (right)."];
variables:
AvgDEMA( 0 );
AvgDEMA = DEMA( Price, Length );
if Displace >= 0 or CurrentBar > AbsValue( Displace ) then
begin
Plot1[Displace]( AvgDEMA, !( "DEMA" ) );
{ alert criteria }
if AlertEnabled and Displace <= 0 then
begin
if Price > AvgDEMA and AvgDEMA > AvgDEMA[1] and AvgDEMA[1] <= AvgDEMA[2] then
Alert( !( "Indicator turning up" ) )
else if Price < AvgDEMA and AvgDEMA < AvgDEMA[1] and AvgDEMA[1] >= AvgDEMA[2] then
Alert( !( "Indicator turning down" ) );
end;
end;
~vmodus
Enjoy everything!
August 1st, 2020, 11:47 AM
ROY, Utah
Experience: Intermediate
Platform: TradeStation
Posts: 81 since Apr 2020
Thanks Given: 11
Thanks Received: 6
I have a dilemma, I have a strategy in TOS I would like to create in EasyLanguage however I not sure how to do it. It has a negative displacement on price. See diagram.
Annotation 2020-08-01 094115
this is how it shows in TOS
Annotation 2020-08-01 094116
This is how it shows in Easylanguage I need both lines back i position
Is there a way to do this, as it is in TOS
Plot Yellow = ( Close[1 ] )
Plot Mag = ( Close[-1] )
August 3rd, 2020, 05:50 PM
ROY, Utah
Experience: Intermediate
Platform: TradeStation
Posts: 81 since Apr 2020
Thanks Given: 11
Thanks Received: 6
I think I got it, have to test a bit
August 4th, 2020, 09:17 AM
ROY, Utah
Experience: Intermediate
Platform: TradeStation
Posts: 81 since Apr 2020
Thanks Given: 11
Thanks Received: 6
OK I can get it to Plot just as in TOS , however when placed in a strategy it will not detect the cross overs as plotted
Last Updated on September 28, 2020