NexusFi: Find Your Edge


Home Menu

 





Need Help EasyLanguage Coding


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one StockT8er with 10 posts (1 thanks)
    2. looks_two vmodus with 6 posts (2 thanks)
    3. looks_3 kinkeadfx with 3 posts (0 thanks)
    4. looks_4 ABCTG with 2 posts (0 thanks)
    1. trending_up 4,704 views
    2. thumb_up 5 thanks given
    3. group 5 followers
    1. forum 21 posts
    2. attach_file 4 attachments




 
Search this Thread

Need Help EasyLanguage Coding

  #11 (permalink)
 StockT8er 
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

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
ZombieSqueeze
Platforms and Indicators
Trade idea based off three indicators.
Traders Hideout
How to apply profiles
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #12 (permalink)
 
vmodus's Avatar
 vmodus 
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 View Post
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!
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #13 (permalink)
 StockT8er 
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

Reply With Quote
Thanked by:
  #14 (permalink)
 StockT8er 
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);

Reply With Quote
  #15 (permalink)
 
vmodus's Avatar
 vmodus 
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 View Post
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!
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #16 (permalink)
 StockT8er 
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

Reply With Quote
  #17 (permalink)
 
vmodus's Avatar
 vmodus 
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!
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #18 (permalink)
 StockT8er 
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] )

Reply With Quote
  #19 (permalink)
 StockT8er 
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

Reply With Quote
  #20 (permalink)
 StockT8er 
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

Reply With Quote




Last Updated on September 28, 2020


© 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