NexusFi: Find Your Edge


Home Menu

 





Basic question on EasyLanguage


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #1 (permalink)
cruncher
Milan, Italy
 
Posts: 2 since Oct 2015
Thanks Given: 2
Thanks Received: 0

Hi everyone
I don't use Easy Language but I found this code and I would like some help understanding what the first "Sell next bar" means:

 
Code
Variable: 
    down_days(3), max_holding_days(4), trade_size(50), average_daily_range(0), daily_price_change(0); 
 
daily_price_change = Close - Close[1]; 
average_daily_range = AvgTrueRange(50); 
 
// Buy MOC if market is down more than 5% of average daily range 3 days in a row: 
If Marketposition = 0 and Highest(daily_price_change, down_days) < - average_daily_range * 5/100 then  
                Buy("Entry") trade_size Contracts this bar at Close; 
                 
// Stop loss at 2 daily ranges from last close:  
Sell("Exit_Stop") next bar at Close - 2*average_daily_range Stop; 
 
// Profit take at half daily range from last close: 
Sell("Exit_Prft") next bar at Close + 0.5*average_daily_range Limit;
1) for every bar since the buy, calculate the average true range for the past 50 bars and set a stop for the next bar at this bar's close minus twice the ATR -> the stop level is changed continuously
OR
2) at buy's bar, calculate the average true range for the past 50 bars, calculate the stop level at buy's bar's close minus twice the ATR, and then for each bar since the buy set a stop at the calculated level -> the stop level is fixated at the buy signal

Which one (or maybe none) is the right interpretation?

Thanks


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pakistan Mediator in Tehran as Hormuz Normalization Coll …
Prediction Markets & Event Contracts
Iran Update May 8: Still Reviewing MOU, Demands Reparati …
Traders Hideout
Iran Airspace Collapses 18 Points to 15.5% While Hormuz …
Prediction Markets & Event Contracts
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
Wood Mackenzie Drops $200 Oil Forecast -- Airspace Expir …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
15 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #3 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 691



cruncher View Post
1) for every bar since the buy, calculate the average true range for the past 50 bars and set a stop for the next bar at this bar's close minus twice the ATR -> the stop level is changed continuously
OR
2) at buy's bar, calculate the average true range for the past 50 bars, calculate the stop level at buy's bar's close minus twice the ATR, and then for each bar since the buy set a stop at the calculated level -> the stop level is fixated at the buy signal

You're very close with (1), except that it's not 'for every bar since the buy'.

The script calculates its variables with every calculation, on every bar (without depending on the buy):
 
Code
daily_price_change = Close - Close[1]; 
average_daily_range = AvgTrueRange(50);
It then submits the stop:

 
Code
Sell("Exit_Stop") next bar at Close - 2*average_daily_range Stop;
Since the `Close` and `average_daily_range` change with each calculation, your first interpretation is correct: the stop changes with each script calculation.


Reply With Quote
  #4 (permalink)
cruncher
Milan, Italy
 
Posts: 2 since Oct 2015
Thanks Given: 2
Thanks Received: 0

Thank you Jura, very helpful!


Reply With Quote




Last Updated on October 31, 2015


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