Plotting Orders and Trade infos on chart - NinjaTrader Programming | futures io social day trading
futures io futures trading


Plotting Orders and Trade infos on chart
Updated: Views / Replies:172 / 1
Created: by chrisbh 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
 

Plotting Orders and Trade infos on chart

  #1 (permalink)
Trading Apprentice
Manama
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Emini S&P
 
chrisbh's Avatar
 
Posts: 5 since Jul 2014
Thanks: 1 given, 0 received

Plotting Orders and Trade infos on chart

Hello everyone,

You will find part of my strategy here below.
The idea is to have a visual representation of the bracket orders with Stop and Target (see attached pic) plus additional infos when the trade is closed.

I would like to add on the chart the value in ticks of the Stop or Target hit by price and see if there were any slippage when Stop or Target was hit.

 
Code
namespace NinjaTrader.Strategy
{
    [Description("Momentum Pimping")]
    public class AAA : Strategy
    {
        #region Variables
        private int contract = 1;        
        private int     barNumberOfOrder     = 0;
        private int        lineLength            = 0;  
        private IOrder entryOrder = null;        
          #endregion

        protected override void Initialize()
        {
               TimeInForce = Cbi.TimeInForce.Day;    
            CalculateOnBarClose = true;    
        }
        protected override void OnBarUpdate()
        {                
            //LONG ENTRY CONDITIONS
            if (Position.MarketPosition == MarketPosition.Flat
                && Close[0]<Close[1]
                && Close[1]<Close[2])
            {
                barNumberOfOrder = CurrentBar;
                entryOrder = EnterLongLimit(CONTRACT, Close[0], "");
            }
            //SHORT ENTRY CONDITIONS
            if (Position.MarketPosition == MarketPosition.Flat
                && Close[0]>Close[1]
                && Close[1]>Close[2])
            {
                barNumberOfOrder = CurrentBar;
                entryOrder = EnterShortLimit(CONTRACT, Close[0], "");                
            }        
        }
        protected override void OnExecution(IExecution execution)
        {
            if(execution.Name == "Stop loss")             PlaySound(@"C:\Program Files (x86)\NinjaTrader 7\sounds\StopFilled.wav");    
            else if(execution.Name == "Profit target")     PlaySound(@"C:\Program Files (x86)\NinjaTrader 7\sounds\TargetFilled.wav");            
           
            int Stop             =   10;
            int Target            =   20;
        
            if (entryOrder != null && entryOrder == execution.Order)
            {    
                SetStopLoss(CalculationMode.Ticks, Stop);
                SetProfitTarget(CalculationMode.Ticks, Target);    
            }
              
            lineLength = Math.Max(CurrentBar - barNumberOfOrder, 3);
            if (Position.MarketPosition == MarketPosition.Long)
            {                    
                PlaySound(@"C:\Program Files (x86)\NinjaTrader 7\sounds\Alert2.wav");
                DrawLine("Target", false, lineLength, Position.AvgPrice + (Target) * TickSize, -8*lineLength, Position.AvgPrice + (Target) * TickSize, Color.Lime, DashStyle.Solid, 2);
                DrawLine("Stop", false, lineLength, Position.AvgPrice - (Stop) * TickSize,-8*lineLength, Position.AvgPrice - (Stop) * TickSize, Color.Red, DashStyle.Solid, 2);
                DrawLine("Entry", false, lineLength, Position.AvgPrice, -8*lineLength, Position.AvgPrice, Color.Tan, DashStyle.Solid, 2);
                
                DrawText("TargetValue","Target: "+Convert.ToString(Target)+" Ticks" , 0, Low[0]-12*TickSize, Color.Yellow);
                DrawText("StopValue","Stop: "+Convert.ToString(Stop)+" Ticks" , 0, Low[0]-10*TickSize, Color.Yellow);
            }
            
            else if (Position.MarketPosition == MarketPosition.Short)
            {                    
                PlaySound(@"C:\Program Files (x86)\NinjaTrader 7\sounds\Alert2.wav");
                DrawLine("Target", false, lineLength, Position.AvgPrice - (Target) * TickSize, -8*lineLength, Position.AvgPrice - (Target) * TickSize, Color.Lime, DashStyle.Solid, 2);
                DrawLine("Stop", false, lineLength, Position.AvgPrice + (Stop) * TickSize, -8*lineLength, Position.AvgPrice + (Stop) * TickSize, Color.Red, DashStyle.Solid, 2);
                DrawLine("Entry", false, lineLength, Position.AvgPrice, -8*lineLength, Position.AvgPrice, Color.Tan, DashStyle.Solid, 2);
                
                DrawText("TargetValue", "Target:"+Convert.ToString(Target)+" Ticks" , 0, High[0]+12*TickSize, Color.Yellow);
                DrawText("StopValue","Stop:"+Convert.ToString(Stop)+" Ticks" , 0, High[0]+10*TickSize, Color.Yellow);
            }
            if (Position.MarketPosition == MarketPosition.Flat)
            {                
                RemoveDrawObject("Stop");
                RemoveDrawObject("Target");
                RemoveDrawObject("Entry");
                RemoveDrawObject("TargetValue");
                RemoveDrawObject("StopValue");
            }    
        }
        #region Properties    
        [Description("")]
        [GridCategory("3.Parameters")]
        public int CONTRACT
        {
            get { return contract; }
            set { contract = Math.Max(1, value); }
        }
        #endregion
    }
}
Additionally i would like to increase the font of the draw text....Dont know how !

Any recommendations to help me improve this part of the code would be more than welcome

Happy trading

Chris

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

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 > > > > > Plotting Orders and Trade infos on chart

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
NT 8 indicator for plotting bid/ask spread on chart? FBJS NinjaTrader 2 May 15th, 2016 01:43 AM
plotting trade history to chart cubcub NinjaTrader 0 July 14th, 2014 09:44 PM
NT Chart not plotting time periods when there is no volume happyfatguy NinjaTrader 10 May 26th, 2014 10:44 AM
Tag Orders on Chart aventeren ThinkOrSwim 0 April 5th, 2013 03:37 PM
One Trade Window used for Chart and Trade Dom loonietrader Sierra Chart 5 September 10th, 2012 09:59 PM


All times are GMT -4. The time now is 07:36 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-11 in 0.08 seconds with 20 queries on phoenix via your IP 54.226.132.197