adventures of a newbie - page 8

 
niko:

Hey CB,


I think Tim is on holiday now as I haven't heard from him for a few days. Thus I am continuing with your code, as it will help me trade (as I am trading manually the strategy now, and it means waking up early hours, etc). I amended all the code as you requested, but for some reason it still returns an error (to do with "==" this time, very strange).


Another thing is I noticed the start function was not closed. So I added "}" after first function within the start (), if we do not do that, code generates an error with the subsequent function string fnGenerateSignal() (saying function definition for that is unexpected).


Thank you as always. I look forward to your comments/amdendments!

Nick

Hi Nick.

You've got a whole set of curlies that are unnecessary in the start() block. So you can remove both the first { and the last }.

You're missing a conditional if statement in the fnGenerateSignal() block, so as its written, it will always return "OP_BUY".

Can't see any problem with ==. What is the precise error you're getting?

CB.

 
cloudbreaker:

Hi Nick.

You've got a whole set of curlies that are unnecessary in the start() block. So you can remove both the first { and the last }.

You're missing a conditional if statement in the fnGenerateSignal() block, so as its written, it will always return "OP_BUY".

Can't see any problem with ==. What is the precise error you're getting?

CB.

Hey CB, thank you for coming to the rescue.

I added the conditional if statement you highlighted.

The == error states: "=="-different types in comparison, and it highlights the following line

if ((OrderSymbol() == Symbol()) && (OrderType() == sSignal))


I think the == error is because we are comparing OrderType which is int to sSignal which is string, so they can't be equal. I'l see if i can change it, and post what i did.

 

Hey I changed 'OP_BUY' to 1, OP_SELL to -1, to overcome the incompatible types error (this meant changing fnGenerateSignal as well). It produces no errors when compiled.


However when I run it on strategy tester it still executes multiple buy and sell orders one after another (and it should only have 1 order in 1 direction). Any thoughts?

 

Give this a try and see how you get on.

- Check first your conditional statements in fnGenerateSignal() to make sure all the less thans and greater thans are correct as I had to re-add the first one.

- If it still doesn't work, then start to insert Print() statements so we can see what the various variables are doing at key points.


CB

Files:
 
niko wrote >>

Hey I changed 'OP_BUY' to 1, OP_SELL to -1, to overcome the incompatible types error (this meant changing fnGenerateSignal as well). It produces no errors when compiled.

However when I run it on strategy tester it still executes multiple buy and sell orders one after another (and it should only have 1 order in 1 direction). Any thoughts?

Hey Niko,

Welcome back from Turkey.

How things doing?

Regards

Huckleberry

 

Hi Nick


Sorry, I didn't realize you we back from hols.


Glad you had a great time in Turkey.

Attached is the updated code with notes etc.


The next task is to complie and debug. Then you can start testing. Some more tidying up of the comments in the code wouldn't be a bad idea either.


Regards

Tim
 
TSWilson:

I actually tidied away some of the comments in the version I just posted above. :-)


CB

 
Hey guys, looks like the whole team is back in action! Thank's Tim I'l proceed with your code, and whenever I get a chance I'l carry on with CB's.
 
niko:
Hey guys, looks like the whole team is back in action! Thank's Tim I'l proceed with your code, and whenever I get a chance I'l carry on with CB's.

Can I just ask you to confirm something about your strategy.

If I remember correctly, you'd said before that you wanted to have a single EA which could be dropped on to any pair and would trade just on the pair of the chart it was dropped onto - and it would make all its trading decisions based just upon the pair of the chart it was dropped onto. Thus, you'd just have a single codebase to maintain. Is that still the case?


CB

 
cloudbreaker wrote >>

Can I just ask you to confirm something about your strategy.

If I remember correctly, you'd said before that you wanted to have a single EA which could be dropped on to any pair and would trade just on the pair of the chart it was dropped onto - and it would make all its trading decisions based just upon the pair of the chart it was dropped onto. Thus, you'd just have a single codebase to maintain. Is that still the case?

CB

Hey CB, The ideal is to have a multi-pair EA - which is what Tim and I are trying to build. However, a single-pair EA is also highly desirable as it is teaching me how to code. Your coding styles differ and it is an excellent exercise for me to see how the same/similar idea can be coded differently. Plus, I thought if we finished the single EA first then I'd use that to help me manual trade, but it looks as though both codes will be finished round the same time now

Reason: