Enter on CalOnBarClose=True, but Exit Immediately on X Ticks - Traders Hideout | futures io social trading
futures io futures trading


Enter on CalOnBarClose=True, but Exit Immediately on X Ticks
Updated: Views / Replies:1,054 / 22
Created: by albertjay 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
 

Enter on CalOnBarClose=True, but Exit Immediately on X Ticks

  #11 (permalink)
Market Wizard
London UK
 
Futures Experience: Beginner
Platform: CQG
Favorite Futures: Futures
 
xplorer's Avatar
 
Posts: 2,499 since Sep 2015
Thanks: 5,182 given, 3,584 received
Forum Reputation: Legendary


kburks View Post
What platform do you use??

Sent from my SM-G920V using futures.io mobile app

CQG QTrader.

Reply With Quote
 
  #12 (permalink)
Elite Member
Crete, IL/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker/Data: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Favorite Futures: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 171 since Aug 2009
Thanks: 99 given, 47 received


xplorer View Post
CQG QTrader.

interesting. do you like it better than Ninja?
does it allow you do write code? what language?

Reply With Quote
 
  #13 (permalink)
Elite Member
Los Angeles CA
 
Futures Experience: Advanced
Platform: NT
Favorite Futures: Stocks
 
Posts: 8 since Aug 2015
Thanks: 0 given, 3 received


This is pretty much the only thing that I've tried thus far that works. NT should make this a bit easier to do. Hopefully in a future update. All the best, and thanks!


spinnybobo View Post
try this code out
it does not work historically. Historically code would need Add(PeriodType.Tick, 1) added to Initialize()

 
Code
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
    
    [Description("used for testing things")]
    public class sdPlayground : Strategy
    {
        
	 private IOrder entryOrder = null;
	 private IOrder exitOrder = null;
	 private int currentBarOrderFilled = 0;
     
        protected override void Initialize()
        {
            CalculateOnBarClose = true;
			Unmanaged = true;
        }

     
        protected override void OnBarUpdate()
        {
		if (!Historical)
		{
			if (entryOrder == null && Flat)
			{
				entryOrder = SubmitOrder(0, OrderAction.SellShort, OrderType.Market, 1, 0, 0, "", "Entry");
				Print("hitting this");
			}
			if (entryOrder != null)
				Print(entryOrder.ToString());
			if (Long)
				Print("we are long: Positin.Quantity: " + Position.Quantity + "  AvgPrice  " + Position.AvgPrice);
		}
			
        }
		
	protected override void OnMarketData(MarketDataEventArgs e)
	{
		if (e.MarketDataType == MarketDataType.Last)
		{
				
			double multiplier = 1;
			OrderAction orderAction = OrderAction.Sell;
				
			if (Short)
			{
				multiplier = -1;
				orderAction = OrderAction.BuyToCover;
			}
			double threshold = Instrument.MasterInstrument.Round2TickSize(multiplier*(e.Price - Position.AvgPrice))/TickSize;

			Print("threshold: " + threshold + "  Position.AvgPrice: " + Position.AvgPrice + " e.Price: " + e.Price);
				
			if (Long || Short)
				Print("filled on bar : " + currentBarOrderFilled + " CurrentBar: " + CurrentBar);
				
			if ((Long || Short)&& currentBarOrderFilled == CurrentBar)
			{
				if (threshold >= 2)
					exitOrder = SubmitOrder(0, orderAction, OrderType.Market, 1, 0, 0, "", "Exit 12 Ticks");
			}
				
		 }
		}
		protected override void OnOrderUpdate(IOrder order)
		{
			if (entryOrder != null && entryOrder == order)
			{
				Print(entryOrder.ToString());
				if (order.OrderState == OrderState.Filled)
				{
					currentBarOrderFilled = CurrentBar;
					Print("Filled on bar number: " + currentBarOrderFilled);
					entryOrder = null;
				}
				if (order.OrderState == OrderState.Cancelled && order.Filled == 0)
					entryOrder = null;
			}
			if (exitOrder != null && exitOrder == order)
			{
				if (order.OrderState == OrderState.Filled)
					exitOrder = null;
				if (order.OrderState == OrderState.Cancelled && order.Filled == 0)
					exitOrder = null;
			}
		}
		private bool Long { get { return (Position.MarketPosition == MarketPosition.Long);}}
		private bool Short { get { return (Position.MarketPosition == MarketPosition.Short);}}
		private bool Flat { get { return (Position.MarketPosition == MarketPosition.Flat);}}

        #region Properties
 
        #endregion
    }
}
what I put in OnBarUpdate() was just to get an order
you would want to deal with OnMarketData and if you use IOrders, then OnOrderUpdate to set the CurrentBar to the bar you got filled on. I also included "helper" methods for Long, Short as well as Flat


