 Need some help with my Awesome Oscillator strategy Need some help with my Awesome Oscillator strategy
 Updated: November 12th, 2018 (09:44 AM) Views / Replies: 697 / 7 Created: November 8th, 2018 (04:14 PM) by BTGUK Attachments: 0

 Welcome to futures io.

# Need some help with my Awesome Oscillator strategy

London, United Kingdom

Posts: 3 since Aug 2018

Need some help with my Awesome Oscillator strategy

Hi All,

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 Code
 ```Inputs: AOShortPeriod(5), AOLongPeriod(34), NumStocks(100), TimeBegin(930), TimeEnd(1145), ExTime(1245), MaxEntry(10); Variables: AOLong(0), AOShort(0), AO(0), LwMkr(0), HiMkr(0), Gd(0), Bool Dwnwrd(false), Bool Upwrd(false), Bool Xdwn(false), Bool Xup(false); // Calculate AO AOLong = Average((High + Low)/2,AOLongPeriod); AOShort = Average((High + Low)/2,AOShortPeriod); AO = AOShort - AOLong; // Detect direction Dwnwrd = AO < 0 and AO < AO and AO < AO; Upwrd = AO > 0 and AO > AO and AO > AO; // Detect Xing Xdwn = (AO < 0) and (AO = 0); Xup = (AO > 0) and (AO = 0); // Compute Running Condition If Dwnwrd and Xdwn then Gd = 1; If Upwrd and Xup then Gd = 2; // 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 and AO < AO then Begin if (LwMkr = 0) or ((LwMkr < 0) and (LwMkr < AO)) then LwMkr = AO; if (LwMkr < 0) and (LwMkr > AO) 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; // Compute Exits If (MarketPosition = 1) and Time > TimeBegin And Time < TimeEnd Then Begin If (Gd = 2) then Begin if AO < AO and AO > AO then Begin if (HiMkr = 0) or ((HiMkr > 0) and (HiMkr > AO)) then HiMkr = AO; if (HiMkr > 0) and (HiMkr < AO) then Begin Sell ("AOSale") next bar at market; HiMkr = 0; End; End; if AO < 0 then Begin Gd = 1; HiMkr = 0; End; End; End; If (MarketPosition = 1) and Time > ExTime Then Begin Sell ("AOExit") next bar at market; End;```

 November 8th, 2018, 04:14 PM Quick Summary Quick Summary Post Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 November 9th, 2018, 03:21 AM Vendor: www.abctradinggroup.com  Hamburg Germany   Trading Experience: Advanced Platform: Multicharts, Tradestation Broker/Data: DTN IQ Favorite Futures: ES   Posts: 2,163 since Apr 2013 Thanks: 384 given, 1,396 received BTGUK, welcome to futures.io. 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 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? Regards, ABCTG
 The following user says Thank You to ABCTG for this post:

London, United Kingdom

Posts: 3 since Aug 2018

Hi ABCTG,

 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.

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.

Quoting
 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.

You mean like temporarily disabling (i.e. via curly brackets) conditional routines and setting a fixed condition instead? Certainly worth a try.

Quoting
 One thing to check is that AO 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.

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

Code
 ```// Calculate AO AOLong = Average((High + Low)/2,AOLongPeriod); AOShort = Average((High + Low)/2,AOShortPeriod); AO = AOShort - AOLong;```
I use

Code
 ```// Calculate AO AOLong = (Average((High + Low)/2,AOLongPeriod)) * 1000000); AOShort = (Average((High + Low)/2,AOShortPeriod)) * 1000000); AO = (AOShort - AOLong) / 1000000;```
I assume this would then avoid the issue with deltas less than 1, at least up to the 6th decimal place.

Quoting
 Apart from that what chart and interval settings did you apply the strategy to, so one could reproduce what you are seeing?

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.

Thanks a lot for your help!

 November 9th, 2018, 06:10 AM Vendor: www.abctradinggroup.com  Hamburg Germany   Trading Experience: Advanced Platform: Multicharts, Tradestation Broker/Data: DTN IQ Favorite Futures: ES   Posts: 2,163 since Apr 2013 Thanks: 384 given, 1,396 received BTGUK, 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. Regards, ABCTG
 The following user says Thank You to ABCTG for this post:

Legendary Market Wizard
Houston, TX

Favorite Futures: Energy

Posts: 3,210 since Dec 2013

Code
 ```// Calculate AO AOLong = Average((High + Low)/2,AOLongPeriod); AOShort = Average((High + Low)/2,AOShortPeriod); AO = AOShort - AOLong;```
I use

Code
 ```// Calculate AO AOLong = (Average((High + Low)/2,AOLongPeriod)) * 1000000); AOShort = (Average((High + Low)/2,AOShortPeriod)) * 1000000); AO = (AOShort - AOLong) / 1000000;```
I assume this would then avoid the issue with deltas less than 1, at least up to the 6th decimal place.

Not really. Try...

Code
 ``` AOLong = Average((High + Low)/2,AOLongPeriod); AOShort = Average((High + Low)/2,AOShortPeriod); AO = Round(AOShort - AOLong, 3);```
Or as @ABCTG suggested instead of

Code
 ```// Detect Xing Xdwn = (AO < 0) and (AO = 0); Xup = (AO > 0) and (AO = 0);```
you could just use

Code
 ```// Detect Xing Xdwn = (AO crosses below 0); Xup = (AO crosses above 0);```

 The following user says Thank You to SMCJB for this post:

London, United Kingdom

Posts: 3 since Aug 2018

Thanks again for your help, ABCTG and SMCJB.

 BTGUK, 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.

Not really. Try...

Code
 ``` AOLong = Average((High + Low)/2,AOLongPeriod); AOShort = Average((High + Low)/2,AOShortPeriod); AO = Round(AOShort - AOLong, 3);```
Or as @ABCTG suggested instead of

Code
 ```// Detect Xing Xdwn = (AO < 0) and (AO = 0); Xup = (AO > 0) and (AO = 0);```
you could just use

Code
 ```// Detect Xing Xdwn = (AO crosses below 0); Xup = (AO crosses above 0);```

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:

Code
 ```// 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 and AO < AO then Begin if (LwMkr = 0) or ((LwMkr < 0) and (LwMkr < AO)) then LwMkr = AO; if (LwMkr < 0) and (LwMkr > AO) 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?

Hamburg Germany

Broker/Data: DTN IQ
Favorite Futures: ES

Posts: 2,163 since Apr 2013

BTGUK,

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

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:

Code
 ```// 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 and AO < AO then Begin if (LwMkr = 0) or ((LwMkr < 0) and (LwMkr < AO)) then LwMkr = AO; if (LwMkr < 0) and (LwMkr > AO) 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?

 futures io > Need some help with my Awesome Oscillator strategy Upcoming Webinars and Events (4:30PM ET unless noted)

Right now

## \$250 Amazon Gift Cards with our "Thanks Contest" challenge!

Right now Similar Threads Thread Thread Starter Forum Replies Last Post protrader007 NinjaTrader Programming 19 August 30th, 2016 04:11 PM bluefightingcat EasyLanguage Programming 3 September 16th, 2015 11:36 AM khmodel NinjaTrader Programming 2 December 9th, 2011 03:04 PM Ryanb Jokes 1 April 5th, 2011 08:00 AM 