Cannot use decimal in RSI formula - NinjaTrader Programming | futures io social day trading
futures io futures trading


Cannot use decimal in RSI formula
Updated: Views / Replies:1,111 / 3
Created: by sqadri Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Cannot use decimal in RSI formula

  #1 (permalink)
Elite Member
Orlando, FL/ USA
 
Futures Experience: Beginner
Platform: Ninja Trader, Firetip
Favorite Futures: Crude Oil
 
Posts: 2 since Sep 2011
Thanks: 2 given, 0 received

Cannot use decimal in RSI formula

Hi,

I hope someone can help me out here. I am beginner with Ninja Trader. Was trying to write out my first strategy using Ninja Trader. I was following the book with the example of the RSI code. I wanted to know if I wanted to code such that I go long for instance when RSI hits 18.5 as opposed to my current 17 how can I do that since it tells me RSI is a Int? I thought RSI has a decimal when I look in the chart ? Below is my code .

My goal is to make the line where it says
if (CrossAbove(RSI(RSIPeriod, RSISmooth),17,1))
something like this ..

if (CrossAbove(RSI(RSIPeriod, RSISmooth),18.5,1))

If I do this the code compiles fine but doesn't Enter me long if RSI comes below 18.5 and moves up. I think it has to do because it's expecting a Integer.

Thanks


#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
///<summary>
/// RSI with a Stop loss and Profit Target
///</summary>
[Description("RSI with a Stop loss and Profit Target")]
publicclass ShoaibRSILow : Strategy
{
#region Variables
// Wizard generated variables
privateint rSIPeriod = 14; // Default setting for RSIPeriod
privateint rSISmooth = 3; // Default setting for RSISmooth
privateint profitTarget = 25; // Default setting for ProfitTarget
privateint stopLoss = 20; // Default setting for StopLoss
// User defined variables (add any user defined variables below)
#endregion
///<summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
///</summary>
protectedoverridevoid Initialize()
{
CalculateOnBarClose =
true;
//This will add the RSI indicator to the chart for vizulation
Add(RSI(RSIPeriod,RSISmooth));
//Add stop loss and profit target orders
SetStopLoss(CalculationMode.Ticks, StopLoss);
SetProfitTarget(CalculationMode.Ticks, ProfitTarget);
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
if (CurrentBar < RSIPeriod)
return;

if (CrossAbove(RSI(RSIPeriod, RSISmooth),17,1))
{
EnterLong();
}
}
#region Properties
[Description(
"RSI Period")]
[GridCategory(
"Parameters")]
publicint RSIPeriod
{
get { return rSIPeriod; }
set { rSIPeriod = Math.Max(1, value); }
}
[Description(
"RSI Smooth")]
[GridCategory(
"Parameters")]
publicint RSISmooth
{
get { return rSISmooth; }
set { rSISmooth = Math.Max(1, value); }
}
[Description(
"Profit Target Offset")]
[GridCategory(
"Parameters")]
publicint ProfitTarget
{
get { return profitTarget; }
set { profitTarget = Math.Max(1, value); }
}
[Description(
"Stop Loss Offset")]
[GridCategory(
"Parameters")]
publicint StopLoss
{
get { return stopLoss; }
set { stopLoss = Math.Max(1, value); }
}
#endregion
}
}

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Calcutta, India
 
Futures Experience: Intermediate
Platform: ArthaChitra
 
Posts: 278 since Jun 2009
Thanks: 161 given, 259 received


havent tested but it should be like this. the changes are in green.

just assign the appropriate value from the parameter dialog box CrossoverValue

 
Code
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
///<summary>
/// RSI with a Stop loss and Profit Target
///</summary>
    [Description("RSI with a Stop loss and Profit Target")]
    public class ShoaibRSILow : Strategy
    {
        #region Variables
        // Wizard generated variables
        private int rSIPeriod = 14; // Default setting for RSIPeriod
        private int rSISmooth = 3; // Default setting for RSISmooth
        private int profitTarget = 25; // Default setting for ProfitTarget
        private int stopLoss = 20; // Default setting for StopLoss
        // User defined variables (add any user defined variables below)
        
        double crossoverValue = 17;
        #endregion
        ///<summary>
        /// This method is used to configure the strategy and is called once before any strategy method is called.
        ///</summary>
        protected override void Initialize()
        {
            CalculateOnBarClose = true;
            //This will add the RSI indicator to the chart for vizulation
            Add(RSI(RSIPeriod,RSISmooth));
            //Add stop loss and profit target orders
            SetStopLoss(CalculationMode.Ticks, StopLoss);
            SetProfitTarget(CalculationMode.Ticks, ProfitTarget);
        }
        ///<summary>
        /// Called on each bar update event (incoming tick)
        ///</summary>
        protected override void OnBarUpdate()
        {
            if (CurrentBar < RSIPeriod)
            return;

            if (CrossAbove(RSI(RSIPeriod, RSISmooth),crossoverValue,1))
            {
                EnterLong();
            }
        }
        
        
        
        
        #region Properties
        [Description("RSI Period")]
        [GridCategory("Parameters")]
        public int RSIPeriod
        {
            get { return rSIPeriod; }
            set { rSIPeriod = Math.Max(1, value); }
        }
        [Description("RSI Smooth")]
        [GridCategory("Parameters")]
        public int RSISmooth
        {
            get { return rSISmooth; }
            set { rSISmooth = Math.Max(1, value); }
        }
        [Description("Profit Target Offset")]
        [GridCategory("Parameters")]
        public int ProfitTarget
        {
            get { return profitTarget; }
            set { profitTarget = Math.Max(1, value); }
        }
        [Description("Stop Loss Offset")]
        [GridCategory("Parameters")]
        public int StopLoss
        {
            get { return stopLoss; }
            set { stopLoss = Math.Max(1, value); }
        }
        
        [Description("Crossover value")]
        [GridCategory("Parameters")]
        public double CrossoverValue
        {
            get { return crossoverValue; }
            set { crossoverValue = Math.Max(1, value); }
        }
        #endregion
    }
}

Reply With Quote
The following user says Thank You to bukkan for this post:
 
  #4 (permalink)
 Vendor: www.innovative-trading-solutions-online.com 
Hartford, CT. USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: AMP/CQG, Kinetick
Favorite Futures: TF
 
RJay's Avatar
 
Posts: 677 since Jun 2009
Thanks: 726 given, 740 received

Hi sqadri,

Everywhere you see "int" in your code you are restriction those values to whole numbers. If you want decimals, you must redefine those values to "double" so they will be processed as decimal values.

RJay

Reply With Quote
The following user says Thank You to RJay for this post:

Reply



futures io > > > > > Cannot use decimal in RSI formula

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula 1 JohnnyAustin Off-Topic 73 April 15th, 2015 08:08 PM
force decimal price marker display different than ticksize mea109 NinjaTrader Programming 8 September 26th, 2011 08:56 PM
Easylanguage : Decimal problem Ozons EasyLanguage Programming 3 February 13th, 2011 01:28 AM
HELP with understanding this FORMULA plz.... mdsvtr Currency Futures 1 February 11th, 2011 10:11 PM
NT Rising / Falling formula diverdan Traders Hideout 7 November 1st, 2010 08:45 AM


All times are GMT -4. The time now is 03:17 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-11 in 0.41 seconds with 19 queries on phoenix via your IP 54.226.172.30