FXCM Forex Trading

Moving-average based stop order [new] + FIFO now!

Strategies are published here.

Moderator: admin

Moving-average based stop order [new] + FIFO now!

Postby Nikolay.Gekht » Mon Oct 04, 2010 2:40 pm

This is an update for Moving-Average based stop order published here: viewtopic.php?f=31&t=2209

The strategy moves stop level of the chosen position exactly on the chosen Moving Average Value. The recommended settings are in range 100-200 for hourly or higher time frame.

Unlike the previous version, this strategy:
a) Starts to work immediately, without waiting for the first tick on chosen instrument.
b) Checks the the most recent MVA value every chosen period (1 second by default) and updates stop if MVA is changed more than for 1/10 of pip.
c) Stops automatically when trade disappears.
d) With "autotrading patch" does not show annoying "Event Log" window every time when stop order is changed. So, if you switched "Don't show this window on next event" to avoid "stop order changed events" you can switch it back, so, other alerts will not skipped anymore.

mvastop3.png


Because this strategy manages the regular stop order, it CANNOT be used on FIFO accounts (any accounts opened in US broker). For US accounts please use
net stop version of the strategy.

Download signal:
mvastop3.lua
(7.94 KiB) Downloaded 1511 times
Nikolay.Gekht
FXCodeBase: Base Builder
 
Posts: 1230
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Moving-average based stop order [new version]

Postby Nikolay.Gekht » Mon Oct 18, 2010 12:48 pm

Wonderful instruction by Jason Rodgers on how to use the strategy can be found here:
http://www.informedtrades.com/blogs/jas ... -loss.html
Nikolay.Gekht
FXCodeBase: Base Builder
 
Posts: 1230
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

FIFO (net stop) version

Postby Nikolay.Gekht » Wed Oct 20, 2010 6:14 pm

If your account is opened in FXCM US or other US-based broker, you cannot use the regular stop and limit orders due to NFA regulation (google for "NFA rule 2-43(b)") which prohibits selective positions management. In other words - you must close first the older positions on the same account for the same instruments. The mvastop3 strategy in the first post of this topic cannot be used as well.

However, the Trading Station provides a good alternative for stop orders - the net stop orders. You can set up them via "Summary" view for chosen account and instrument. If you recognize the whole amount of particular instrument on particular account as one netting position this orders works good enough for risk management.

So, please find the netting stop MVA-based order below. Unlike the strategy above, this strategy is attached to the instrument and the account (instead of the instrument and the trade). Everything else is the same - if the set of positions is long and chosen MVA value is below the market - the strategy creates and then tracks the order according MVA value. And, in opposite case - if the set of positions is short and chosen MVA value is above the market...

The strategy creates the stop order only in case the position exist. If position is closed, the strategy does not stop, but waits until the next position is created.

Please DO NOT use this strategy on non-FIFO (for example FXCM UK or dbFX accounts)!

Download:
mvastop4.lua
(8.19 KiB) Downloaded 857 times
Nikolay.Gekht
FXCodeBase: Base Builder
 
Posts: 1230
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Moving-average based stop order [new] + FIFO now!

Postby alepan72 » Wed May 04, 2011 5:46 am

Hi Nikolay!
I love this strategy (mvastop3). I use it for all of my trades. I want to write the code in my strategies, but I have a big problem and I wonder if you can help me... :roll:
If I write the code in a tick strategy (like orders) everything is OK. When I include the mvastop strategy into a candle strategy, mvastop3 stop the trade when the price hit an EMA but on close of current candle. Can you tell me how I must write the code, so strategy open a trade on a close candle (e.g. MA_advisor or RSI_strategy) but the mvastop work on tick?
I am grateful if you can me help with the code or if it exists somewhere a document - guide to read.
Best regards!
Thanks in advance :!:
Image
User avatar
alepan72
 
Posts: 59
Joined: Wed Oct 27, 2010 4:19 am

Re: Moving-average based stop order [new] + FIFO now!

Postby Nikolay.Gekht » Wed May 04, 2011 7:47 am

alepan72 wrote:Hi Nikolay!
I love this strategy (mvastop3). I use it for all of my trades. I want to write the code in my strategies, but I have a big problem and I wonder if you can help me... :roll:
If I write the code in a tick strategy (like orders) everything is OK. When I include the mvastop strategy into a candle strategy, mvastop3 stop the trade when the price hit an EMA but on close of current candle. Can you tell me how I must write the code, so strategy open a trade on a close candle (e.g. MA_advisor or RSI_strategy) but the mvastop work on tick?
I am grateful if you can me help with the code or if it exists somewhere a document - guide to read.
Best regards!
Thanks in advance :!:

Do you use helper.lua in your strategy? (It is just a slightly different approach in case it is used or not).
Nikolay.Gekht
FXCodeBase: Base Builder
 
Posts: 1230
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Moving-average based stop order [new] + FIFO now!

Postby alepan72 » Wed May 04, 2011 9:28 am

Thanks for direct correspondence

Yes, I use helper.lua
Image
User avatar
alepan72
 
Posts: 59
Joined: Wed Oct 27, 2010 4:19 am

Re: Moving-average based stop order [new] + FIFO now!

Postby Nikolay.Gekht » Thu May 05, 2011 10:56 am

With helper Lua:

1) Add a subscribtion for ticks:

Code: Select all
bid = ExtSubscribe(id, nil, "t1", true, "close");
-- or
ask = ExtSubscribe(id, nil, "t1", false, "close");


where id is an integer number which is different from the subscribtion id used for other collections you subscribed.

2) Add the case into ExtUpdate(id, source, period)

Code: Select all
if id == _your_bar_history_id_ then
   ...
elseif id == _your_tick_history_id_ then
   --
   -- this case will work on every tick!
   --

   -- calc stop level here
   ...
   -- apply stop level here
   ...
end
Nikolay.Gekht
FXCodeBase: Base Builder
 
Posts: 1230
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Moving-average based stop order [new] + FIFO now!

Postby alepan72 » Thu May 05, 2011 1:33 pm

Thanx a lot :!: :!: :!:
Your services are so helpfull!

Keep coding ;)
:lol:
Image
User avatar
alepan72
 
Posts: 59
Joined: Wed Oct 27, 2010 4:19 am

Re: Moving-average based stop order [new] + FIFO now!

Postby bguguen » Tue May 10, 2011 3:48 pm

Hey hey, im absolutely loving this feature, found it very useful however, just couple of question, is it possible to add a feature to it so i get to ADD more positions into the strategy?? because if im understanding correctly this strategy can only manage 1 trade at a time using the parameteres set, but what if i keep adding positions with the same purpose of having the SL following the EMA and eventually they will all Stop out as trend changes, and some will hit SL with a BE Positive win...

yea thats about it...
bguguen
 
Posts: 1
Joined: Tue May 10, 2011 3:42 pm

Re: Moving-average based stop order [new] + FIFO now!

Postby spinemaligna » Mon Apr 23, 2012 4:26 am

hi all,
Is it possible, and if so, could you add the facility to offset the value of the average by a number of pips.

Many thanks,
Ross
spinemaligna
 
Posts: 40
Joined: Sun Sep 12, 2010 2:42 am

Next

Return to Custom Strategies

Who is online

Users browsing this forum: No registered users and 2 guests