﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>ActFX Algorithmic Trading » ActFX » Trading Strategies  » Envelopes Strategy</title><generator>InstantForum.NET 2012-1</generator><description>ActFX Algorithmic Trading</description><link>http://forum.actfx.com/</link><webMaster>ActFX Algorithmic Trading</webMaster><lastBuildDate>Sun, 20 May 2012 22:47:36 GMT</lastBuildDate><ttl>20</ttl><item><title>Envelopes Strategy</title><link>http://forum.actfx.com/FindPost210.aspx</link><description>The Envelopes is similar to the Moving Average indicator. In consists of two Moving Averages, one displaced up, and one displaced down.It shows the range of the expected price behavior, so if price goes out of the area between two lines, it will come back to it.&lt;br&gt;&lt;br&gt;My Envelopes Strategy opens a long position if the price goes above the bottom line. The strategy opens a sell position if th3 price goes below the top indicator line.&lt;br&gt;&lt;br&gt;[img]http://forum.actfx.com/Attachment50.aspx[/img]</description><pubDate>Wed, 09 May 2012 21:01:12 GMT</pubDate><dc:creator>elvin</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3896.aspx</link><description>;)</description><pubDate>Wed, 09 May 2012 21:01:12 GMT</pubDate><dc:creator>Venus</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3780.aspx</link><description>Dear roaddog,&lt;br&gt;&lt;br&gt;You just need to add the type of MA, for example makSimple:&lt;br&gt;&lt;br&gt;     MA1 := TIndicatorMovingAverage.Create(History, 'Ma 1'); &lt;br&gt;     MA1.Period := 100;       &lt;br&gt;     MA1.Kind := makSimple;&lt;br&gt;&lt;br&gt;The Envelopes Strategy v.3.1 (with Simple MA) is in attachment. &lt;br&gt;</description><pubDate>Fri, 27 Jan 2012 07:50:00 GMT</pubDate><dc:creator>Admin</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3299.aspx</link><description>Could somebody please look at this; I am trying to add a moving average, so that it would only open long positions above ma and short only below MA; closes should stay the same not connected to MA; &lt;br&gt;I am doing something wrong&lt;br&gt;&lt;br&gt;&lt;br&gt;const&lt;br&gt;   StrategyName = 'Envelopes_Strategy_v.2.2';&lt;br&gt;&lt;br&gt;var&lt;br&gt;   History: TCandleHistory;&lt;br&gt;   Account: TAccount;&lt;br&gt;   Amount, Point: Double;&lt;br&gt;   MaxPos : Integer;&lt;br&gt;   Stop, Limit, Range, i: Integer;&lt;br&gt;   Env: TIndicatorEnvelopes;//the Envelopes indicator    &lt;br&gt;   MA1: TIndicatorMovingAverage;&lt;br&gt;&lt;br&gt;procedure OnCreate;&lt;br&gt;begin&lt;br&gt;     AddCandleHistorySetting(@History, 'History', '', CI_1_Minute, 100);&lt;br&gt;     History.OnNewCandleEvent := @OnNewCandle;&lt;br&gt;     History.OnNewRateEvent := @OnNewRate;&lt;br&gt;     AddIntegerSetting(@MaxPos, 'Max Open Trades', 1); // Change this to any number you like.&lt;br&gt;     AddAccountSetting(@Account, 'Account', '');&lt;br&gt;     AddFloatSetting(@Amount, 'Amount(Lots)', 1);         &lt;br&gt;     AddIntegerSetting(@Stop, 'Stop in pips', 20);&lt;br&gt;     AddIntegerSetting(@Limit, 'Limit in pips', 60);&lt;br&gt;     &lt;br&gt;     AddIntegerSetting(@Range, 'Trader Range', 2);&lt;br&gt;     &lt;br&gt;     Env := TIndicatorEnvelopes.Create(History,'Envelopes indicator'); //setting for envelopes&lt;br&gt;     //the envelopes parameters:&lt;br&gt;     Env.Period := 14;&lt;br&gt;     Env.Deviation := 0.05;     &lt;br&gt;&lt;br&gt;     MA1 := TIndicatorMovingAverage.Create(History, 'Ma 1');   &lt;br&gt;     MA1.Period := 100;&lt;br&gt;end;&lt;br&gt;&lt;br&gt;&lt;br&gt;procedure OnNewCandle;&lt;br&gt;begin&lt;br&gt;     Point := History.Instrument.PointSize;&lt;br&gt;     //price crosses the top line -&gt; sell&lt;br&gt;     if (TradeList.Count &lt; MaxPos) and (History.Last(1).Close &gt; Env.TopGraph.Last(1)) and ((History.Instrument.Sell &lt;= MA1.Graph.Last(0))) then&lt;br&gt;     begin&lt;br&gt;        if (TradeList.Count &gt; 0) then&lt;br&gt;        begin&lt;br&gt;            for i:=TradeList.Count-1 downto 0 do&lt;br&gt;            begin&lt;br&gt;               if (TradeList.Get(i).Tag = 'BuyEnv') then&lt;br&gt;               begin&lt;br&gt;                  CloseTrade(TradeList.Get(i), TradeList.Get(i).Amount, Range, TradeList.Get(i).Tag);&lt;br&gt;               end; &lt;br&gt;            end; &lt;br&gt;        end;&lt;br&gt;          CreateOrder(History.Instrument, Account, Amount, bsSell, &lt;br&gt;                      History.Instrument.Buy + Stop*Point,&lt;br&gt;                      History.Instrument.Buy - Limit*Point, Range, 'SellEnv');&lt;br&gt;     end;&lt;br&gt;&lt;br&gt;&lt;br&gt;//price crosses the bottom line -&gt; buy&lt;br&gt;    if(TradeList.Count &lt; MaxPos) and (History.Last(1).Close &lt; Env.BottomGraph.Last(1)) and ((History.Instrument.Sell &gt;= MA1.Graph.Last(0))) then&lt;br&gt;    begin&lt;br&gt;       if (TradeList.Count &gt; 0) then&lt;br&gt;       begin&lt;br&gt;          for i:=TradeList.Count-1 downto 0 do&lt;br&gt;          begin              &lt;br&gt;              if (TradeList.Get(i).Tag = 'SellEnv') then&lt;br&gt;              begin&lt;br&gt;                 CloseTrade(TradeList.Get(i), TradeList.Get(i).Amount, Range, TradeList.Get(i).Tag);&lt;br&gt;              end; &lt;br&gt;          end; &lt;br&gt;       end;&lt;br&gt;    CreateOrder(History.Instrument, Account, Amount, bsBuy,  &lt;br&gt;                History.Instrument.Sell - Stop*Point,&lt;br&gt;                History.Instrument.Sell + Limit*Point,  Range, 'BuyEnv');&lt;br&gt;    end;&lt;br&gt;end;&lt;br&gt;</description><pubDate>Sun, 31 Jul 2011 18:47:41 GMT</pubDate><dc:creator>roaddog</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3288.aspx</link><description>Try to change the limit or stop settings if you have 9999</description><pubDate>Wed, 27 Jul 2011 16:15:24 GMT</pubDate><dc:creator>roaddog</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3284.aspx</link><description>Hi, &lt;br&gt;Would someone please help me!&lt;br&gt;When I try to run the strategy in real it gives me this error!&lt;br&gt;I don't know what to do,&lt;br&gt;&lt;br&gt;&lt;br&gt;EXCEPTION&lt;br&gt;ESmartException in TTraderDataProvider&lt;br&gt;CODE&lt;br&gt;20135&lt;br&gt;MESSAGE&lt;br&gt;Exception at trading strategy "NASA" in routine OnNewRate at Line:Column 123:10&lt;br&gt;Wrong Stop or Limit price: market rate 1.4497; order rate 1.4497;&lt;br&gt;DETAILS&lt;br&gt;ORA-20135: Wrong Stop or Limit price: market rate 1.4497; order rate 1.4497;&lt;br&gt;ORA-06512: at "EFOREX35.EXCEPTIONS", line 350&lt;br&gt;&lt;br&gt;</description><pubDate>Wed, 27 Jul 2011 00:18:46 GMT</pubDate><dc:creator>PataPata</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3281.aspx</link><description>[quote][b]smallpips (7/25/2011)[/b][hr]Hi folks,&lt;br&gt;I'm trying to get to grips with the ACT stuff and I was wondering.  Is it possible to configure an ACT file to run at a certain time of day?  Let's say I know I'm not going to be at my screen at 1am but I want a trade entered at 1:30am based on the previous six 5m candlesticks.  Is it possible to configure the file so that it will only run at a pre-determined time?&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;thanks for any assistance.&lt;br&gt;&lt;br&gt;&lt;br&gt;[/quote]&lt;br&gt;&lt;br&gt;First, I don't know of any way to start a Strategy from a dead stop, except to do it manually. If you want to do this, ask Admin to be sure.&lt;br&gt;&lt;br&gt;If all you want to do is make a running Strategy react at certain times, there is scripting info located at [url]http://help.sysfx.com/documents/traders_manual/4.3/en_US/index.html?other_functions_2.htm[/url] under the Date/Time sub-heading. Also, check out the scripts in the &lt;a href="http://www.actfx.com/Downloads.aspx" target="_blank"&gt;Code Library&lt;/a&gt;.&lt;br&gt;&lt;br&gt;Do a search on the word "time" in the ActTrader manual located here: [url]http://help.sysfx.com/documents/traders_manual/4.3/en_US/index.html?icts_trader_application.htm[/url].&lt;br&gt;&lt;br&gt;&lt;br&gt;:)</description><pubDate>Tue, 26 Jul 2011 03:05:52 GMT</pubDate><dc:creator>black</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3276.aspx</link><description>Hi folks,&lt;br&gt;I'm trying to get to grips with the ACT stuff and I was wondering.  Is it possible to configure an ACT file to run at a certain time of day?  Let's say I know I'm not going to be at my screen at 1am but I want a trade entered at 1:30am based on the previous six 5m candlesticks.  Is it possible to configure the file so that it will only run at a pre-determined time?&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;thanks for any assistance.&lt;br&gt;&lt;br&gt;&lt;br&gt;</description><pubDate>Mon, 25 Jul 2011 11:00:45 GMT</pubDate><dc:creator>smallpips</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3271.aspx</link><description>[center][img]http://foolstown.com/sm/shrk.gif[/img][/center]</description><pubDate>Thu, 21 Jul 2011 20:13:42 GMT</pubDate><dc:creator>m500</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3270.aspx</link><description>Could somebody tweek this script a bit, so that it would close poistion as soon as the candle breaks the envelope to the outside and not wait till it comes back inside. Thanks &lt;br&gt;&lt;br&gt;//==============================================&lt;br&gt;// This is a strategy using envelopes indicator&lt;br&gt;//==============================================&lt;br&gt;// Modification of Envelopes Strategy &lt;br&gt;&lt;br&gt;const&lt;br&gt;  StrategyName = 'Envelopes_Strategy_v.2';&lt;br&gt;&lt;br&gt;var&lt;br&gt;  History: TCandleHistory;&lt;br&gt;  Account: TAccount;&lt;br&gt;  Amount, Point: Double;&lt;br&gt;  &lt;br&gt;  Range, i: Integer;&lt;br&gt;   &lt;br&gt;  Env: TIndicatorEnvelopes;//the Envelopes indicator&lt;br&gt;&lt;br&gt;procedure OnCreate;&lt;br&gt;begin&lt;br&gt;  AddCandleHistorySetting(@History, 'History', '', CI_15_Minutes, 100);   &lt;br&gt;  History.OnNewCandleEvent := @OnNewCandle;&lt;br&gt;  History.OnNewRateEvent := @OnNewRate;   &lt;br&gt;  AddAccountSetting(@Account, 'Account', ''); &lt;br&gt;  AddFloatSetting(@Amount, 'Amount(Lots)', 1);&lt;br&gt;  &lt;br&gt;  AddIntegerSetting(@Range, 'Trader Range', 2);&lt;br&gt;&lt;br&gt;  Env := TIndicatorEnvelopes.Create(History,'Envelopes indicator'); //setting for envelopes&lt;br&gt;  //the envelopes parameters:&lt;br&gt;  Env.Period := 4;&lt;br&gt;  Env.Deviation := 0.2; &lt;br&gt;end;&lt;br&gt;&lt;br&gt;&lt;br&gt;// this procedure runs when a new candle opens&lt;br&gt;procedure OnNewCandle;&lt;br&gt;begin&lt;br&gt;  //price crosses the top line -&gt; sell                                                                                         &lt;br&gt;  if (History.Last(1).Close&lt;Env.TopGraph.Last(1)) and (History.Last(2).Close&gt;Env.TopGraph.Last(2)) then  &lt;br&gt;  begin  &lt;br&gt;  for i:=TradeList.Count-1 downto 0 do         &lt;br&gt;         if (TradeList.Get(i).BuySell = bsBuy) and (TradeList.Get(i).Tag = 'BuyEnv')  then&lt;br&gt;         CloseTrade(TradeList.Get(i), TradeList.Get(i).Amount, 0, TradeList.Get(i).Tag);&lt;br&gt;  CreateOrder(History.Instrument, Account, Amount*2, bsSell, Nullrate, NullRate, Range, 'SellEnv');   &lt;br&gt;  end;&lt;br&gt;  //price crosses the bottom line -&gt; buy                  &lt;br&gt;  if (History.Last(1).Close&gt;Env.BottomGraph.Last(1)) and (History.Last(2).Close&lt;Env.BottomGraph.Last(2)) then  &lt;br&gt;  begin   &lt;br&gt;  for i:=TradeList.Count-1 downto 0 do         &lt;br&gt;         if (TradeList.Get(i).BuySell = bsSell) and (TradeList.Get(i).Tag = 'SellEnv')  then&lt;br&gt;         CloseTrade(TradeList.Get(i), TradeList.Get(i).Amount, 0, TradeList.Get(i).Tag);  &lt;br&gt;  CreateOrder(History.Instrument, Account, Amount*2, bsBuy, NullRate, Nullrate, Range, 'BuyEnv');&lt;br&gt;  end;&lt;br&gt;end;&lt;br&gt;&lt;br&gt;procedure OnTradeChange(const Action: TDataModificationType; const Trade: TTrade);&lt;br&gt;begin&lt;br&gt;  if (Action=dmtInsert) then if (Trade.Tag='SellEnv') then log ('Sell trade opened.');&lt;br&gt;  if (Action=dmtInsert) then if (Trade.Tag='BuyEnv') then log ('Buy trade opened.'); &lt;br&gt;  if (Action=dmtInsert) then  log ('Open Rate.' +FloatToStr(Trade.OpenRate));&lt;br&gt;end;</description><pubDate>Wed, 20 Jul 2011 10:07:18 GMT</pubDate><dc:creator>roaddog</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3255.aspx</link><description>Emoe; could this last script be changed so that it would be opening and closing positions as soon the price touches the envelope and not wait for the candle to close ?</description><pubDate>Wed, 13 Jul 2011 14:34:08 GMT</pubDate><dc:creator>roaddog</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3250.aspx</link><description>Thanks Emoe but I have managed  to get it work (with help of great ACT team) but results arent immpresive. &lt;br&gt;So, back to work:)</description><pubDate>Tue, 12 Jul 2011 12:26:03 GMT</pubDate><dc:creator>roaddog</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3249.aspx</link><description>Hi roaddog!&lt;br&gt;&lt;br&gt;If you discribe what changes do you need (or how it should work) I'll try to help you</description><pubDate>Tue, 12 Jul 2011 05:20:13 GMT</pubDate><dc:creator>eMoe</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3234.aspx</link><description>Also I see that this scrip is opening positions on every time frame if outside the envelope.</description><pubDate>Fri, 08 Jul 2011 11:32:36 GMT</pubDate><dc:creator>roaddog</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3233.aspx</link><description>I know now what the problem is; it only closes positions until the maximum alowed opened trades is filled. &lt;br&gt;Lets say we have max open trades: 5&lt;br&gt;It will be closing positions if there are less than 5 open poistions, if there are 5 open poistions it stops closing them.&lt;br&gt;I dont know how to fix that.</description><pubDate>Fri, 08 Jul 2011 08:15:21 GMT</pubDate><dc:creator>roaddog</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3232.aspx</link><description>I we tryed it with avafx tester and sterling gent tester and its the same thing; also it did close positions with the origninal strategy with not limited positions.</description><pubDate>Fri, 08 Jul 2011 05:02:54 GMT</pubDate><dc:creator>roaddog</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3228.aspx</link><description>I’ve tried this strategy in test mode and my positions were closed.&lt;br&gt;&lt;br&gt;Maybe you trade with NFA broker? Closing individual position is restricted under NFA.</description><pubDate>Fri, 08 Jul 2011 04:34:36 GMT</pubDate><dc:creator>eMoe</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3226.aspx</link><description>Thank you for hepling eMoe but it still doesnt wont to close the position</description><pubDate>Fri, 08 Jul 2011 04:16:51 GMT</pubDate><dc:creator>roaddog</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3222.aspx</link><description>Hello, roaddog.&lt;br&gt;&lt;br&gt;I’ve organized and fixed your code. Now it seems to work. Enjoy.&lt;br&gt;</description><pubDate>Fri, 08 Jul 2011 03:23:00 GMT</pubDate><dc:creator>eMoe</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3219.aspx</link><description>Its not working; cant get past compile but thans for suggestion&lt;br&gt;&lt;br&gt;&lt;br&gt;//==============================================&lt;br&gt;// This is a strategy using envelopes indicator&lt;br&gt;//==============================================&lt;br&gt;// Modification of Envelopes Strategy &lt;br&gt;&lt;br&gt;const&lt;br&gt;  StrategyName = 'Envelopes_Strategy_v.2';&lt;br&gt;&lt;br&gt;var&lt;br&gt;  History: TCandleHistory;&lt;br&gt;  Account: TAccount;&lt;br&gt;  Amount, Point: Double;  &lt;br&gt;  MaxPos : Integer;&lt;br&gt;&lt;br&gt;  &lt;br&gt;  Range, i: Integer;  &lt;br&gt;  &lt;br&gt;   &lt;br&gt;  Env: TIndicatorEnvelopes;//the Envelopes indicator&lt;br&gt;&lt;br&gt;procedure OnCreate;&lt;br&gt;begin&lt;br&gt;  AddCandleHistorySetting(@History, 'History', '', CI_1_Minute, 100);   &lt;br&gt;  History.OnNewCandleEvent := @OnNewCandle;&lt;br&gt;  History.OnNewRateEvent := @OnNewRate; &lt;br&gt;  AddIntegerSetting(@MaxPos, 'Max Open Trades', 1); // Change this to any number you like.  &lt;br&gt;  AddAccountSetting(@Account, 'Account', ''); &lt;br&gt;  AddFloatSetting(@Amount, 'Amount(Lots)', 1);&lt;br&gt;  &lt;br&gt;  AddIntegerSetting(@Range, 'Trader Range', 2);&lt;br&gt;&lt;br&gt;  Env := TIndicatorEnvelopes.Create(History,'Envelopes indicator'); //setting for envelopes&lt;br&gt;  //the envelopes parameters:&lt;br&gt;  Env.Period := 14;&lt;br&gt;  Env.Deviation := 0.05;     &lt;br&gt; &lt;br&gt;end;&lt;br&gt;&lt;br&gt;&lt;br&gt;// this procedure runs when a new candle opens&lt;br&gt;procedure OnNewCandle;&lt;br&gt;begin&lt;br&gt; //price crosses the top line -&gt; sell&lt;br&gt;if (TradeList.Count &lt; MaxPos) and (History.Last(1).Close &gt; Env.TopGraph.Last(1)) then&lt;br&gt;begin&lt;br&gt;&lt;br&gt;if (TradeList.Count &gt; 0) then&lt;br&gt;begin&lt;br&gt;for i:=TradeList.Count-1 downto 0 do&lt;br&gt;begin&lt;br&gt;if (TradeList.Get(i).BuySell = bsBuy) and (TradeList.Get(i).Tag = 'BuyEnv') then&lt;br&gt;begin&lt;br&gt;CloseTrade(TradeList.Get(i), TradeList.Get(i).Amount, 0, TradeList.Get(i).Tag);&lt;br&gt;end; end; end;&lt;br&gt;&lt;br&gt;CreateOrder(History.Instrument, Account, Amount, bsSell, Nullrate, NullRate, Range, 'SellEnv');&lt;br&gt;&lt;br&gt;end;&lt;br&gt;          &lt;br&gt;  end;&lt;br&gt;  //price crosses the bottom line -&gt; buy&lt;br&gt;if(TradeList.Count &lt; MaxPos) and (History.Last(1).Close &lt; Env.BottomGraph.Last(1)) then&lt;br&gt;begin&lt;br&gt;&lt;br&gt;if (TradeList.Count &gt; 0) then&lt;br&gt;begin&lt;br&gt;for i:=TradeList.Count-1 downto 0 do&lt;br&gt;begin&lt;br&gt;if (TradeList.Get(i).BuySell = bsSell) and (TradeList.Get(i).Tag = 'SellEnv') then&lt;br&gt;begin&lt;br&gt;CloseTrade(TradeList.Get(i), TradeList.Get(i).Amount, 0, TradeList.Get(i).Tag);&lt;br&gt;end; end; end;&lt;br&gt;&lt;br&gt;CreateOrder(History.Instrument, Account, Amount, bsBuy, NullRate, Nullrate, Range, 'BuyEnv');&lt;br&gt;&lt;br&gt;end;&lt;br&gt;&lt;br&gt;procedure OnTradeChange(const Action: TDataModificationType; const Trade: TTrade);&lt;br&gt;begin&lt;br&gt;  if (Action=dmtInsert) then if (Trade.Tag='SellEnv') then log ('Sell trade opened.');&lt;br&gt;  if (Action=dmtInsert) then if (Trade.Tag='BuyEnv') then log ('Buy trade opened.'); &lt;br&gt;  if (Action=dmtInsert) then  log ('Open Rate.' +FloatToStr(Trade.OpenRate));       &lt;br&gt;  &lt;br&gt; &lt;br&gt;end;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</description><pubDate>Thu, 07 Jul 2011 21:36:55 GMT</pubDate><dc:creator>roaddog</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3218.aspx</link><description>I haven't tried this, but here are some changes to the script above:&lt;br&gt;&lt;br&gt;===========================================&lt;br&gt;&lt;br&gt;//********** &lt;br&gt;&lt;br&gt;//price crosses the top line -&gt; sell&lt;br&gt;if (TradeList.Count &lt; MaxPos) and (History.Last(1).Close &gt; Env.TopGraph.Last(1)) then&lt;br&gt;begin&lt;br&gt;&lt;br&gt;if (TradeList.Count &gt; 0) then&lt;br&gt;begin&lt;br&gt;for i:=TradeList.Count-1 downto 0 do&lt;br&gt;begin&lt;br&gt;if (TradeList.Get(i).BuySell = bsBuy) and (TradeList.Get(i).Tag = 'BuyEnv') then&lt;br&gt;begin&lt;br&gt;CloseTrade(TradeList.Get(i), TradeList.Get(i).Amount, 0, TradeList.Get(i).Tag);&lt;br&gt;end; end; end;&lt;br&gt;&lt;br&gt;CreateOrder(History.Instrument, Account, Amount, bsSell, Nullrate, NullRate, Range, 'SellEnv');&lt;br&gt;&lt;br&gt;end;&lt;br&gt;&lt;br&gt;//********** &lt;br&gt;&lt;br&gt;//price crosses the bottom line -&gt; buy&lt;br&gt;if(TradeList.Count &lt; MaxPos) and (History.Last(1).Close &lt; Env.BottomGraph.Last(1)) then&lt;br&gt;begin&lt;br&gt;&lt;br&gt;if (TradeList.Count &gt; 0) then&lt;br&gt;begin&lt;br&gt;for i:=TradeList.Count-1 downto 0 do&lt;br&gt;begin&lt;br&gt;if (TradeList.Get(i).BuySell = bsSell) and (TradeList.Get(i).Tag = 'SellEnv') then&lt;br&gt;begin&lt;br&gt;CloseTrade(TradeList.Get(i), TradeList.Get(i).Amount, 0, TradeList.Get(i).Tag);&lt;br&gt;end; end; end;&lt;br&gt;&lt;br&gt;CreateOrder(History.Instrument, Account, Amount, bsBuy, NullRate, Nullrate, Range, 'BuyEnv');&lt;br&gt;&lt;br&gt;end;&lt;br&gt;&lt;br&gt;//********** &lt;br&gt;&lt;br&gt;&lt;br&gt;:)</description><pubDate>Thu, 07 Jul 2011 18:27:34 GMT</pubDate><dc:creator>black</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost3217.aspx</link><description>Hello ! I am trying to maket this strategy that it will only open a limited amount of positions; i have read the forum and tryed to copy paste it but something is wrong; now it doesnt wont to close positions and also is buying 2 pos at once; could someone look at this ? Thanks&lt;br&gt;&lt;br&gt;const&lt;br&gt;  StrategyName = 'Envelopes_Strategy_v.2';&lt;br&gt;&lt;br&gt;var&lt;br&gt;  History: TCandleHistory;&lt;br&gt;  Account: TAccount;&lt;br&gt;  Amount, Point: Double;  &lt;br&gt;  MaxPos : Integer;&lt;br&gt;&lt;br&gt;  &lt;br&gt;  Range, i: Integer;  &lt;br&gt;  &lt;br&gt;   &lt;br&gt;  Env: TIndicatorEnvelopes;//the Envelopes indicator&lt;br&gt;&lt;br&gt;procedure OnCreate;&lt;br&gt;begin&lt;br&gt;  AddCandleHistorySetting(@History, 'History', '', CI_1_Minute, 100);   &lt;br&gt;  History.OnNewCandleEvent := @OnNewCandle;&lt;br&gt;  History.OnNewRateEvent := @OnNewRate; &lt;br&gt;  AddIntegerSetting(@MaxPos, 'Max Open Trades', 1); // Change this to any number you like.  &lt;br&gt;  AddAccountSetting(@Account, 'Account', ''); &lt;br&gt;  AddFloatSetting(@Amount, 'Amount(Lots)', 1);&lt;br&gt;  &lt;br&gt;  AddIntegerSetting(@Range, 'Trader Range', 2);&lt;br&gt;&lt;br&gt;  Env := TIndicatorEnvelopes.Create(History,'Envelopes indicator'); //setting for envelopes&lt;br&gt;  //the envelopes parameters:&lt;br&gt;  Env.Period := 14;&lt;br&gt;  Env.Deviation := 0.05;     &lt;br&gt; &lt;br&gt;end;&lt;br&gt;&lt;br&gt;&lt;br&gt;// this procedure runs when a new candle opens&lt;br&gt;procedure OnNewCandle;&lt;br&gt;begin&lt;br&gt;  //price crosses the top line -&gt; sell                                                                                         &lt;br&gt;  if (TradeList.Count &lt; 1) and (History.Last(1).Close&lt;Env.TopGraph.Last(1)) and (History.Last(2).Close&gt;Env.TopGraph.Last(2))  then  &lt;br&gt;  begin  &lt;br&gt;  for i:=TradeList.Count-1 downto 0 do         &lt;br&gt;         if (TradeList.Get(i).BuySell = bsBuy) and (TradeList.Get(i).Tag = 'BuyEnv')  then&lt;br&gt;         CloseTrade(TradeList.Get(i), TradeList.Get(i).Amount, 0, TradeList.Get(i).Tag);&lt;br&gt;  CreateOrder(History.Instrument, Account, Amount*2, bsSell, Nullrate, NullRate, Range, 'SellEnv'); &lt;br&gt;          &lt;br&gt;  end;&lt;br&gt;  //price crosses the bottom line -&gt; buy                  &lt;br&gt;  if(TradeList.Count &lt; 1) and (History.Last(1).Close&gt;Env.BottomGraph.Last(1)) and (History.Last(2).Close&lt;Env.BottomGraph.Last(2)) then  &lt;br&gt;  begin   &lt;br&gt;  for i:=TradeList.Count-1 downto 0 do         &lt;br&gt;         if (TradeList.Get(i).BuySell = bsSell) and (TradeList.Get(i).Tag = 'SellEnv')  then&lt;br&gt;         CloseTrade(TradeList.Get(i), TradeList.Get(i).Amount, 0, TradeList.Get(i).Tag);  &lt;br&gt;  CreateOrder(History.Instrument, Account, Amount*2, bsBuy, NullRate, Nullrate, Range, 'BuyEnv');   &lt;br&gt;         &lt;br&gt;  end;&lt;br&gt;end;&lt;br&gt;&lt;br&gt;procedure OnTradeChange(const Action: TDataModificationType; const Trade: TTrade);&lt;br&gt;begin&lt;br&gt;  if (Action=dmtInsert) then if (Trade.Tag='SellEnv') then log ('Sell trade opened.');&lt;br&gt;  if (Action=dmtInsert) then if (Trade.Tag='BuyEnv') then log ('Buy trade opened.'); &lt;br&gt;  if (Action=dmtInsert) then  log ('Open Rate.' +FloatToStr(Trade.OpenRate));       &lt;br&gt;  &lt;br&gt; &lt;br&gt;end;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</description><pubDate>Thu, 07 Jul 2011 13:40:47 GMT</pubDate><dc:creator>roaddog</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost2373.aspx</link><description>hi i have a question, how do i do to make the strategy only open positions on buy but not on sell or the other way around.. i explain: i believe the wuro is falling, so i decide to play only sell positions for this strategy.. how do i do?</description><pubDate>Wed, 24 Nov 2010 07:45:08 GMT</pubDate><dc:creator>romeno182</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost2370.aspx</link><description>am using 16 - 0.143 on eur/usd 15 min in real and having great results..</description><pubDate>Wed, 24 Nov 2010 02:50:03 GMT</pubDate><dc:creator>romeno182</dc:creator></item><item><title>RE: Envelopes Strategy</title><link>http://forum.actfx.com/FindPost2199.aspx</link><description>Sorry for the previous post. After reading all the coments I see that the problem is with the deviation setings.</description><pubDate>Sun, 24 Oct 2010 03:40:04 GMT</pubDate><dc:creator>Mihai</dc:creator></item></channel></rss>
