Dynamic calculation of R/R after an entry signal - NinjaTrader Programming | futures io social day trading
futures io futures trading


Dynamic calculation of R/R after an entry signal
Updated: Views / Replies:506 / 1
Created: by AquaLife Attachments:1

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
 

Dynamic calculation of R/R after an entry signal

  #1 (permalink)
Trading Apprentice
Amsterdam
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Forex
 
AquaLife's Avatar
 
Posts: 3 since Oct 2014
Thanks: 1 given, 0 received

Dynamic calculation of R/R after an entry signal

Hi all,

I'm currently working on a strategy that measures the Risk/Reward ratio as an entry filter. This is the coding I'm currently using for a LONG entry;

 
Code
if (CCI(256)[0] > -100 && CCI(256)[1] > -100 && CCI(256)[2] > -100 && CrossAbove(CCI(256), -100, 3) && ((EMA(50)[0] - Close[0]) / (Close[0] - (Low[LowestBar(Low, 96)] - 10 * TickSize))) >= 0.90)
			{	
				LongEntryOrder = EnterLong(30000, "LongEntry");
				DrawArrowUp("My up arrow" + CurrentBar, false, 0, Low[0] - 5 * TickSize, Color.Lime);
			}
As you can see I'm checking if CCI > -100 for the past 3 bars. The red part is the R/R measurement. As you can see I want the R/R ratio to be at least 0,90 before I want to enter a trade. But now the thing I can't figure out yet;

IF the R/R ratio is below 0,9, but all the other rules for entry are met, I want my strategy to check on the next bar if;

1) Target 1 wouldn't have hit yet. (Target 1 = EMA 50 period)
2) My stoploss wouldn't have hit yet (StopLoss = 10 ticks below the lowest low of the last 96 bars counted from the entry bar)
3) CCI remains above -100
4) R/R ratio is at least 1.10

I want the strategy to keep checking these 4 requirements and enter a LONG position if all 4 requirements are met. If 1 of the 4 are false, I want the strategy to reset completely and start checking again for the original entry requirements. But I have no idea what logic to use to keep checking this every bar and still keep in mind the first entry requirements.

I hope I'm making some sense here. To clear things up, I've added a chart where I'm illustrating what I just described.
I've also added my whole coding.

 
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>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class CCItest : Strategy
    {
        #region Variables
        // Wizard generated variables
        // User defined variables (add any user defined variables below)
		
		private IOrder LongEntryOrder = null;
		private IOrder ShortEntryOrder = null;
		private IOrder LongScalper = null;
		private IOrder LongTarget1 = null;
		private IOrder ShortScalper = null;
		private IOrder ShortTarget1 = null;
		
		#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;
			ExitOnClose = false;
			EntriesPerDirection = 1;
			EntryHandling = EntryHandling.AllEntries;
			
			Add(CCI(256));
            Add(EMA(50));
		}

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            // LONG entry condition set 
            if (CCI(256)[0] > -100 && CCI(256)[1] > -100 && CCI(256)[2] > -100 && CrossAbove(CCI(256), -100, 3) && ((EMA(50)[0] - Close[0]) / (Close[0] - (Low[LowestBar(Low, 96)] - 10 * TickSize))) >= 0.90)
			{	
				LongEntryOrder = EnterLong(10000, "LongEntry");
				DrawArrowUp("My up arrow" + CurrentBar, false, 0, Low[0] - 5 * TickSize, Color.Lime);
			}
		
			// SHORT entry condition set
            if (CCI(256)[0] < 100 && CCI(256)[1] < 100 && CCI(256)[2] < 100 && CrossBelow(CCI(256), 100, 3) && ((Close[0] - EMA(50)[0]) / ((High[HighestBar(High, 96)] + 10 * TickSize) - Close[0])) >= 0.90)
			{
				ShortEntryOrder = EnterShort(10000, "ShortEntry");
				DrawArrowDown("My down arrow" + CurrentBar, false, 0, High[0] + 5 * TickSize, Color.Lime);
				}
			
			
			
			
			
			

			
			
			
			// LONG StopLoss condition set
			if (Position.MarketPosition == MarketPosition.Long)
			{
				if (Position.Quantity == 10000)
				{
					if (EMA(50)[0] <= Position.AvgPrice)
					{
						ExitLong(0, 10000, "ExitEMALong", "");
					}
				}
			}
				
			// SHORT StopLoss condition set
			if (Position.MarketPosition == MarketPosition.Short)
			{
				if (Position.Quantity == 10000)
				{
					if (EMA(50)[0] >= Position.AvgPrice)
					{
						ExitShort(0, 10000, "ExitEMAShort", "");
					}
				}
			}
			
			
			
			
			
			
			
			
			
			
			// LONG Scalper condition set
			if (Position.MarketPosition == MarketPosition.Long)
			{
				if (Position.Quantity == 10000)
				{
					LongScalper = ExitLongLimit(0, true, 10000, EMA(50)[0] - 2 * TickSize, "LongScalper", "");
				}
			}

			// SHORT Scalper condition set
			if (Position.MarketPosition == MarketPosition.Short)
			{
				if (Position.Quantity == 10000)
				{
					ShortScalper = ExitShortLimit(0, true, 10000, EMA(100)[0] + 2 * TickSize, "ShortScalper", "");
				}
			}

		}
		
		
		
		
		
		
		
		
		
		
		protected override void OnExecution (IExecution execution)
		{
			if (LongEntryOrder != null && LongEntryOrder == execution.Order)
			{
				if (Position.Quantity == 10000)
				{
					ExitLongStop(0, true, 30000, Low[LowestBar(Low, 96)] - 10 * TickSize, "StoppedOutLong", "");
				}
			}
			
			if (ShortEntryOrder != null && ShortEntryOrder == execution.Order)
			{
				if (Position.Quantity == 10000)
				{
					ExitShortStop(0, true, 30000, High[HighestBar(High, 96)] + 10 * TickSize, "StoppedOutShort", "");
				}
			}

				
		}
	}
		#region Properties
        #endregion
}

Attached Thumbnails
Dynamic calculation of R/R after an entry signal-example.png  
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.


Reply



futures io > > > > > Dynamic calculation of R/R after an entry signal

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Calculation on trades please..... mdsvtr Options on Futures 6 November 5th, 2014 08:03 AM
Phase Calculation eleven NinjaTrader Programming 7 December 29th, 2012 08:03 PM
How to capture a double value for entry price and int value for entry bar kbaran Elite Automated Trading 3 October 10th, 2012 06:37 PM
BEST BEST Entry Signal dimitri The Elite Circle 11 January 28th, 2011 07:47 AM
Using Limit entry, how to know if entry was execute - Multicharts arjfca EasyLanguage Programming 11 November 24th, 2010 05:33 PM


All times are GMT -4. The time now is 06:28 AM.

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-17 in 0.08 seconds with 20 queries on phoenix via your IP 54.82.81.154