NexusFi: Find Your Edge


Home Menu

 





Stuck in RSI Indicator conversion


Discussion in EasyLanguage Programming

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




 
Search this Thread

Stuck in RSI Indicator conversion

  #1 (permalink)
 jojojo 
FrankfurtGermany
 
Experience: Beginner
Platform: Tradestation
Posts: 41 since Oct 2010
Thanks Given: 4
Thanks Received: 7

Hello
I'm trying to convert an indicator to Multicharts 64.Is From Trendspider , they use some kind of Java. This is what I get:

 
Code
describe_indicator("RSI pressure zones");

const ATR_FACTOR = 5;
const LENGTH = 14;

const rsiNormalized = rsi(close, LENGTH).map(value => (value - 50) / 100);
const rsiScaledToAtr = for_every(atr(LENGTH), rsiNormalized, (a, r) => a * r * ATR_FACTOR);
const rsiDoubleScaledToAtr = mult(rsiScaledToAtr, 2);

const rsiLine = add(ohlc4, rsiScaledToAtr);
const rsiLineDouble = add(ohlc4, rsiDoubleScaledToAtr);

color_cloud(ohlc4, rsiLine, '#ff0000', '#00ff00', 'Red Area', 'Green Area');
color_cloud(rsiLine, rsiLineDouble, '#550000', 'green', 'Red Area', 'Green Area');

Conversion is so far :

 
Code
inputs:
      Length(14),
      ATR_Factor(5);
vars:
    
    ArraySize(10000),
    j(0);

array:
    RSIArray[10000](0),
    RsiScaledToAtr[10000](0),
    currentRsiScaled[10000](0),
    rsiNormalized[10000](0),
    RsiLineDouble[10000](0),
    RsiLine[10000](0);

// Calculate and normalize RSI values
for j = 0 to BarNumber - 1 begin
    RSIArray[j] = (RSI(Close, Length)[j] - 50) / 100;
end;

// Scale RSI values to ATR and store in currentRsiScaled
for j = 0 to BarNumber - 1 begin
    currentRsiScaled[j] = atr(Length)[j] * RSIArray[j] * ATR_Factor;
    // Use currentRsiScaled[j] for further calculations or assign it to another series
end;

// Copy values from currentRsiScaled to rsiScaledToAtr
for j = 0 to BarNumber - 1 begin
    RsiScaledToAtr[j] = currentRsiScaled[j];
end;

// Calculate RsiLine based on TypicalPrice and scaled RSI values
for j = 0 to BarNumber - 1 begin
   RsiLine[j] = TypicalPrice + RsiScaledToAtr[j];
   // Plot RsiLine on the chart
   Plot1(RsiLine[j], "RsiLine");
   //Plot1((RSI(Close, Length)[j] - 50) / 100 );
end;
{
// Calculate RsiLineDouble by doubling the scaled RSI values
for j = 0 to BarNumber - 1 begin
   RsiLineDouble[j] = RsiScaledToAtr[j] * 2;
   // Plot RsiLineDouble on the chart
   Plot2(RsiLineDouble[j], "RsiLineDouble");
end;
}
But it gives unclear result - especially the Plot2(RsiLineDouble is 100% wrong .
Any help ?

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
REcommedations for programming help
Sierra Chart
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #2 (permalink)
 jojojo 
FrankfurtGermany
 
Experience: Beginner
Platform: Tradestation
Posts: 41 since Oct 2010
Thanks Given: 4
Thanks Received: 7

add a pic


Started this thread Reply With Quote
  #3 (permalink)
 Pickles1774 
Pembroke Pines
 
Experience: Beginner
Platform: NinjaTrader
Broker: Ninjatrader
Trading: Futures
Frequency: Daily
Duration: Minutes
Posts: 24 since Nov 2022
Thanks Given: 0
Thanks Received: 2


Here you go please test

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using PowerLanguage.Indicator;

namespace PowerLanguage.Strategy
{
public class RsiPressureZones : SignalObject
{
private readonly double ATR_FACTOR = 5;
private readonly int LENGTH = 14;

private IPlotSeries rsiNormalized;
private IPlotSeries rsiScaledToAtr;
private IPlotSeries rsiDoubleScaledToAtr;
private IPlotSeries rsiLine;
private IPlotSeries rsiLineDouble;

protected override void Create()
{
rsiNormalized = new PlotSeries(Color.Transparent);
rsiScaledToAtr = new PlotSeries(Color.Transparent);
rsiDoubleScaledToAtr = new PlotSeries(Color.Transparent);
rsiLine = new PlotSeries(Color.Transparent);
rsiLineDouble = new PlotSeries(Color.Transparent);

AddPlot(rsiNormalized);
AddPlot(rsiScaledToAtr);
AddPlot(rsiDoubleScaledToAtr);
AddPlot(rsiLine);
AddPlot(rsiLineDouble);
}

protected override void StartCalc()
{
var rsi = RSI(Close, LENGTH);
var rsiNormalized = rsi.Select(value => (value - 50) / 100);
var atr = ATR(LENGTH)[0];

var rsiScaledToAtr = rsiNormalized.Select((r, i) => atr[i] * r * ATR_FACTOR);
var rsiDoubleScaledToAtr = rsiScaledToAtr.Select(value => value * 2);

var rsiLine = Close + rsiScaledToAtr;
var rsiLineDouble = Close + rsiDoubleScaledToAtr;

this.rsiNormalized.Set(rsiNormalized);
this.rsiScaledToAtr.Set(rsiScaledToAtr);
this.rsiDoubleScaledToAtr.Set(rsiDoubleScaledToAtr);
this.rsiLine.Set(rsiLine);
this.rsiLineDouble.Set(rsiLineDouble);
}

protected override void CalcBar()
{
}
}
}

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 
Serger's Avatar
 Serger 
Quebec
 
Experience: Intermediate
Platform: Multicharts 64 +VolProfile
Broker: Interactive Brokers
Trading: Ym, Es
Posts: 74 since Oct 2010
Thanks Given: 64
Thanks Received: 25

Hello ,
you can try with Chat gbp, I had good results with, sometimes it takes several tests but is ok .
sorry I'm on a trip and impossible for me to test.

Reply With Quote




Last Updated on January 27, 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 - Downloads - Top
no new posts