Need some help with my Awesome Oscillator strategy - futures io
futures io



Need some help with my Awesome Oscillator strategy


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one ABCTG with 3 posts (2 thanks)
    2. looks_two BTGUK with 3 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 SMCJB with 1 posts (1 thanks)
    1. trending_up 1,120 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 7 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Need some help with my Awesome Oscillator strategy

(login for full post details)
  #1 (permalink)
BTGUK
London, United Kingdom
 
 
Posts: 3 since Aug 2018
Thanks: 3 given, 0 received

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[1] and AO[1] < AO[2];
	Upwrd = AO > 0 and AO > AO[1] and AO[1] > AO[2];


// Detect Xing

	Xdwn = (AO < 0) and (AO[1] = 0);
	Xup = (AO > 0) and (AO[1] = 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[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;
	
	
	
// Compute Exits
	
	If (MarketPosition = 1) and Time > TimeBegin And Time < TimeEnd Then 
	Begin
		
		If (Gd = 2) then
		Begin
			
			if AO < AO[1] and AO[1] > AO[2] then
			Begin	
				if (HiMkr = 0) or ((HiMkr > 0) and (HiMkr > AO[1])) then HiMkr = AO[1];
				
				if (HiMkr > 0) and (HiMkr < AO[1]) 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;
Any ideas? Comments? Critique?

Reply With Quote

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(172 thanks from 21 posts)
looks_twoSalao's Journalby Salao
(48 thanks from 11 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(35 thanks from 18 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(15 thanks from 13 posts)
looks_5Maybe a little bit different journalby Malykubo
(14 thanks from 14 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Big Mike in Ecuador
76 thanks
The Crude Dude Oil Trading System
57 thanks
Would You Sell Your System?
57 thanks
Help improve the FIO community
27 thanks
The New Micro Contract - MICRO BITCOIN coming May 2021
25 thanks
 
(login for full post details)
  #3 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,238 since Apr 2013
Thanks: 417 given, 1,489 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[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?

Regards,

ABCTG

Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #4 (permalink)
BTGUK
London, United Kingdom
 
 
Posts: 3 since Aug 2018
Thanks: 3 given, 0 received

Hi ABCTG,

Thanks for your reply!


ABCTG View Post
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[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.

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!

Reply With Quote
 
(login for full post details)
  #5 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,238 since Apr 2013
Thanks: 417 given, 1,489 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

Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #6 (permalink)
 SMCJB 
Legendary Market Wizard
Houston, TX
 
Experience: Advanced
Platform: Trading Technologies
Broker: Primary Advantage Futures. Also ED&F and Tradestation
Trading: Primarily Energy but also a little GE, GC, SI & Bitcoin
 
Posts: 4,044 since Dec 2013
Thanks: 3,345 given, 7,987 received


BTGUK View Post
 
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[1] = 0);
	Xup = (AO > 0) and (AO[1] = 0);
you could just use
 
Code
// Detect Xing

	Xdwn = (AO crosses below 0);
	Xup = (AO crosses above 0);

Reply With Quote
The following user says Thank You to SMCJB for this post:
 
(login for full post details)
  #7 (permalink)
BTGUK
London, United Kingdom
 
 
Posts: 3 since Aug 2018
Thanks: 3 given, 0 received

Thanks again for your help, ABCTG and SMCJB.


ABCTG View Post
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.



SMCJB View Post
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[1] = 0);
	Xup = (AO > 0) and (AO[1] = 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[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?

Reply With Quote
 
(login for full post details)
  #8 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,238 since Apr 2013
Thanks: 417 given, 1,489 received

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


BTGUK View Post
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[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?


Follow me on Twitter Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Need some help with my Awesome Oscillator strategy


Last Updated on November 12, 2018


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts