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've altered the code from BigMike's video to experiment with Optimizer.
Changed to not be involved in the optimization:
private int target1 = 1000;
private int target2 = 1000;
private int target3 = 1000;
private int stop = 1000;
Changed to create a simple go long or go short strategy (using range bars):
ManageOrders();
if (Position.MarketPosition != MarketPosition.Flat) return;
if ( Close[0]>Close[1] && Median[0]>Median[1])
GoLong();
else
if (Close[0]<Close[1] && Median[0]<Median[1])
GoShort();
At 8:27 I was looking for a short trade to be taken. The close was lower and the median was lower.
A tad before 10:00 I was looking for a long trade to be taken and it was not. Etc. Etc.
Can you help answer these questions from other members on NexusFi?
I've spent some time on my code. I have changed it as can be seen below.
If anyone has any comments that's fine. I'm not really sure if what I've done is correct, or
just an improvement. Thanks.
Note the added ( ) around your entry logic and your position logic. Using print statements helps, and I'm a big fan of using bools so I can print out all the true/false conditions to see where I messed up.
I was wondering if there was anything that looked terribly off. My new code (shown above already) really
SEEMED to do what I wanted.
zeller4, the trouble originally was that it did not do anything besides take a long or short. The else
statement was not seen apparently, which I thought was very odd.
MXASJ, why are the extra ( ) helpful in your opinion?
I have never " I'm a big fan of using bools so I can print out all the true/false conditions" done this.
But it is an idea.
Thanks to you both. I've got to go for today. Sorry if I missed a point either of you tried to make to me.
P.S. I have a question regarding optimization. It was mentioned in the video, but maybe there is a more
active thread you both might know about. (Don't wan't to start a tread for nothing.)
in OnBarUpdate will stop any processing of historical data, for example.
While you are coding something that is giving you issues, one way to check your logic is to print stuff out to the output window to see whats going on in your logic.
If you trade logic is, for example, buy if its going up. You can add a print statement. Instead of:
if (Close[0]>Close[1]) EnterLong();
You can do
if (Close[0]>Close[1]) { EnterLong(); Print(DateTime.Now + " Long signal generated"); }
If you previously declared a variable bool goingUp = false;
You could add:
if (Close[0]>Close[1]) { EnterLong(); goingUp = true; Print(DateTime.Now + " Are we GoingUp= " + goingUp); }
So you can check your logic conditions.
In a situation where you have multiple true/false conditions for enter/exit/do nothing, there is some creative stuff you can do.
But again I'm crap at this so have a play and see what works for you. Happy trading!
It looks, at the moment anyway, that what I have works. I'm hoping to do more over the
weekend. You don't have to comment of course, but one thing I heard a while back is to
just backtest your system without stoploss orders, to see what the natural risk was. Maybe
natural risk isn't the exactly phrasing??
So after that the plan would be to add a stoploss, and
then a breakeven stop. The video has all this already, I just have to make it work in my strategy.
I think I may need a BarsSinceExit in there somewhere as well.
( It'd be nice if all that stuff we read about 'simple is best' actually worked for a change.)
Maybe day after tomorrow I'll have to ask a couple questions in a new thread on optimization.
So, thanks, and I'm all set for now unless you really feel it's important to reply.