NexusFi: Find Your Edge


Home Menu

 





How to keep the condition once the event occured


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #1 (permalink)
 
Small Dog's Avatar
 Small Dog 
Sydney NSW Australia
 
Experience: Intermediate
Platform: TradeStation, Oanda
Trading: Forex, index futures
Frequency: Daily
Duration: Days
Posts: 174 since Jun 2020
Thanks Given: 18
Thanks Received: 163

How to I keep the variable once an event occurred? For example, once RSI becomes overbought, I want the condition1 = true, and then look for breakouts.

A simple "if RSI (close, 14) < 30 then condition1 = true" doesn't work, because in the next several bars it can move above 30, while the breakout I want hasn't happened.
How do I keep the condition or a variable the same once it occurred, even if it changes in the next several bars?

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
is there a better Trade Performance tool for NinjaTrader?
NinjaTrader
Historical data for Kospi and Nikkei Index
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Brendt Skorupinsky
Trading Reviews and Vendors
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
HumbleTraders next chapter
80 thanks
Legends Trading: Ask Me Anything (AMA) w/Greg Khojikian CEO
38 thanks
Tao te Trade: way of the WLD
33 thanks
Deeteeā€™s DAX Trading Journal (time based)
22 thanks
Learning to Trade with the Big Money
16 thanks
  #2 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT Stellar & Tradestation
Broker: Primarily Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals, U308 and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,060 since Dec 2013
Thanks Given: 4,410
Thanks Received: 10,230


Small Dog View Post
How to I keep the variable once an event occurred? For example, once RSI becomes overbought, I want the condition1 = true, and then look for breakouts.

A simple "if RSI (close, 14) < 30 then condition1 = true" doesn't work, because in the next several bars it can move above 30, while the breakout I want hasn't happened.
How do I keep the condition or a variable the same once it occurred, even if it changes in the next several bars?

Surely it can only change back if you change it back (or reset it)?

Reply With Quote
Thanked by:
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,441 since Apr 2013
Thanks Given: 487
Thanks Received: 1,633


Small Dog,

as @SMCJB correctly pointed out a condition written as

if RSI( Close, 14 ) < 30 then rsiWasBelow30 = true ;

will remain true unless you reset the variable back to false somewhere in your code.

If you evaluate the condition the following way

rsiWasBelow30 = RSI( Close, 14 ) < 30 ;

rsiWasBelow30 would be false if the RSI is >= 30.

I would suggest using the print reserved word to check the value that your variable holds at different bars.

Regards,

ABCTG


Small Dog View Post
How to I keep the variable once an event occurred? For example, once RSI becomes overbought, I want the condition1 = true, and then look for breakouts.

A simple "if RSI (close, 14) < 30 then condition1 = true" doesn't work, because in the next several bars it can move above 30, while the breakout I want hasn't happened.
How do I keep the condition or a variable the same once it occurred, even if it changes in the next several bars?


Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
 
Small Dog's Avatar
 Small Dog 
Sydney NSW Australia
 
Experience: Intermediate
Platform: TradeStation, Oanda
Trading: Forex, index futures
Frequency: Daily
Duration: Days
Posts: 174 since Jun 2020
Thanks Given: 18
Thanks Received: 163

Thanks for the replies. I suspect I am not terribly bright when it comes to coding. Currently I am struggling with another code, sort of related to the earlier one.

I am trying to get the strategy to go long if both RSI of weekly and RSI of daily price are below a value. I thought the code should be as simple as that:

If RSI (close, length) < 30 AND RSI (close of Data2, length) < 10 then buy this bar at close; //Default timeframe is daily, Data2 is weekly

For some reason it doesn't work, and the strategy doesn't take trades. I tried RSI (close of data2, length[1] and CloseW (1). Doesn't work. What am I missing? Should I assign a variable to the weekly rsi and use that instead? As in RSI (close of data2, length) = o_sold; if 0_sold <=10 the buy etc.

Any help would be appreciated.

Started this thread Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,441 since Apr 2013
Thanks Given: 487
Thanks Received: 1,633

Small Dog,

I would suggest starting with the free EasyLanguage Essentials PDF that will give you a good, solid foundation of the basics. This includes how you can correctly compute functions on secondary data series.

As previously suggested, use the print reserved word to check what is going on within your code i.e. are conditions fulfilled or not, are values different than you think they should be etc.. This usually is an invaluable tool for tracking code issues down.

Regards,

ABCTG


Small Dog View Post
Thanks for the replies. I suspect I am not terribly bright when it comes to coding. Currently I am struggling with another code, sort of related to the earlier one.

I am trying to get the strategy to go long if both RSI of weekly and RSI of daily price are below a value. I thought the code should be as simple as that:

If RSI (close, length) < 30 AND RSI (close of Data2, length) < 10 then buy this bar at close; //Default timeframe is daily, Data2 is weekly

For some reason it doesn't work, and the strategy doesn't take trades. I tried RSI (close of data2, length[1] and CloseW (1). Doesn't work. What am I missing? Should I assign a variable to the weekly rsi and use that instead? As in RSI (close of data2, length) = o_sold; if 0_sold <=10 the buy etc.

Any help would be appreciated.


Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on July 2, 2024


© 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 - Sitemap - Downloads - Top
no new posts