NexusFi: Find Your Edge


Home Menu

 





stochastic now versus 1 bar ago


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one ABCTG with 1 posts (0 thanks)
    2. looks_two westofpluto with 1 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 clzppt with 1 posts (0 thanks)
    1. trending_up 1,543 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?
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
TradingView Deploys AI to Monitor SEC Filings in Real Ti …
TradingView
Netherlands & Germany Surge as World Cup Field Narro …
Prediction Markets & Event Contracts
Iran Forward Curve: June 30 at 56% vs June 15 at 28% -- …
Prediction Markets & Event Contracts
Orban at 29pct as Hungary Votes Tomorrow -- McIlroy Surg …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
197 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 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,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

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