NexusFi: Find Your Edge


Home Menu

 





Store lowest tick since entry in variable


Discussion in EasyLanguage Programming

Updated
    1. trending_up 5,591 views
    2. thumb_up 4 thanks given
    3. group 2 followers
    1. forum 11 posts
    2. attach_file 0 attachments




 
Search this Thread

Store lowest tick since entry in variable

  #1 (permalink)
Learningeasy
Amsterdam, Noord-Holland, Netherlands
 
Posts: 6 since May 2020
Thanks Given: 4
Thanks Received: 0

Hi all,

I'm still rather new to EasyLanguage and for a strategy I'm developing, I'm trying to figure out how I can keep track of the lowest tick (lowest price) since I entered a position.

I tried the following:

HTML Code:
Variables:
     Intrabarpersist LowestPrice(0);

LowestPrice = EntryPrice; // since the initial lowest price is the price of your entry, that's stored in the variable

If Close < LowestPrice Then
     LowestPrice = Close;
However, this only works as long as Close < Close[1]. That is, the lowest price is set to equal the Close price when it's higher than Close[1] but lower than EntryPrice. I think that I understand that what goes wrong is that at each tick/bar the code is executed again and the code only looks at whether Close < EntryPrice, not at whether Close < All previous Closes since entry.

Any ideas about how to do this?

Thanks!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Futures True Range Report
The Elite Circle
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
37 thanks
GFIs1 1 DAX trade per day journal
22 thanks
NexusFi site changelog and issues/problem reporting
22 thanks
The Program
20 thanks
  #2 (permalink)
 
numberjuani's Avatar
 numberjuani 
Agoura Hills, CA USA
 
Experience: Advanced
Platform: Tradestation&Multicharts
Broker: TradeStation
Trading: Futures & Equities
Posts: 128 since Apr 2019
Thanks Given: 9
Thanks Received: 102

LowestPrice = (Lowest(L, BarsSinceEntry);


Learningeasy View Post
Hi all,

I'm still rather new to EasyLanguage and for a strategy I'm developing, I'm trying to figure out how I can keep track of the lowest tick (lowest price) since I entered a position.

I tried the following:

HTML Code:
Variables:
     Intrabarpersist LowestPrice(0);

LowestPrice = EntryPrice; // since the initial lowest price is the price of your entry, that's stored in the variable

If Close < LowestPrice Then
     LowestPrice = Close;
However, this only works as long as Close < Close[1]. That is, the lowest price is set to equal the Close price when it's higher than Close[1] but lower than EntryPrice. I think that I understand that what goes wrong is that at each tick/bar the code is executed again and the code only looks at whether Close < EntryPrice, not at whether Close < All previous Closes since entry.

Any ideas about how to do this?

Thanks!


Reply With Quote
Thanked by:
  #3 (permalink)
Learningeasy
Amsterdam, Noord-Holland, Netherlands
 
Posts: 6 since May 2020
Thanks Given: 4
Thanks Received: 0



numberjuani View Post
LowestPrice = (Lowest(L, BarsSinceEntry);

Thanks for your reply, numberjuani. I'd tried this before however, and I always get an error telling me that it is trying to reference too many bars back. Or am I missing something?

Reply With Quote
  #4 (permalink)
 
numberjuani's Avatar
 numberjuani 
Agoura Hills, CA USA
 
Experience: Advanced
Platform: Tradestation&Multicharts
Broker: TradeStation
Trading: Futures & Equities
Posts: 128 since Apr 2019
Thanks Given: 9
Thanks Received: 102

try
if barssinceentry < maxbarsback then
LowestPrice = (Lowest(L, BarsSinceEntry);



Learningeasy View Post
Thanks for your reply, numberjuani. I'd tried this before however, and I always get an error telling me that it is trying to reference too many bars back. Or am I missing something?


Reply With Quote
Thanked by:
  #5 (permalink)
Learningeasy
Amsterdam, Noord-Holland, Netherlands
 
Posts: 6 since May 2020
Thanks Given: 4
Thanks Received: 0


numberjuani View Post
try
if barssinceentry < maxbarsback then
LowestPrice = (Lowest(L, BarsSinceEntry);

Thanks again for your reply, numberjuani. Your solution does solve the error. However, the value is reset every time the maxbarsback is reached. I could increase that max, of course, but it seems to me that there has to be another way that isn't dependent on an arbitrary setting.

Reply With Quote
  #6 (permalink)
 
numberjuani's Avatar
 numberjuani 
Agoura Hills, CA USA
 
Experience: Advanced
Platform: Tradestation&Multicharts
Broker: TradeStation
Trading: Futures & Equities
Posts: 128 since Apr 2019
Thanks Given: 9
Thanks Received: 102

keep in mind the information you are looking for is in the performance report already, called run up/drawdown, also you have maxpositionloss as a reserved keyword in there. unless I know what you are trying to do, cant be of any more help

Reply With Quote
  #7 (permalink)
Learningeasy
Amsterdam, Noord-Holland, Netherlands
 
Posts: 6 since May 2020
Thanks Given: 4
Thanks Received: 0


numberjuani View Post
keep in mind the information you are looking for is in the performance report already, called run up/drawdown, also you have maxpositionloss as a reserved keyword in there. unless I know what you are trying to do, cant be of any more help

Thanks, numberjuani. For the purpose of strategy automation, all I really need to know is how to store the lowest tick since entry in a variable. :-)

Reply With Quote
  #8 (permalink)
 
numberjuani's Avatar
 numberjuani 
Agoura Hills, CA USA
 
Experience: Advanced
Platform: Tradestation&Multicharts
Broker: TradeStation
Trading: Futures & Equities
Posts: 128 since Apr 2019
Thanks Given: 9
Thanks Received: 102

maybe (entryprice - maxpositionloss/bigpointvalue)

Reply With Quote
Thanked by:
  #9 (permalink)
 
Sandpaddict's Avatar
 Sandpaddict 
Vancouver, Canada
 
Experience: Advanced
Platform: Ninjatrader, MT4
Broker: IB, Global Prime
Trading: Futures CFDs
Posts: 684 since Mar 2020
Thanks Given: 975
Thanks Received: 637


Learningeasy View Post
Thanks, numberjuani. For the purpose of strategy automation, all I really need to know is how to store the lowest tick since entry in a variable. :-)

Im just quickly seeing this I'll go back later and read whole post but off the top of my head you just need to set MaxBarsBack MUCH farther. Either in the Tradestation settings or deliberately in your code. Its because your variables are trying to call too far back and theres no info there. Sorry if this is not what you need. I'll look at full post abit later.

Sent using the NexusFi mobile app

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #10 (permalink)
Learningeasy
Amsterdam, Noord-Holland, Netherlands
 
Posts: 6 since May 2020
Thanks Given: 4
Thanks Received: 0



Sandpaddict View Post
Im just quickly seeing this I'll go back later and read whole post but off the top of my head you just need to set MaxBarsBack MUCH farther. Either in the Tradestation settings or deliberately in your code. Its because your variables are trying to call too far back and theres no info there. Sorry if this is not what you need. I'll look at full post abit later.

Sent using the NexusFi mobile app

Hi Sandpaddict, thanks for your reply. I tried that as well, but if I set the MaxBarsBack too high the strategy doesn't execute. When I read about the reserved word MaxBarsBack in the EasyLanguage reference, I don't really understand why, though.

Reply With Quote




Last Updated on June 1, 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