MA HA Strategy

Strategies are published here.

Moderator: admin

MA HA Strategy

Postby Apprentice » Sat Dec 23, 2017 8:22 am

1.png

2.png

Based on the request.
viewtopic.php?f=27&t=65472&p=116601#p116601
MA HA Strategy.lua
(41.82 KiB) Downloaded 413 times

SHIFT_MA.lua is available here.
viewtopic.php?f=17&t=1044&p=106775#p106775
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 18849
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: MA HA Strategy

Postby Silverthorn » Tue Jan 02, 2018 12:38 am

Hi Apprentice,

Thank you for your help.

At first the Strategy behaved very strangely. I eventually figured out that the shift on the MA was 2 periods not 1.

I found the lines

upper_band = core.indicators:create("SHIFT_MA", ha_ask.high, instance.parameters.N, instance.parameters.MA, 1, instance.parameters.SY);
lower_band = core.indicators:create("SHIFT_MA", ha_bid.low, instance.parameters.N, instance.parameters.MA, 1, -instance.parameters.SY);
centre_band_bid = core.indicators:create("SHIFT_MA", ha_bid.open, instance.parameters.N, instance.parameters.MA, 1, 0);
centre_band_ask = core.indicators:create("SHIFT_MA", ha_ask.open, instance.parameters.N, instance.parameters.MA, 1, 0);

and changed to

upper_band = core.indicators:create("SHIFT_MA", ha_ask.high, instance.parameters.N, instance.parameters.MA, 0, instance.parameters.SY);
lower_band = core.indicators:create("SHIFT_MA", ha_bid.low, instance.parameters.N, instance.parameters.MA, 0, -instance.parameters.SY);
centre_band_bid = core.indicators:create("SHIFT_MA", ha_bid.open, instance.parameters.N, instance.parameters.MA, 0, 0);
centre_band_ask = core.indicators:create("SHIFT_MA", ha_ask.open, instance.parameters.N, instance.parameters.MA, 0, 0);

That gives an offset of one candle as required but I'm sure that is not the correct way to fix the problem. It did allow me to run the strategy in simulator to test.

I then saw that the pending stop losses are placed at the centre band instead on the opposite band. I had originally requested that the stop be placed on the opposing band and moved to the centre band on the next candle but now realise that that is way too soon and causes a lot of stop outs. This is a manual trading system that I have used successfully for some time now. However the timing of when I move from the outer band to the centre band is something I use my own judgement on so it may need some tweaking.

Can I please have the pending stop loss placed on the opposite outer band on creation and then move up with the opposing outer band until the stop loss is above the trade entry/ break even point. At that time the stop loss should follow the centre band.

Lastly this is not a strategy that is set and forget. The timing is based on top down and bottom up analysis. I originally thought that being able to set trading to long or short only would suffice. I now realise that it would be a big advantage to be able to force a trade open and then let the strategy manage it from there. Is it possible to have a pair of buttons on the screen that would allow me to open trades manually and then allow the strategy to manage the trades from there?

Thanks again for your awesome work.

Cheers.
User avatar
Silverthorn
 
Posts: 41
Joined: Fri Nov 08, 2013 12:29 am
Location: Brisbane Australia

Re: MA HA Strategy

Postby Apprentice » Tue Jan 02, 2018 8:31 am

Your request is added to the development list under Id Number 3927
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 18849
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: MA HA Strategy

Postby Apprentice » Wed Jan 03, 2018 5:19 am

Try this version.
MA HA Strategy.lua
(43.25 KiB) Downloaded 358 times
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 18849
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: MA HA Strategy

Postby Silverthorn » Sun Mar 04, 2018 11:56 pm

Hi Apprentice,

I've been using this for some time now and would like to request some changes if I may.

1- Can I please have an option to turn the use of the centre band off and on.

Use Center Band ON = Stop is placed at the opposite band and moves up or down with the opposite band until the stop loss is above the break even point and then is moved with the center band.

Use Center Band OFF = Stop is placed at the opposite band and moves up or down with the opposite band.

2- I have also noticed that to move the stop loss is first deleted and then a new stop order is placed. Sometimes the new stop order is too close to the market price and the order fails. When this happens the trade is left open with no stop loss. Is it possible to place either the stop as close as possible to the desired position or track the position some other way and close if the stop loss is hit.
User avatar
Silverthorn
 
Posts: 41
Joined: Fri Nov 08, 2013 12:29 am
Location: Brisbane Australia

Re: MA HA Strategy

Postby Apprentice » Mon Mar 05, 2018 11:17 am

Your request is added to the development list under Id Number 4061
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 18849
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: MA HA Strategy

Postby Apprentice » Tue Mar 06, 2018 3:46 pm

Try this version.
MA HA Strategy.lua
(43.7 KiB) Downloaded 361 times
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 18849
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: MA HA Strategy

Postby Silverthorn » Mon Mar 19, 2018 7:10 pm

Hi Apprentice.

Works GREAT!! Thanks so much. Is it possible to get it to work on custom time frames like can be set with Custom Time Frame Candle View?
User avatar
Silverthorn
 
Posts: 41
Joined: Fri Nov 08, 2013 12:29 am
Location: Brisbane Australia

Re: MA HA Strategy

Postby Silverthorn » Tue Mar 20, 2018 11:48 pm

Hi Apprentice,

I hope you can help.

I'm getting the following error popup and then the Strategy stops.

C:/Program Files (x86)/Candleworks/FXTS2/Strategies/Custom/MA HA Strategy.lua:110: attempt to index local 'source' (a nil value)
User avatar
Silverthorn
 
Posts: 41
Joined: Fri Nov 08, 2013 12:29 am
Location: Brisbane Australia

Re: MA HA Strategy

Postby Silverthorn » Sun Mar 25, 2018 9:08 pm

Hi Apprentice,

Any word on this? Are you able to replicate the error?
User avatar
Silverthorn
 
Posts: 41
Joined: Fri Nov 08, 2013 12:29 am
Location: Brisbane Australia

Next

Return to Custom Strategies

Who is online

Users browsing this forum: No registered users and 11 guests