NexusFi: Find Your Edge


Home Menu

 





stochastic now versus 1 bar ago


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Quick Summary with 1 posts (0 thanks)
    2. looks_two clzppt with 1 posts (0 thanks)
    3. looks_3 ABCTG with 1 posts (0 thanks)
    4. looks_4 westofpluto with 1 posts (0 thanks)
    1. trending_up 1,527 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
westofpluto
Encinitas
 
Posts: 4 since Jan 2019
Thanks Given: 0
Thanks Received: 0

I'm new to easy language and I'm a bit confused about the syntax when comparing the value of the stochastic now versus one bar ago.

The stochastic is computed as follows:

ok = Stochastic(High, Low, Close, 14, 3, 3, 1, oFastK, oFastD, oSlowK, oSlowD);

And the "value" I am looking for is oSlowK - oSlowD. So this is the value at the current bar. How do I get the value at the previous bar? One possibility is this:

ok2 = Stochastic(High[1], Low[1], Close[1], 14, 3, 3, 1, oFastK1, oFastD1, oSlowK1, oSlowD1);
value1 = oSlowK1 - oSlowD1

But is it also (instead) possible to just use this:

value1 = oSlowK[1] = oSowD[1];

What is the correct syntax?


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NinjaTrader Parent Payward Acquires Bitnomial for $550M …
Platforms and Indicators
Asia Equities Crash Overnight -- Nikkei -5.2%, KOSPI -6. …
Traders Hideout
Beijing Summit Closes: Xi Pledges Hormuz Help -- $1.14B …
Prediction Markets & Event Contracts
Bookmap Global Plus Lifetime + Lifetime Addons For Sale
Platforms and Indicators
Orban Crashes to 21pct on Record Turnout -- McIlroy Drop …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
22 thanks
2026 Jlab journal
10 thanks
Trying to learn Volume and price action correlation
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Hello Im new here
5 thanks
  #3 (permalink)
 clzppt 
Huntsville, AL
 
Experience: Intermediate
Platform: TradeStation
Broker: Tradestation
Trading: Index Futures
Posts: 10 since Jun 2014
Thanks Given: 1
Thanks Received: 0



westofpluto View Post
ok2 = Stochastic(High[1], Low[1], Close[1], 14, 3, 3, 1, oFastK1, oFastD1, oSlowK1, oSlowD1);
value1 = oSlowK1 - oSlowD1


westofpluto View Post
value1 = oSlowK[1] = oSowD[1];

I believe the two code snippets should provide exactly the same answer. As a test, put both sets of code in the same indicator and plot them. I would expect they would be the same line.


Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

westofpluto,

you can reference previous bar's values for variables (just like you can do for some reserved words) using [x], where x is the number of bars back starting from the current bar, which is 0.
In your case both ways will work, but since you likely call the stochastic already within your code getting the previous bars values using oSlowK[1] and oSowD[1] will be more efficient.

If you haven't done so already, I would suggest checking out the free EasyLanguage Essentials PDF that you can download on the Tradestation website. It will bring you up to speed in terms of the basics of EasyLanguage.

Regards,

ABCTG


Follow me on X Reply With Quote




Last Updated on January 28, 2019


© 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