Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Manual Trade Monitoring Strategy/"Tool" :)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Manual Trade Monitoring Strategy/"Tool" :)

    Hi,

    I was wondering if it possible to code a strategy that only does money management. I want to be able to place all my trades manually with the strategy running. The strategy will not manage trades at all. It will just monitor profit and loss for the day.

    For example: If I turn the strategy on, it monitors my trading activity. If I have a daily loss of $200 THEN it restricts me from placing any more trades manually. To be real fancy it could display: "Max Daily Loss Amount Reached: No more trading Allowed". It would not let allow me to place any more trades. Now I know I could just turn the strategy off & keep trading but this would be a good way to restrict my trading.

    The other thing that would be handy is if it could send out a message for max daily profit too. For example say I reach $1000 for the day, message could display "Max Profit Reached: Would you like to End Manual Trading for the Day? with Yes/No option? Another friendly reminder to keep from overtrading. The only inputs would be max loss & max profit and possibly max # of trades as another limiting factor.

    I think this would be a great strategy/"tool" for all traders to use. The idea is to use an "automated strategy" really as a management "tool" Probably not possible but thought I would ask for suggestions on how to code if it is possible. I have mild coding abilities, just need some guidance or if there are some amazing coders out there who would like to find a way to make this possible for everyone since it just a simple money management tool, that would be great too. Thanks for any response!!

    -Tom

    #2
    Almost anything is possible... depending on your coding skillz...

    Indicator Warehouse has a trade manager. I've never watched a video or know what it does in totality. So it might not do what you wish it to do, but it might be close. (Trade Manager type stuff).


    Comment


      #3
      Hello tnellman,

      Thanks for your post.

      I am not aware of any method that would accomplish your goal to prevent you from further trading through the platform.

      You can certainly run a strategy that could monitor your account and take some action such as producing a message on the screen, sending an e-mail, making a sound, coloring the chart, sending an alert. This can be done through Ninjascript as well as through the strategy wizard. Note that this would apply only to the chart/instrument that you have the strategy enabled.

      For information on running strategies please visit the following link: http://www.ninjatrader.com/support/h...strategies.htm

      If you would like to take on learning NinjaScript, we have a fully documented help guide which will help you get started with Ninja Script. You will find language references to all of the methods and functions you will be using. You will also see a tutorial section which will help you create your first strategy and get you started with some of these concepts.
      A link to our Help Guide can be found below: http://www.ninjatrader.com/support/h...?tutorials.htm

      I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript: http://www.ninjatrader.com/support/h..._resources.htm

      You will find Reference Samples online as well as some Tips and Tricks for both indicators and strategies:
      Click here to see our NinjaScript Reference Samples: http://www.ninjatrader.com/support/f...splay.php?f=30
      Click here to see our NinjaScript Tips: http://www.ninjatrader.com/support/f...ead.php?t=3229

      These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

      There is a also a growing library of user submitted custom indicators (100+) and strategies that can be downloaded from our support form. Please look in the NinjaScript File Sharing section of our support forum as you may find what you are looking for there: http://www.ninjatrader.com/support/f...splay.php?f=37
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Another Idea

        Hi Paul,

        Thanks for the reply! So I went to code it and I came up with an idea. I don't know how strategies interact with manual trades(which is where I get stuck) but if a manual trade doesn't disable the strategy I thought this might work:

        I would have the strategy running.... My variables are MaxDailyLoss, GrossProfit, & MaxDailyTrades

        I would sync the account so that the strategy always reads what the the open positions and what the MaxDailyLoss, GrossProfit, & MaxDailyTrades for the day is.

        If I reach one of those variables it would send a text alert saying that I am "done trading for the day" but more importantly it triggers a continuous loop that constantly is trying to flatten or exit all positions; meaning even if there are no positions open it is trying to flatten them. Therefore if I try to place a manual trade it will immediately flatten it. This would cost me a commission if I accidentally placed an additional trade & it flattened it but at least that would remind me not to do it again. Does this sound possible? I guess it all hinges on how strategies can interact with manually placed trades. Thanks!

        -Tom

        Comment


          #5
          Code Sample

          Here is my code. I'm not a programmer but hopefully I'm going the right direction. Thanks:

          Code:
          //This namespace holds Strategies in this folder and is required. Do not change it. 
          namespace NinjaTrader.NinjaScript.Strategies
          {
          	public class RiskManager : Strategy
          	{
          		protected override void OnStateChange()
          		{
          			if (State == State.SetDefaults)
          			{
          				Description							= @"Helps with risk management & account management.";
          				Name								= "RiskManager";
          				Calculate							= Calculate.OnEachTick;
          				EntriesPerDirection					= 1;
          				EntryHandling						= EntryHandling.AllEntries;
          				IsExitOnSessionCloseStrategy		= true;
          				ExitOnSessionCloseSeconds			= 30;
          				IsFillLimitOnTouch					= false;
          				MaximumBarsLookBack					= MaximumBarsLookBack.TwoHundredFiftySix;
          				OrderFillResolution					= OrderFillResolution.Standard;
          				Slippage							= 0;
          				StartBehavior						= StartBehavior.WaitUntilFlatSynchronizeAccount;
          				TimeInForce							= TimeInForce.Gtc;
          				TraceOrders							= true;
          				RealtimeErrorHandling				= RealtimeErrorHandling.StopCancelClose;
          				StopTargetHandling					= StopTargetHandling.PerEntryExecution;
          				BarsRequiredToTrade					= 1;
          				DailyLossLimit						= 200;
          				GrossDailyProfit					= 1000;
          				MaxDailyTrades 						= 6;
          			}
          			else if (State == State.Configure)
          			{
          				IsAdoptAccountPositionAware = true;
          				StartBehavior = StartBehavior.AdoptAccountPosition;
          			}
          		}
          
          		protected override void OnPositionUpdate(Cbi.Position position, double averagePrice, 
          			int quantity, Cbi.MarketPosition marketPosition)
          		{
          			
          		}
          
          		protected override void OnBarUpdate()
          		{
          			
          			if(SystemPerformance.AllTrades.TradesPerformance.GrossLoss > DailyLossLimit)
          			{
          				if (Position.MarketPosition == MarketPosition.Long)
          
                				ExitLong();
          
             				else if (Position.MarketPosition == MarketPosition.Short)
          
                				ExitShort();
          				
          				Alert("myAlert", Priority.High, "Daily Loss Limit Reached! Trading No Longer Permitted!", NinjaTrader.Core.Globals.InstallDir+@"\sounds\Alert1.wav", 10, Brushes.Black, Brushes.Yellow); 
          				
          			}
          			
          			if(SystemPerformance.AllTrades.TradesPerformance.GrossProfit > GrossDailyProfit)
          			{
          				if (Position.MarketPosition == MarketPosition.Long)
          
                				ExitLong();
          
             				else if (Position.MarketPosition == MarketPosition.Short)
          
                				ExitShort();
          				
          				Alert("myAlert", Priority.High, "Daily Profit Reached! DO NOT OVERTRADE!", NinjaTrader.Core.Globals.InstallDir+@"\sounds\Alert1.wav", 10, Brushes.Black, Brushes.Green);
          				
          			}
          			
          			if(SystemPerformance.AllTrades.TradesPerformance.TradesCount > MaxDailyTrades)
          			{
          				if (Position.MarketPosition == MarketPosition.Long)
          
                				ExitLong();
          
             				else if (Position.MarketPosition == MarketPosition.Short)
          
                				ExitShort();
          				
          				Alert("myAlert", Priority.High, "Max Daily Trades Reached! DO NOT OVERTRADE!", NinjaTrader.Core.Globals.InstallDir+@"\sounds\Alert1.wav", 10, Brushes.Black, Brushes.Yellow);
          				
          			}
          		}
          
          		#region Properties
          		[Range(1, double.MaxValue)]
          		[NinjaScriptProperty]
          		[Display(Name="DailyLossLimit", Order=1, GroupName="Parameters")]
          		public double DailyLossLimit
          		{ get; set; }
          
          		[Range(1, double.MaxValue)]
          		[NinjaScriptProperty]
          		[Display(Name="GrossDailyProfit", Order=2, GroupName="Parameters")]
          		public double GrossDailyProfit
          		{ get; set; }
          		
          		
          		[Range(1, double.MaxValue)]
          		[NinjaScriptProperty]
          		[Display(Name="MaxDailyTrades", Order=2, GroupName="Parameters")]
          		public double MaxDailyTrades
          		{ get; set; }
          		#endregion
          
          	}

          Comment


            #6
            Hello Tom,

            Thanks for your posts.

            I don't think you will be able to accomplish your goals here. The code will only work on a per instrument basis and only on start-up would it adopt the positions. Sorry, I have no other ideas to add here. Perhaps others in the community can provide further suggestions.
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ETFVoyageur, Yesterday, 07:05 PM
            4 responses
            30 views
            0 likes
            Last Post ETFVoyageur  
            Started by JGriff5646, Yesterday, 10:02 PM
            2 responses
            21 views
            0 likes
            Last Post JGriff5646  
            Started by DawnTreader, Today, 05:58 PM
            0 responses
            5 views
            0 likes
            Last Post DawnTreader  
            Started by ntram, Today, 05:39 PM
            0 responses
            5 views
            0 likes
            Last Post ntram
            by ntram
             
            Started by giulyko00, Today, 11:49 AM
            2 responses
            12 views
            0 likes
            Last Post giulyko00  
            Working...
            X