Reply With Quote
 
  #14 (permalink)
Elite Member
Crete, IL/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker/Data: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Favorite Futures: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 171 since Aug 2009
Thanks: 99 given, 47 received


albertjay View Post
This is pretty much the only thing that I've tried thus far that works. NT should make this a bit easier to do. Hopefully in a future update. All the best, and thanks!

cool glad I could help. let me know how it goes

Reply With Quote
 
  #15 (permalink)
Market Wizard
London UK
 
Futures Experience: Beginner
Platform: CQG
Favorite Futures: Futures
 
xplorer's Avatar
 
Posts: 2,499 since Sep 2015
Thanks: 5,182 given, 3,584 received
Forum Reputation: Legendary


spinnybobo View Post
interesting. do you like it better than Ninja?
does it allow you do write code? what language?

Yes, my experience is that CQG has a better responsiveness than NT. You can code indicators and the like, although I don't think we can talk about CQG having a programming language per se.


Check the 2 posts from this link out - my own one and Okina's (R.I.P.)

Reply With Quote
 
  #16 (permalink)
Elite Member
Crete, IL/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker/Data: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Favorite Futures: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 171 since Aug 2009
Thanks: 99 given, 47 received


xplorer View Post
Yes, my experience is that CQG has a better responsiveness than NT. You can code indicators and the like, although I don't think we can talk about CQG having a programming language per se.


Check the 2 posts from this link out - my own one and Okina's (R.I.P.)

where are the links? wow just read about Okina. so sad. I didn't know him but so young. :-( many prayers for him and his wife and family.

Reply With Quote
The following user says Thank You to spinnybobo for this post:
 
  #17 (permalink)
Market Wizard
London UK
 
Futures Experience: Beginner
Platform: CQG
Favorite Futures: Futures
 
xplorer's Avatar
 
Posts: 2,499 since Sep 2015
Thanks: 5,182 given, 3,584 received
Forum Reputation: Legendary


spinnybobo View Post
where are the links? wow just read about Okina. so sad. I didn't know him but so young. :-( many prayers for him and his wife and family.

Sorry here's the URL

https://futures.io/elite-trading-journals/38439-scalper-s-journey-1088.html#post583691

Reply With Quote
 
  #18 (permalink)
Elite Member
Crete, IL/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker/Data: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Favorite Futures: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 171 since Aug 2009
Thanks: 99 given, 47 received



oh ok. yeah CQG looks great. but you can't develop in it?

Reply With Quote
 
  #19 (permalink)
Market Wizard
London UK
 
Futures Experience: Beginner
Platform: CQG
Favorite Futures: Futures
 
xplorer's Avatar
 
Posts: 2,499 since Sep 2015
Thanks: 5,182 given, 3,584 received
Forum Reputation: Legendary


spinnybobo View Post
oh ok. yeah CQG looks great. but you can't develop in it?

You can use APIs if you have specific needs CQG APIs | CQG, Inc.

CQG has a built-in facility to create indicators. I like its relative simplicity of language to do that.

However documentation is quite poor.

Reply With Quote
 
  #20 (permalink)
Elite Member
Crete, IL/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker/Data: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Favorite Futures: ES, CL, EUR/USD, TF
 
spinnybobo's Avatar
 
Posts: 171 since Aug 2009
Thanks: 99 given, 47 received



xplorer View Post
You can use APIs if you have specific needs CQG APIs | CQG, Inc.

CQG has a built-in facility to create indicators. I like its relative simplicity of language to do that.

However documentation is quite poor.

cool I will have to look into it sometime

Reply With Quote

Reply



futures io > > > Enter on CalOnBarClose=True, but Exit Immediately on X Ticks

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

July Journal Challenge w/$1100 in prizes from TopstepTrader

July

John @ No BS Day Trading (TBA)

Elite only

An Afternoon with FIO member Softsoap (being rescheduled)

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Enter and Exit market using different chart resolution vhanded MultiCharts 0 May 1st, 2015 05:37 AM
Enter and exit positions within the same bar mandelmus EasyLanguage Programming 2 March 12th, 2015 09:41 AM
How to enter long buy on a bar immediately before it closes. bmtfken EasyLanguage Programming 19 July 27th, 2014 07:01 PM
Best Price Enter/Exit? NJAMC Elite Automated NinjaTrader Trading 3 July 8th, 2011 05:00 PM
Viper has a "order entry strategy" that you can use to enter and exit. rcr3908 NinjaTrader 2 April 30th, 2011 05:20 PM


All times are GMT -4. The time now is 06:26 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-06-24 in 0.14 seconds with 39 queries on phoenix via your IP 107.22.17.220