NexusFi: Find Your Edge


Home Menu

 





oscillator code not working, numerical expression expected here


Discussion in EasyLanguage Programming

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




 
Search this Thread

oscillator code not working, numerical expression expected here

  #1 (permalink)
hhomsi8
Stockholm, Sweden
 
Posts: 10 since Feb 2023
Thanks Given: 7
Thanks Received: 0

Hi, I am new here and I am enjoying reading these posts, learning a lot. thanks for it

I am trying to convert code from Pine Script to TradeStation easy langauge, all is fine except I am getting error near
HTML Code:
s = s + (close > open[ss]) - (close < open[ss]);
HTML Code:
inputs: 
double length(14), 
double calcLength(5), 
double smoothLength(3);

vars: 
double s(0), 
double MA(0), 
double Main(0), 
double Signal(0), 
double ss(0),
double len(0);

len = length;

s = 0;
for ss = 0 to (len - 1) begin
    s = s + (close > open[ss]) - (close < open[ss]);
end

MA = XAverage(s, calcLength);
Main = XAverage(MA, smoothLength);
Signal = XAverage(Main, smoothLength);

plot1(Main, "Main", iff(Main > Signal, green, red));
plot2(Signal, "Signal", iff(Main > Signal, green, red));
plot3(0, "ZeroLine", gray);

plot4(length, "UpperLine", red);
plot5(-length, "LowerLine", green);

plot6(length * 0.7, "Overbought", gray);
plot7(-length * 0.7, "Oversold", gray);

fillPlot(plot4, plot5, "Range", iff(Main > Signal, green, red), 90);
fillPlot(plot6, plot4, "Overbought", red, 90);
fillPlot(plot7, plot5, "Oversold", green, 90);


I can not seem to understand where its going wrong, any help would be very appreciate it

Thanks a lot in advance

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Trade idea based off three indicators.
Traders Hideout
REcommedations for programming help
Sierra Chart
Trend Direction Force Index (TDFI)
Platforms and Indicators
About a successful futures trader who didnt know anythin …
Psychology and Money Management
 
  #2 (permalink)
 sevensa 
Singapore, Singapore
 
Experience: Intermediate
Platform: Sierra Chart/IB, NT, TS
Trading: NQ, Weekly Options
Frequency: Several times daily
Duration: Hours
Posts: 42 since Aug 2017
Thanks Given: 31
Thanks Received: 68

This part doesn't translate to a numerical expression. With other words, doesn't translate to an actual number:

(close > open[ss]) - (close < open[ss]);

What are you trying to do here?

Reply With Quote
Thanked by:
  #3 (permalink)
 sevensa 
Singapore, Singapore
 
Experience: Intermediate
Platform: Sierra Chart/IB, NT, TS
Trading: NQ, Weekly Options
Frequency: Several times daily
Duration: Hours
Posts: 42 since Aug 2017
Thanks Given: 31
Thanks Received: 68


So, I think you are trying to add 1 when close is greater than open and subtract 1 when close is less than open. One way of doing it is to change this:

 
Code
   s = s + (close > open[ss]) - (close < open[ss]);
to this:

 
Code
    s = s + IFF(close > open[ss],1,0) - IFF(close < open[ss],1,0);
btw, you also have other issues in your code. "Gray" is not a recognized color in EasyLangauge. darkgray is. I am also not sure about fillplot.

Reply With Quote
Thanked by:
  #4 (permalink)
hhomsi8
Stockholm, Sweden
 
Posts: 10 since Feb 2023
Thanks Given: 7
Thanks Received: 0


sevensa View Post
So, I think you are trying to add 1 when close is greater than open and subtract 1 when close is less than open. One way of doing it is to change this:

 
Code
   s = s + (close > open[ss]) - (close < open[ss]);
to this:

 
Code
    s = s + IFF(close > open[ss],1,0) - IFF(close < open[ss],1,0);
btw, you also have other issues in your code. "Gray" is not a recognized color in EasyLangauge. darkgray is. I am also not sure about fillplot.

Thanks a lot for the help, yes indeed after long review i discovered that I forgot to implement the "if" statement, and was confused about the error becuz I thought I did.

Reply With Quote




Last Updated on May 19, 2023


© 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