Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I want to implement in my strategy 2 different stop times a day. Lets say for example 11:30 and 17:45 o'clock.
This means: each running trade, no matter of its open time, will quit exactly to the next of the both fixed exit times.
a) Please: I am not searching a starting period like this example from the NT-forum:
if (ToTime(Time[0]) >= 74500 && ToTime(Time[0]) <= 134500)
b) And: this both fix-time-trade-end-conditions must works in timeless charts like Renko, too.
Two fix-single-independent-of-each-other-trade-ending-times. I cant believe, that this is so difficult or complex to realize - but I am failing in its.
What I need is an working example or an working example code.
Thank you for your help!
Best regards,
Renkotrader
Can you help answer these questions from other members on NexusFi?
its a great job - thank you very much, but on my computer it does not works.
a) The '>=' operator cannot be applied to operands of type 'int' and 'System.TimeSpan'. CS0019
b) The '<' operator cannot be applied to operands of type 'System.DateTime' and 'System.TimeSpan'. CS0019
c) The '>=' operator cannot be applied to operands of type 'int' and 'System.TimeSpan'. CS0019
d) The '<' operator cannot be applied to operands of type 'System.DateTime' and 'System.TimeSpan'. CS0019
So I had the idea, to put "closingTime1" (for example) in this convert-construct:
(Convert.ToInt32(closingTime1))
The result is: no compiling-errors, but no trades, too.
So my idea was not the best...
It seems that NinjaTrader handles time comparisons differently from standard C# DateTime comparisons. To address this, i have modified the code to compare DateTime TimeSpan object with Tanother TimeSpan type object. This code should work.
in my tests I can see, that its works for the forst exit time (11:30) - but not for the second one (17:45).
Something does not work or calculate correct, or?
If I take a look at cour code, so the logical structure looks like correct for me...
I will leave it up to you to find the solution. Just use print statements to find what does not work as expected and you should be able to solve this problem. That's what coding is all about after all.
thank you, I compared both versions and the are very different.
Your new one works and that is fine
Two things I have to ask to this solution:
1) It is possible to change the hard coded times to variables, so that I can use its in the parameter list? I tried its the morning in different ways, but no one has worked.
2) I did, what you said about debugging for learning. To work with the Print() is a real good thing. I defined a Print-Line, but there the next problem was finding me. I would love to get the execution close time from the order - not only the start-time. For me it is important in comparing the times from a time chart with a renko chart. In the helping system I dont find another method then "Time[0]". So I thought, I can use its after the line "ExitLong();", but this is not working, too. Is there a special trick for getting the close time?