NexusFi: Find Your Edge


Home Menu

 





How to keep the condition once the event occured


Discussion in EasyLanguage Programming

Updated
    1. trending_up 1,367 views
    2. thumb_up 4 thanks given
    3. group 3 followers
    1. forum 5 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: 183 since Jun 2020
Thanks Given: 18
Thanks Received: 175

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?
Bookmap Global Plus Lifetime + Lifetime Addons For Sale
Platforms and Indicators
April FOMC Minutes: Most Divided Fed Since 1992 -- Many …
Traders Hideout
Trump Lands in Beijing on CPI Day: Iran Peace Expires To …
Prediction Markets & Event Contracts
Warsh Opens Today, Hormuz June 19 -- WTI Below $80, Fran …
Prediction Markets & Event Contracts
Six Days to Kickoff: World Cup Prediction Markets Hit $1 …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
196 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
BERN ALGOS algo trading journal
8 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,241 since Dec 2013
Thanks Given: 4,585
Thanks Received: 10,531


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,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642


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 X 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: 183 since Jun 2020
Thanks Given: 18
Thanks Received: 175

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,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

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 X Reply With Quote
Thanked by:
  #6 (permalink)
 
Small Dog's Avatar
 Small Dog 
Sydney NSW Australia
 
Experience: Intermediate
Platform: TradeStation, Oanda
Trading: Forex, index futures
Frequency: Daily
Duration: Days
Posts: 183 since Jun 2020
Thanks Given: 18
Thanks Received: 175

As a typical lazy and not a very bright coder I went to Upwork and got someone else to do it.

A terrific resource, by the way, and I used it quite a few times.


Started this thread Reply With Quote




Last Updated on August 5, 2024


© 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