NexusFi: Find Your Edge


Home Menu

 





Strategy: two fix different stop times a day


Discussion in NinjaTrader

Updated
    1. trending_up 1,061 views
    2. thumb_up 8 thanks given
    3. group 3 followers
    1. forum 16 posts
    2. attach_file 9 attachments




 
Search this Thread

Strategy: two fix different stop times a day

  #11 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,527 since Oct 2009
Thanks Given: 4,176
Thanks Received: 6,020

I modified the script so that it can accept various time inputs as UI properties but i have not tested it. I am sure it works but we never know :-)

Attached Files
Elite Membership required to download: crossOverWithExitOnTime.cs
Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Quantum physics & Trading dynamics
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
use extra computer for optimisation
NinjaTrader
can i use extra computer for optimising
Traders Hideout
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #12 (permalink)
 
Renkotrader's Avatar
 Renkotrader 
Frankfurt, Hessen, Germany
 
Experience: Advanced
Platform: NinjaTrader 8
Broker: APEX & NinjaTrader Brokerage
Trading: 6E, 6J, CL, ES, FDAX, FGBL, GC, HG, NQ, RTY, SI, YM
Posts: 547 since May 2012
Thanks Given: 1,419
Thanks Received: 227

Thank you very much, trendisyourfried!

Its looks like its works well now.

I will test its tomorrow and if I am having questions to this, I will write you here again!



Best regards and a great evening,
Renkotrader

Started this thread Reply With Quote
Thanked by:
  #13 (permalink)
 
Renkotrader's Avatar
 Renkotrader 
Frankfurt, Hessen, Germany
 
Experience: Advanced
Platform: NinjaTrader 8
Broker: APEX & NinjaTrader Brokerage
Trading: 6E, 6J, CL, ES, FDAX, FGBL, GC, HG, NQ, RTY, SI, YM
Posts: 547 since May 2012
Thanks Given: 1,419
Thanks Received: 227


Hi trendisyourfriend,

sorry, but the code doesnt work like it should be.

Here we are trading with the MA cross as example.
That means, that the trade is starting with a crossover and it is ending with the crossover in the other direction.

The time filter should take the trade out, if the exit crossover is still in the future.

But the code is doing that right now:

a) the exit time is canceling the second cross signal, if this valid exit signal is coming earlier. That is not allowed. So all trades ends only at this fix exit signal (that is coming later).

b) all the trades after the second fix end time does run only one period of a candle (so in a 5 minutes chart the trade is closing after 5 minutes).

The last I tried to change with a third exit time ("end of trading day"), but this does not work.

Best regards,
Renkotrader

Attached Files
Elite Membership required to download: crossOverWithExitOnTime.cs
Started this thread Reply With Quote
  #14 (permalink)
 Teebone21 
houston texas
 
Experience: Intermediate
Platform: Thinkorswim
Trading: Emini
Posts: 10 since Apr 2019
Thanks Given: 7
Thanks Received: 4

For NT8 you need to Learn the grouping feature. You can use 2 time intervals by grouping the conditions separately

Reply With Quote
Thanked by:
  #15 (permalink)
 
Renkotrader's Avatar
 Renkotrader 
Frankfurt, Hessen, Germany
 
Experience: Advanced
Platform: NinjaTrader 8
Broker: APEX & NinjaTrader Brokerage
Trading: 6E, 6J, CL, ES, FDAX, FGBL, GC, HG, NQ, RTY, SI, YM
Posts: 547 since May 2012
Thanks Given: 1,419
Thanks Received: 227

Hi Teebone21,

what you are meaning with "grouping feature": It is using Groups in the Strategy Builder and then unlocking the code? Or do you mean to change the code structure in NinjaScript manually?

Best regards,
Renkotrader

Started this thread Reply With Quote
  #16 (permalink)
 Teebone21 
houston texas
 
Experience: Intermediate
Platform: Thinkorswim
Trading: Emini
Posts: 10 since Apr 2019
Thanks Given: 7
Thanks Received: 4


Renkotrader View Post
Hi Teebone21,

what you are meaning with "grouping feature": It is using Groups in the Strategy Builder and then unlocking the code? Or do you mean to change the code structure in NinjaScript manually?

Best regards,
Renkotrader

Yes in strategy builder create a group for execution conditions on different sets that include time intervals

Reply With Quote
Thanked by:
  #17 (permalink)
 
Renkotrader's Avatar
 Renkotrader 
Frankfurt, Hessen, Germany
 
Experience: Advanced
Platform: NinjaTrader 8
Broker: APEX & NinjaTrader Brokerage
Trading: 6E, 6J, CL, ES, FDAX, FGBL, GC, HG, NQ, RTY, SI, YM
Posts: 547 since May 2012
Thanks Given: 1,419
Thanks Received: 227

Hello Teebone21,

thank you for this information. I testet its a while ago, but I did something wrong, because its did not work. Before I test its again, I tried a "last test" this morning right now. You see the names in German language.

 
Code
// Fixe Exitzeiten
maxZeitEurexVormittagBeginn = DateTime.Parse("11:50", System.Globalization.CultureInfo.InvariantCulture);
maxZeitEurexVormittagEnde = DateTime.Parse("11:55", System.Globalization.CultureInfo.InvariantCulture);
maxZeitNymexOpenBeginn = DateTime.Parse("14:20", System.Globalization.CultureInfo.InvariantCulture);
maxZeitNymexOpenEnde = DateTime.Parse("14:25", System.Globalization.CultureInfo.InvariantCulture);
maxZeitNyseOpenBeginn = DateTime.Parse("15:20", System.Globalization.CultureInfo.InvariantCulture);
maxZeitNyseOpenEnde = DateTime.Parse("15:25", System.Globalization.CultureInfo.InvariantCulture);
maxZeitEurexCloseBeginn = DateTime.Parse("17:20", System.Globalization.CultureInfo.InvariantCulture);
maxZeitEurexCloseEnde = DateTime.Parse("17:25", System.Globalization.CultureInfo.InvariantCulture);
 
Code
#region ExitLong
	if (				
	(Close[0] <= amaSuperTrendU111.StopLine[0])
	|| ((Times[0][0].TimeOfDay >= maxZeitEurexVormittagBeginn.TimeOfDay) && (Times[0][0].TimeOfDay <= maxZeitEurexVormittagEnde.TimeOfDay))
	|| ((Times[0][0].TimeOfDay >= maxZeitNymexOpenBeginn.TimeOfDay) && (Times[0][0].TimeOfDay <= maxZeitNymexOpenEnde.TimeOfDay))
	|| ((Times[0][0].TimeOfDay >= maxZeitNyseOpenBeginn.TimeOfDay) && (Times[0][0].TimeOfDay <= maxZeitNyseOpenEnde.TimeOfDay))
	|| ((Times[0][0].TimeOfDay >= maxZeitEurexCloseBeginn.TimeOfDay) && (Times[0][0].TimeOfDay <= maxZeitEurexCloseEnde.TimeOfDay)))		
	{
		ExitLong(Convert.ToInt32(kontrakteLong), @"ExitLong", @"EntryLong");
	}
#endregion

So I put the stop times in the stop-part of my strategy. Now it works.

Thank you for your help, too.

Best regards,
Renkotrader

Started this thread Reply With Quote




Last Updated on September 9, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts