cBots

Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.
Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
How to install
DescriptionSubmited byDateCategoryPreviewDownloadsCommentsRating
This cBot helps to manage positions. cBot functions: 1. Setup initial stop loss (this this function is not important because cTrader already can do it). 2. Setup breakeven 1 (calculates in appliance with amount of comissions) on level1 3. Close fraction of the position and setup SL in appliance with amount of comissions and remain part. 4. Setup breakeven 2. 5. Tralling position.
11 Apr 2015
Downloads
861
Comments
2
Rating
0
Download
Advisor "MCAD PrbSAR noise" trades on signals indicators MACD and Parabolic SAR, default is optimized on a pair EURUSD H1. You can optimize any instrument and timeframe. Additionally Advisor equipped noise levels on indicators MACD and Parabolic SAR. Closing of open positions occurs on signals indicators MACD and Parabolic SAR only in profits, or - the stop-loss. 1- Noise_Prb_SAR_ema  2- Noise_MACD_m0  3- Noise_MACD_s0  4- Noise_MACD_sm 
18 Mar 2015
Downloads
1264
Comments
4
Rating
0
Download
Hi all,   This the first post of a serie of posts where I'll share my robots. This robot use moving average crossover strategy. The time frame to use is D1 otherwise don't change any other setting. This robot can help you pass the tough times if you use contrarian strategies because it allows you to have a big draw UP  when your contrarian strategy is making a big dawn. In the long term,  the results of this robot are sufficiently positive to not reduce the gain of your main strategy. Here are some back tests results : 
09 Feb 2015
Downloads
1671
Comments
0
Rating
0
Download
Forex Equity Protection works by setting a limit to your drawdown(floating loss) based on a preset percentage of your choice. Protect your Account balance and more importantly your equity with simple software that saves your forex account with equity protection. Limit your losses while trading forex with equity protection which cuts your losses at predefined percentage levels. Forex Equity Protection(FEP) prevents future losses by closing your losing positions without your decision. You can setup the FEP one time on your VPS and protect your account equity from being exposed to unknown forex volatility. More features coming soon  
01 Feb 2015
Downloads
911
Comments
2
Rating
0
Download
The Mechanic Bot uses the Candlestick Tendency indicator as a decision driver for entering trades. The basic idea is to trade higher order timeframe with current local timeframe. It trades a single position at a time and has mechanisms for trailing stops and basic money management. Here's the list of parameters and their descriptions: HighOrderTimeFrame - which higher timeframe to use for deciding on trend direction, default value is h1 (it's ok to leave it like that). This parameter gets forwarded to the Candlestick Tendency indicator. This is recommended to be at least 4x local timeframe. If you use minutes for the main local timeframe, then use minutes over hours for a higher timeframe, or hours over days, days over months etc... Volume - the trading amount, default is 10000, set this to whatever is satisfied by backtesting. EnableStopLoss - the name says it all, default is true to use stoploss mechanism, it's highly recommended to leave it as is (do not turn stoploss off unless you know what you're doing). StopLoss - the stoploss value, in pips, default is 20 (if enabled). EnableBreakEven - use breakeven mechanism or not, default is false (do not move to break even), other breakeven settings only have effect when this setting is true. BreakEvenPips - the amount of pips to set break even stoploss to, default is 10. BreakEvenGain - the minimal amount of profitable pips that triggers a move to break even, default is 20. EnableTrailingStop - use trailing stop mechanism or not, default is false, other trailing stop settings only have effect when this setting is true. TrailingStop - the amount of trailing pips, default is 10 (if enabled). TrailingStart - the minimal amount of profitable pips to start trailing (if enabled). EnableTakeProfit - use the takeprofit mechanism or not, default is true, highly recommended to leave it on. TakeProfit - the amount of take profit pips, default is 30, set this to whatever is satisfied by backtesting. EnterOnSyncSignalOnly - only trade when both local and global trends change direction on the same bar simultaneously, default is true. This setting increases the win/lose ratio, but can reduce the total amount of trades. That is, when this setting is set to true, the bot will make less trades and less mistakes, but this will probably take more time. ExitOnOppositeSignal - exit a position on opposite signal, default is false. This can generate a lot of noise and false signals, so it is recommended to leave it off. Installation: 1. Download and install the Candlestick Tendency indicator. 2. Download and install this bot. 3. Set a reference to Candlestick Tendency in reference manager before building the bot (3rd screenshot) 4. Build the bot.  
28 Jan 2015
Downloads
2742
Comments
6
Rating
2.5
Download
Reversion & Trend trading robot. Utilizes threshold to determine entry. Includes trailing stop loss. Reversion & Trend trading robot. Utilizes threshold to determine entry. Includes trailing stop loss.
06 Jan 2015
Downloads
2405
Comments
13
Rating
5
Download
Il n'y a ici que le money management d'Alembex, à vous d'y rajouter votre technique (les positions sont prises aux hasard sur l'exemple) Montrez vos résultat de ce Money management + votre technique :) Merci MISE A JOUR : - Corrections des bugs - Nouvelles images  avec les tests d'optimisations :  
29 Dec 2014
Downloads
2390
Comments
22
Rating
1.67
Download
Runs as a bot  that writes tick data to a  external CSV file  that can be read by other processes.    I needed this because our AI algorithm exists outside of calgo and needs fresh data every tick to make it's predictions.     I will eventually build the plumbing to allow external buy / sell recommendations to be read back from another stream using a separate bot. For those who want bar data instead of tick data.  Look for DataExportBars. Enhanced 2014-12-21 - Added the num_bid, num_ask and vol_adj_ask, vol_adj_bid columns based on market depth also removed some columns that have values that never changed.   I think  vol_adj_bid and vol_adj_ask show where the market really is with less gaming.  I like this because it shows where the bulk of the real orders are concentrated.   That way the odd sell at a very low or very high price people use to try and game the system are averaged out because they typically do not use large volumes for this kind of gaming.   It may be even better to throw away the statistical outliers and average the rest. Enhanced:2014-12-21 - Reverse spread for vol_adj_price and added a price adjust volume to provide a basic bull vs bear indicator based on where the bulk the open order book is hanging.   When used against backtest it can download historical data.  (See instructions in source) but the Market depth values I use to set num_bid, num_ask, vol_adj_ask, vol_adj_bid are not available during back test which is a real shame because I think these would be really handle for Machine learning algorithms.   The output file name is constructed from the Symbol plus the length of the moving average.  An example is: exp-EURUSD-ma30-ticks.csv   The moving average is included as an additional field just to show how it can be merged with the tick data. Sample Output: date,ask,bid,spread,num_ask,num_bid,vol_adj_ask,vol_adj_bid,vol_adj_spread 2014-12-22 06:51:29.746,1.225520,1.225410,0.000110,11,10,1.225600,1.225347,-0.000252 2014-12-22 06:51:36.527,1.225520,1.225420,0.000100,9,8,1.225590,1.225356,-0.000234 2014-12-22 06:51:44.308,1.225520,1.225430,0.000090,8,10,1.225584,1.225355,-0.000229 2014-12-22 06:51:44.621,1.225520,1.225440,0.000080,7,11,1.225588,1.225357,-0.000231 2014-12-22 06:51:47.621,1.225540,1.225440,0.000100,9,10,1.225594,1.225358,-0.000235 2014-12-22 06:51:49.371,1.225540,1.225460,0.000080,12,9,1.225635,1.225345,-0.000290 2014-12-22 06:51:49.621,1.225550,1.225460,0.000090,12,13,1.225662,1.225332,-0.000330 2014-12-22 06:51:50.371,1.225560,1.225460,0.000100,12,11,1.225675,1.225336,-0.000339 2014-12-22 06:51:50.605,1.225570,1.225460,0.000110,11,13,1.225682,1.225334,-0.000348 2014-12-22 06:51:50.918,1.225550,1.225450,0.000100,11,12,1.225684,1.225337,-0.000348 2014-12-22 06:51:51.168,1.225570,1.225490,0.000080,11,15,1.225667,1.225319,-0.000348 2014-12-22 06:51:51.480,1.225600,1.225520,0.000080,13,12,1.225723,1.225392,-0.000331 2014-12-22 06:51:51.621,1.225620,1.225520,0.000100,11,11,1.225703,1.225413,-0.000290 2014-12-22 06:51:52.418,1.225610,1.225520,0.000090,9,12,1.225676,1.225436,-0.000241 Sample in Excel When ran live can save new inbound ticks to the file as they arrive where a external process can pick them up.   I opened the file in shared mode so both processes can access the file simultaneously. It delivers a poor mans pipe for freshly arriving bar data.    I tested this in Lua and it will sit there waiting for new bars to show up at the end of the file and seems to catch them every time they arrive.     When using in this mode I recommend using a fast SSD or Ramdisk to minimize IO latency to disk. I apologize to those who want to use it internationally since I know the comma delimiter will mess up your formatting.  I tried changing it to a Tab delimited format but then it takes 5 extra clicks to load into excel.  There are only two lines where you have to change the , to tab to make  it work internationally.  I did not try to fix the back fill data problem for ticks like I did with bars because my application did not find them essential.  Let me know if you want this feature we can not duplicate it exactly but should be able to get close except for being able to backfill the gaps between end of back-test and real time.  Note:  To avoid saving ticks that had no order book I added a If Statement if ((volAdjAsk == 0.0) && (volAdjBid == 0.0)) it will have to be commented if you want to use it to download historical bars.  Want to collaborate:     www.linkedin.com/pub/joe-ellsworth/0/22/682/ or     http://bayesanalytic.com No Promises,  No Warranty.  Terms of use MIT http://opensource.org/licenses/MIT
23 Dec 2014
Downloads
1175
Comments
11
Rating
5
Download
Exports chosen bars for Symbol at chosen at the chosen bar size from calgo to CSV file in Directory specified.      Files can be imported by excel but do not open in  when trying to update as excel takes an exclusive lock which will crash the process. OK: Help Needed:   When I run this in Backtest mode with 1 minute bars I get something that looks like valid volumes.  When I run it with 10 tick bars I get the same volume in every bar.    How do we get valid volume for the smaller duration bars.  Question:  How do you convert (MarketSeries.TickVolume to actual Transaction volume for the Bar. I want Total number of units traded during the bar.   I think transaction volume is a more meaningful input for momentum because a small transaction of a fractional unit doesn't mean as much as if a 100 million $ changed hands during the same change in price.  Recommended used is to use the Backtester to download as much historical data as possible in a back-test then switch over to activating the strategy live.  It will auto-backfill the data between end of Backtest and live data but use the Backtest to get as much of the data as possible first as it's lastBar semantic is simplistic.  I have found that tickvolume is only accurate when the Backtest is using the "Tick Data from Server"       The system is smart enough to add new data from current Backtest to end of existing data and it will not overwrite or duplicate the older data but it is not smart enough to detect gaps if the user runs a Backtest covering a couple of months then skips a few months and runs a different Backtest. When used live it will write a new bar whenever a bar has been completed for as long as the cbot is active.    The files are opened in shared mode so a separate process can read new data from them as they arrive.  I needed this because our AI prediction engine needs new data as it arrives and can not run inside of calgo.  I will eventually  write the reverse plumbing to allow predictions from the external engine to be picked up by calgo and executed as trades. When used in back-tester will export the data in the time-frame specified by the backtest.   I tested it back to Jan-1-2011 and all the data seemed to show up.         File name is derived from the symbol, bar duration and chosen moving average and looks like:  exp-EURUSD-Minute-ma3-bars.b1.csv Data  Looks as follows: datetime,open,close,high,low,volume,weighted_val,rsi,stddev,spread 2014-01-27 00:00:00.000,1.368700,1.368630,1.368730,1.368610,23.000000,1.368650,67.318063,0.000223,0.000050 2014-01-27 00:01:00.000,1.368620,1.368590,1.368630,1.368590,15.000000,1.368600,66.005144,0.000282,0.000050 2014-01-27 00:02:00.000,1.368570,1.368860,1.368880,1.368490,41.000000,1.368773,70.226266,0.000365,0.000060 2014-01-27 00:03:00.000,1.368880,1.368980,1.369010,1.368880,29.000000,1.368963,71.896500,0.000438,0.000050 2014-01-27 00:04:00.000,1.368970,1.368980,1.368980,1.368970,4.000000,1.368978,71.896500,0.000483,0.000030 2014-01-27 00:05:00.000,1.369010,1.368810,1.369010,1.368810,20.000000,1.368860,65.829147,0.000504,0.000070 2014-01-27 00:06:00.000,1.368800,1.368610,1.368810,1.368610,28.000000,1.368660,59.470578,0.000500,0.000080 2014-01-27 00:07:00.000,1.368590,1.368970,1.368980,1.368550,36.000000,1.368868,65.862483,0.000511,0.000060 2014-01-27 00:08:00.000,1.368980,1.368990,1.369000,1.368980,6.000000,1.368990,66.181582,0.000512,0.000060 In Excel it looks like: Note: To auto parse the dates when loading in excel change the code to replace T between dateTime with a space. Enhanced Dec-21-2014: To only add bars newer than what are already present in the file but it is still missing the code  to detect gaps and try to fill them in.   Enhanced Dec-212-2014 - To attempt to backfill bars between current bar and the last bar it finds in the file.  This is needed because the the back tester in CAglo always runs a little behind the current data and would create a gap of some very critical missing current data.     This process calculates how many are missing and attempts to backfile from current series.   I have tested it over a weekend but not over longer periods of times.     Want to collaborate:   www.linkedin.com/pub/joe-ellsworth/0/22/682/  or http://BayesAnalytic.com No Promises,  No Warranty.  
22 Dec 2014
Downloads
1055
Comments
2
Rating
5
Download
//Momentum WillR% + Hull HMA tendence cBot. cBit also generate an oposite position if it tends to lose. //http://ctdn.com/algos/indicators/show/603   //#reference: ..\Indicators\EHMA.algo //Needs to install: http://ctdn.com/algos/indicators/show/17, Manage references. // //Date: 17/12/2014 //Country: Chile //Copyright: Felipe Sepulveda Maldonado  //LinkedIn: https://cl.linkedin.com/in/felipesepulvedamaldonado //Facebook: https://www.facebook.com/mymagicflight1 //Whats Up: +56 9 58786321 // felipe.sepulveda@gmail.com // //Recomended Timeframe: Minute, for more frequency and accuracy. //Cheers! using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo {     [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]     public class XkaliburBa : Robot     {         #region cBot Parameters         [Parameter("cBot Label", DefaultValue = "XkaliburBa")]         public string cBotLabel { get; set; }         [Parameter("Volume", DefaultValue = 1000, MinValue = 1000)]         public int InitialVolume { get; set; }         [Parameter("Take Profit", DefaultValue = 2, MinValue = 0, MaxValue = 102)]         public double TakeProfit { get; set; }         [Parameter("WilliamsR High", DefaultValue = 70, MinValue = 60, MaxValue = 95)]         public int wHigh { get; set; }         [Parameter("WilliamsR Low", DefaultValue = 30, MinValue = 5, MaxValue = 40)]         public int wLow { get; set; }         [Parameter("WilliamsR Period", DefaultValue = 120, MinValue = 10, MaxValue = 150)]         public int wrPeriod { get; set; }         [Parameter("Zero Loss Inverse (Pips)", DefaultValue = 6, MinValue = 4, MaxValue = 15)]         public int zlInv { get; set; }         [Parameter("EHMA Period", DefaultValue = 12, MinValue = 7)]         public int HullPeriod { get; set; }         [Parameter("Max. Time Open (Minutes)", DefaultValue = 30, MinValue = 5, MaxValue = 120)]         public int maxTime { get; set; }         double TrailingStop;         int nVolume;         string comId;         private EHMA hullMA1;         private EHMA hullMA2;         #endregion         #region cBot Events         protected override void OnStart()         {             hullMA1 = Indicators.GetIndicator<EHMA>(HullPeriod);             hullMA2 = Indicators.GetIndicator<EHMA>(HullPeriod * 6);             Timer.Start(1);         }         protected override void OnTimer()         {         }         protected override void OnTick()         {             double mercado = 100000 * Indicators.AverageTrueRange(MarketSeries, 5, MovingAverageType.VIDYA).Result.Last(0);             double will = 100 + Indicators.WilliamsPctR(wrPeriod).Result.Last(0);             if ((will < wLow) && hullMA1.ehma.IsRising() && hullMA2.ehma.IsRising())             {                 System.Threading.Thread.Sleep(15000);                 ExecuteMarketOrder(TradeType.Buy, Symbol, InitialVolume, cBotLabel, 100, 100, 2);             }             if ((will > wHigh) && hullMA1.ehma.IsFalling() && hullMA2.ehma.IsFalling())             {                 System.Threading.Thread.Sleep(15000);                 ExecuteMarketOrder(TradeType.Sell, Symbol, InitialVolume, cBotLabel, 100, 100, 2);             }             SetTrailingStop(mercado);             ZeroLoss();         }         #endregion         private void SetTrailingStop(double mercado)         {             var sellPositions = Positions.FindAll(cBotLabel, Symbol, TradeType.Sell);             TrailingStop = mercado / 30;             foreach (Position position in sellPositions)             {                 int mPosition = (position.EntryTime.Hour * 60) + position.EntryTime.Minute + maxTime;                 int mActual = (Time.Hour * 60) + Time.Minute;                 double distance = position.EntryPrice - Symbol.Ask;                 if ((distance < TakeProfit * Symbol.PipSize) || (mPosition < mActual))                     continue;                 double newStopLossPrice = Symbol.Ask + TrailingStop * Symbol.PipSize;                 if (position.StopLoss == null || newStopLossPrice < position.StopLoss)                     ModifyPosition(position, newStopLossPrice, position.TakeProfit);             }             var buyPositions = Positions.FindAll(cBotLabel, Symbol, TradeType.Buy);             foreach (Position position in buyPositions)             {                 int mPosition = (position.EntryTime.Hour * 60) + position.EntryTime.Minute + maxTime;                 int mActual = (Time.Hour * 60) + Time.Minute;                 double distance = Symbol.Bid - position.EntryPrice;                 if ((distance < TakeProfit * Symbol.PipSize) || (mPosition < mActual))                     continue;                 double newStopLossPrice = Symbol.Bid - TrailingStop * Symbol.PipSize;                 if (position.StopLoss == null || newStopLossPrice > position.StopLoss)                     ModifyPosition(position, newStopLossPrice, position.TakeProfit);             }         }         private void ZeroLoss()         {             var sellPositions = Positions.FindAll(cBotLabel, Symbol, TradeType.Sell);             foreach (Position position in sellPositions)             {                 double distance = position.EntryPrice - Symbol.Ask;                 double xtp = (double)((position.EntryPrice - position.TakeProfit) / Symbol.PipSize);                 if ((distance < -zlInv * Symbol.PipSize) && (xtp > 90))                 {                     double zlTP = Symbol.Ask - 90 * Symbol.PipSize;                     ModifyPosition(position, position.StopLoss, zlTP);                     switch (position.Volume)                     {                         case 1000:                             nVolume = 2000;                             break;                         case 2000:                             nVolume = 3000;                             break;                         default:                             nVolume = (int)(position.Volume * 2);                             break;                     }                     if (position.Comment != "")                         comId = position.Comment;                     else                         comId = position.Id.ToString();                     ExecuteMarketOrder(TradeType.Buy, Symbol, nVolume, cBotLabel, 100, 100, 2, comId);                 }             }             var buyPositions = Positions.FindAll(cBotLabel, Symbol, TradeType.Buy);             foreach (Position position in buyPositions)             {                 double distance = Symbol.Bid - position.EntryPrice;                 double xtp = (double)((position.TakeProfit - position.EntryPrice) / Symbol.PipSize);                 if ((distance < -zlInv * Symbol.PipSize) && (xtp > 90))                 {                     double zlTP = Symbol.Bid + 90 * Symbol.PipSize;                     ModifyPosition(position, position.StopLoss, zlTP);                     switch (position.Volume)                     {                         case 1000:                             nVolume = 2000;                             break;                         case 2000:                             nVolume = 3000;                             break;                         default:                             nVolume = (int)(position.Volume * 2);                             break;                     }                     if (position.Comment != "")                         comId = position.Comment;                     else                         comId = position.Id.ToString();                     ExecuteMarketOrder(TradeType.Sell, Symbol, nVolume, cBotLabel, 100, 100, 2, comId);                 }             }         }     } }  
18 Dec 2014
Downloads
874
Comments
2
Rating
0
Download
// ----------------------------------------------------------------------------------------     If you open multiple positions in a hedge strategy. This indicator show volume exposure each currency to other currency. // ----------------------------------------------------------------------------------------                                                                                                                                         
15 Dec 2014
Downloads
741
Comments
0
Rating
0
Download
//Date: 11/12/2014 //Country: Chile //Copyright: Felipe Sepulveda Maldonado //LinkedIn: https://cl.linkedin.com/in/felipesepulvedamaldonado //Facebook: https://www.facebook.com/mymagicflight1 //Whats Up: +56 9 58786321, your comments are welcome! //Donations Wallet: wallet.google.com felipe.sepulveda@gmail.com //Description: WillR% & Moving Average //Recomended Timeframe: M5 //Cheers! using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo {     [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]     public class Maithai : Robot     {         #region cBot Parameters         [Parameter("cBot Label", DefaultValue = "Maithai")]         public string cBotLabel { get; set; }         [Parameter("Volume", DefaultValue = 1000, MinValue = 1000)]         public int InitialVolume { get; set; }         [Parameter("Take Profit", DefaultValue = 2, MinValue = 1, MaxValue = 100)]         public int TakeProfit { get; set; }         [Parameter("Trailing Stop", DefaultValue = 1, MinValue = 0, MaxValue = 30)]         public int TrailingStop { get; set; }         [Parameter("Stop Loss", DefaultValue = 14, MinValue = 5, MaxValue = 150)]         public int StopLoss { get; set; }         [Parameter("WilliamsR High", DefaultValue = 90, MinValue = 85, MaxValue = 95)]         public int wHigh { get; set; }         [Parameter("WilliamsR Low", DefaultValue = 15, MinValue = 5, MaxValue = 20)]         public int wLow { get; set; }         [Parameter("WilliamsR Period", DefaultValue = 100, MinValue = 50, MaxValue = 200)]         public int wrPeriod { get; set; }         [Parameter("ATR Market Volatility Min.", DefaultValue = 35, MinValue = 0, MaxValue = 110)]         public int atrMarketMin { get; set; }         [Parameter("ATR Market Volatility Max.", DefaultValue = 100, MinValue = 100)]         public int atrMarketMax { get; set; }         [Parameter("ATR Period", DefaultValue = 10, MinValue = 1, MaxValue = 100)]         public int atrPeriod { get; set; }         [Parameter("Moving Average Type", DefaultValue = MovingAverageType.Simple)]         public MovingAverageType MovingAverageType { get; set; }         [Parameter("MA Period", DefaultValue = 14, MinValue = 3, MaxValue = 100)]         public int Period { get; set; }         [Parameter("MA Source")]         public DataSeries Source { get; set; }         [Parameter("Max. Time Open (Minutes)", DefaultValue = 60, MinValue = 5, MaxValue = 360)]         public int maxTime { get; set; }         #endregion         private MovingAverage _movingAverage;         #region cBot Events         protected override void OnStart()         {             _movingAverage = Indicators.MovingAverage(Source, Period, MovingAverageType);             Timer.Start(1);         }         protected override void OnTimer()         {         }         protected override void OnTick()         {             //Put your core logic here             double mercado = 100000 * Indicators.AverageTrueRange(MarketSeries, atrPeriod, MovingAverageType.VIDYA).Result.Last(0);             double will = 100 + Indicators.WilliamsPctR(wrPeriod).Result.Last(0);             ChartObjects.DrawText("", "Market:" + mercado.ToString() + "WillR:" + will.ToString(), StaticPosition.BottomRight, Colors.White);             if ((will < wLow) && (mercado > atrMarketMin) && (mercado < atrMarketMax) && _movingAverage.Result.IsRising())             {                 System.Threading.Thread.Sleep(1000);                 var result = ExecuteMarketOrder(TradeType.Buy, Symbol, InitialVolume, cBotLabel, StopLoss, 100, 2, mercado.ToString() + "-" + will.ToString());             }             if ((will > wHigh) && (mercado > atrMarketMax) && (mercado < atrMarketMax) && _movingAverage.Result.IsFalling())             {                 System.Threading.Thread.Sleep(1000);                 var result = ExecuteMarketOrder(TradeType.Sell, Symbol, InitialVolume, cBotLabel, StopLoss, 100, 2, mercado.ToString() + "-" + will.ToString());             }             // Trailing Stop for all positions             SetTrailingStop();             TimerClose();         }         #endregion         private void SetTrailingStop()         {             var sellPositions = Positions.FindAll(cBotLabel, Symbol, TradeType.Sell);             foreach (Position position in sellPositions)             {                 double distance = position.EntryPrice - Symbol.Ask;                 if (distance < TakeProfit * Symbol.PipSize)                     continue;                 double newStopLossPrice = Symbol.Ask + TrailingStop * Symbol.PipSize;                 if (position.StopLoss == null || newStopLossPrice < position.StopLoss)                     ModifyPosition(position, newStopLossPrice, position.TakeProfit);             }             var buyPositions = Positions.FindAll(cBotLabel, Symbol, TradeType.Buy);             foreach (Position position in buyPositions)             {                 double distance = Symbol.Bid - position.EntryPrice;                 if (distance < TakeProfit * Symbol.PipSize)                     continue;                 double newStopLossPrice = Symbol.Bid - TrailingStop * Symbol.PipSize;                 if (position.StopLoss == null || newStopLossPrice > position.StopLoss)                     ModifyPosition(position, newStopLossPrice, position.TakeProfit);             }         }         private void TimerClose()         {             foreach (Position position in Positions)             {                 int mPosition = (position.EntryTime.Hour * 60) + position.EntryTime.Minute + maxTime;                 int mActual = (Time.Hour * 60) + Time.Minute;                 //Si es que pasaron X min, entonces reevalua Buy (Abajo). Deja de insistir?                 if (mPosition < mActual)                     ClosePosition(position);                 //Si es que pasaron X min, entonces reevalua Sell (Arriba). Deja de insistir?                 if (mPosition < mActual)                     ClosePosition(position);             }         }     } }
11 Dec 2014
Downloads
768
Comments
0
Rating
0
Download