NexusFi: Find Your Edge


Home Menu

 





PineScript to EasyLanguage


Discussion in TradeStation

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




 
Search this Thread
  #1 (permalink)
troylavigne
Tampa, FL, USA
 
Posts: 2 since Apr 2023
Thanks Given: 0
Thanks Received: 0

Can someone help me turn this PineScript code into EasyLanguage to be used on TradeStation?

//@version=5
strategy("Dynamic Range Deviation Entry", overlay=true)

// Define the lookback period for calculating the range
lookback_period = input.int(20, "Lookback Period")

// Calculate the highest high and lowest low over the lookback period
highest_high = ta.highest(high, lookback_period)
lowest_low = ta.lowest(low, lookback_period)

// Define the range of prices to trade within based on the highest high and lowest low
range_low = lowest_low
range_high = highest_high

// Calculate the range width
range_width = range_high - range_low

// Calculate the entry thresholds based on the deviation from the range
entry_deviation_long = input.float(0.04, "Long Entry Deviation")
entry_deviation_short = input.float(0.033, "Short Entry Deviation")

entry_threshold_long = range_low - (range_width * entry_deviation_long)
entry_threshold_short = range_high + (range_width * entry_deviation_short)

// Place buy and sell orders based on the entry thresholds
strategy.entry("Long", strategy.long, comment="Long Entry", limit=entry_threshold_long)
strategy.entry("Short", strategy.short, comment="Short Entry", limit=entry_threshold_short)

// Close the entire position if it goes against the entry direction
if strategy.position_size != 0 and ((strategy.position_size > 0 and close < range_low) or (strategy.position_size < 0 and close > range_high))
strategy.close("Long", comment="Long Exit")
strategy.close("Short", comment="Short Exit")

// Plot the range and the entry thresholds
plot(range_low, color=color.green, style=plot.style_linebr)
plot(range_high, color=color.red, style=plot.style_linebr)
plot(entry_threshold_long, color=color.green, style=plot.style_circles, linewidth=3)
plot(entry_threshold_short, color=color.red, style=plot.style_circles, linewidth=3)


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Support / Resistance indicator
Tradovate
Sierra Chart Trade order fill nor display correct data
The Elite Circle
How to look up market depth?
MultiCharts
Half-life over Cointegration?
Traders Hideout
Retirement Portfolio Strategy
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Gradient Divergence Trading
5 thanks
Tariffs and what comes next...
4 thanks
HumbleTraders next chapter
2 thanks
PATs - Price Action Trading - Elite Members Common Journal
1 thanks
NexusFi site changelog and issues/problem reporting
1 thanks
  #2 (permalink)
troylavigne
Tampa, FL, USA
 
Posts: 2 since Apr 2023
Thanks Given: 0
Thanks Received: 0

Open to paying someone to help if needed!


Reply With Quote
  #3 (permalink)
 pabloatb 
Montevideo
 
Experience: Beginner
Platform: NinjaTrader
Posts: 1 since Apr 2020
Thanks Given: 3
Thanks Received: 0


Hi, did you get help with this?


troylavigne View Post
Can someone help me turn this PineScript code into EasyLanguage to be used on TradeStation?

//@version=5
strategy("Dynamic Range Deviation Entry", overlay=true)

// Define the lookback period for calculating the range
lookback_period = input.int(20, "Lookback Period")

// Calculate the highest high and lowest low over the lookback period
highest_high = ta.highest(high, lookback_period)
lowest_low = ta.lowest(low, lookback_period)

// Define the range of prices to trade within based on the highest high and lowest low
range_low = lowest_low
range_high = highest_high

// Calculate the range width
range_width = range_high - range_low

// Calculate the entry thresholds based on the deviation from the range
entry_deviation_long = input.float(0.04, "Long Entry Deviation")
entry_deviation_short = input.float(0.033, "Short Entry Deviation")

entry_threshold_long = range_low - (range_width * entry_deviation_long)
entry_threshold_short = range_high + (range_width * entry_deviation_short)

// Place buy and sell orders based on the entry thresholds
strategy.entry("Long", strategy.long, comment="Long Entry", limit=entry_threshold_long)
strategy.entry("Short", strategy.short, comment="Short Entry", limit=entry_threshold_short)

// Close the entire position if it goes against the entry direction
if strategy.position_size != 0 and ((strategy.position_size > 0 and close < range_low) or (strategy.position_size < 0 and close > range_high))
strategy.close("Long", comment="Long Exit")
strategy.close("Short", comment="Short Exit")

// Plot the range and the entry thresholds
plot(range_low, color=color.green, style=plot.style_linebr)
plot(range_high, color=color.red, style=plot.style_linebr)
plot(entry_threshold_long, color=color.green, style=plot.style_circles, linewidth=3)
plot(entry_threshold_short, color=color.red, style=plot.style_circles, linewidth=3)


Reply With Quote




Last Updated on August 9, 2023


© 2025 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