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'm new to EasyLanguage, and try to make my first steps in it. My first real attempt to develop my own strategy is this one, which is based on the idea of the Awesome Oscillator indicator and which (if it was working) should scan for a Twin Peaks situation and then buy and sell accordingly.
After spending some time doing modal diagrams and thinking about what the strategy should do, I came up with some EL code. Only - it doesn't seem to do anything. Nothing.
So I'm hoping that someone who's more experienced than me could have a look at my code and tell me where it's going wrong?
Here's the masterpiece
Any ideas? Comments? Critique?
Can you help answer these questions from other members on NexusFi?
welcome to NexusFi. A good way to find out why a strategy is not behaving like you think it does is using the print reserved word. You would simply add print statements within code blocks and when you execute your code you can see the print statements in the EasyLanguage Output log. This will
Another way is to turn parts of the logic into an input and plot the results, as sometimes it's a lot easier to see what is going on (or better not correctly working) when you have it plotted on a chart.
One thing to check is that AO[1] is actually 0 for some bars. Keep in mind that it might be unlikely that the two averages are exactly the same for one bar i.e. if they are different at the tenth decimal place only your condition would not be valid. If that is the problem, an alternative approach could be to check for AO crossing over and under 0 for example.
Apart from that what chart and interval settings did you apply the strategy to, so one could reproduce what you are seeing?
Thanks, I wasn't aware of this print facility, but it sounds like a good tool to probe what's going on in the strategy. I'll have to read more about it and then give it a try.
You mean like temporarily disabling (i.e. via curly brackets) conditional routines and setting a fixed condition instead? Certainly worth a try.
Thanks, I didn't think of that. One fix for that could be to multiply the individual Long and Short Averages by say 1'000'000 and then divide the difference by 1'000'000, i.e. instead
I use
I assume this would then avoid the issue with deltas less than 1, at least up to the 6th decimal place.
Chart settings I tried were line chart, candlestick and candlestick with Momentum, with 15s a 1s intervals. The only study that was open was Awesome Oscillator. The other settings were left at standard for TS 10.
I am afraid there is a typo in my reply, I meant to write "Another way is to turn parts of the logic into an indicator and plot the results [...]".
It depends on what you are actually trying to discover when you say Xing. You can also simply check for one indicator crossing over or under the other using the reserved words "crosses over" and "crosses under".
That should effectively eliminate any problems due to a variable not being 0 in the nth decimal place.
I am afraid there is a typo in my reply, I meant to write "Another way is to turn parts of the logic into an indicator and plot the results [...]".
I see. That's a good idea, however thanks to the help I got so far the basic strategy now seems to work and plots enntry and exit points on my charts.
Quoting
It depends on what you are actually trying to discover when you say Xing. You can also simply check for one indicator crossing over or under the other using the reserved words "crosses over" and "crosses under".
That should effectively eliminate any problems due to a variable not being 0 in the nth decimal place.
I'm sure you're right. I'm still learning the basics and I now realized that for many things there are actually simple ways to do it.
Thank you very much! After I made all the changes you and ABCTG recommend the strategy seems to work now
Well, at least in general terms, but that's a start. Unfortunately it appears the 'detection' of twin peaks isn't very good, as it seems to often mis-interpret the peaks and settles for minimal changes, so something in my code isn't quite right:
// Compute Entry
If (MarketPosition = 0) and (EntriesToday(Date) < MaxEntry) and Time > TimeBegin And Time < TimeEnd Then
Begin
If (Gd = 1) then
Begin
if AO > AO[1] and AO[1] < AO[2] then
Begin
if (LwMkr = 0) or ((LwMkr < 0) and (LwMkr < AO[1])) then LwMkr = AO[1];
if (LwMkr < 0) and (LwMkr > AO[1]) then
Begin
Buy ("AOBuy") NumStocks shares next bar at market;
LwMkr = 0;
End;
End;
if AO > 0 then
Begin
Gd = 2;
LwMkr = 0;
End;
End;
End;
Does anyone have an idea how I could improve the 'twin peak' detection above?
you are welcome. Can you verbalize and show a screenshot of what scenario you are looking to detect exactly when you say twin peak'? This might help others in pointing you in the right direction.
Regards,
ABCTG
BTGUK
Thanks again for your help, ABCTG and SMCJB.
I see. That's a good idea, however thanks to the help I got so far the basic strategy now seems to work and plots enntry and exit points on my charts.
I'm sure you're right. I'm still learning the basics and I now realized that for many things there are actually simple ways to do it.
Thank you very much! After I made all the changes you and ABCTG recommend the strategy seems to work now
Well, at least in general terms, but that's a start. Unfortunately it appears the 'detection' of twin peaks isn't very good, as it seems to often mis-interpret the peaks and settles for minimal changes, so something in my code isn't quite right:
// Compute Entry
If (MarketPosition = 0) and (EntriesToday(Date) < MaxEntry) and Time > TimeBegin And Time < TimeEnd Then
Begin
If (Gd = 1) then
Begin
if AO > AO[1] and AO[1] < AO[2] then
Begin
if (LwMkr = 0) or ((LwMkr < 0) and (LwMkr < AO[1])) then LwMkr = AO[1];
if (LwMkr < 0) and (LwMkr > AO[1]) then
Begin
Buy ("AOBuy") NumStocks shares next bar at market;
LwMkr = 0;
End;
End;
if AO > 0 then
Begin
Gd = 2;
LwMkr = 0;
End;
End;
End;
Does anyone have an idea how I could improve the 'twin peak' detection above?