Hey fellow coding humans,
Im new to this and have stumbled across a problem i need help with.
Im trying to simply tell my system that i dont want it to enter a long position if its under the average (110)
heres and extract from my code:
mo= average(110)
IF not longonmarket and upbox + boxsize crosses over mo or upbox + boxsize > mo THEN
buy 10 share at market
Elsif barindex crosses under mo or barindex < mo or tradeindex < mo then
buy 0 share at market
upbox and downbox are defined params. I have tried everything to try to stop it from placing LONG positions under the average (110) e.g. ELSIF upbox + downbox<mo THEN etc.
it is still buying long positions.
what am i doing wrong?
many thanks lovely people.
Please provide the full code of your strategy as I don’t know what values are stored into your upbox+boxsize variables.
Instead of not entering if under MA(110) why not have a condition added to your other Long entry conditions …
If Condition X AND Condition Y AND Close >= Average(110) Then
Buy 1 Contract at Market
EnfIF
Or have I missed the point?? 🙂
I second Grahal in this one. 😉
Great many thanks guys. That really helped. Ive sorted it now.
Just another question about the mechanics of automated trading if i may?
I have written a multiple moving average crossover strategy for the hourly USD/JPY which returns over 100% a year. If i then apply this to the EUR/GBP it losses money.
Is this because i have been writing / altering the code to suit the backtesting of the USD/JPY? And do i need to get the code working well on all pairs before implementing? Or is this normal that these types of strategy suit some pairs more than others?
many thanks
You asked … is this normal that these types of strategy suit some pairs more than others? … Yes, but usually it’s due to the value of the variables have been optimised for a particular forex pair etc.
You said … which returns over 100% a year … you sure you have the ‘tick mode box’ enabled as this sounds too good to be true?
Make sure you run in Demo for weeks / months before you go Live and maybe lose your hard earned money??