Topics
Replies
admin
29 Nov 2012, 12:36
I'm not sure why that is maybe you can share your code. In the meantime please test this and tell us if it solves your problem:
using System; using cAlgo.API; namespace cAlgo.Robots { [Robot] public class TestCreateBuyStopOrder:Robot { protected override void OnTick() { if(Trade.IsExecuting) return; double targetPrice = Symbol.Ask + Symbol.PipSize; if (Account.PendingOrders.Count == 0 && Account.Positions.Count == 0) Trade.CreateBuyStopOrder(Symbol, 1000, targetPrice, targetPrice - Symbol.PipSize, targetPrice + Symbol.PipSize, Server.Time.AddMinutes(10)); } protected override void OnPendingOrderCreated(PendingOrder newOrder) { Print("Pending order created"); Print("Stop Loss {0}", newOrder.StopLoss); Print("Take Profit {0}", newOrder.TakeProfit); } protected override void OnPositionOpened(Position openedPosition) { Print("Position opened"); Print("Stop Loss {0}", openedPosition.StopLoss); Print("Take Profit {0}", openedPosition.TakeProfit); } protected override void OnError(Error error) { Stop(); } } }
@admin
admin
29 Nov 2012, 11:17
The algo file is actually a dll file you can just rename it to .algo. Make sure you also set the namespace to be cAlgo.Robots/cAlgo.Indicators. You can set it as the default in the Application tab in the project properties in Visual Studio.
Let us know if you need more help.
@admin
admin
28 Nov 2012, 17:39
You can create a class library in c#. Make sure you add a reference to the cAlgo.API and that you are using .NET framework 4. You can build the project in visual studio and set the project output path to the folder where the indicators/robots are saved. This will create the algo file and then you will need to create an empty text (cs) file with the same name so that you can find it in the indicators/robots list and execute it there. Alternatively you may just copy paste the code into the cAlgo editor and just build it there.
Let us know if you require additional help.
@admin
admin
27 Nov 2012, 18:07
The reason it is crasshing is here:
bool longposition = position != null & position.TradeType == TradeType.Buy; bool shortposition = position != null & position.TradeType == TradeType.Sell;
It has to be corrected to this:
bool longposition = position != null && position.TradeType == TradeType.Buy; bool shortposition = position != null && position.TradeType == TradeType.Sell;
One more note, you would need this line
public IndicatorDataSeries MarketTrend { get; set; }
instead of
public double markettrend = 0;
in order to be able to access the values.
@admin
admin
26 Nov 2012, 17:55
Just correct it to this: Print("close=", MarketSeries.Close[MarketSeries.Close.Count-2]);
int index = MarketSeries.Close.Count-1;
int prevIndex = index - 1;
open: MarketSeries.Open[prevIndex]
high: MarketSeries.High[prevIndex]
low: MarketSeries.Low[prevIndex]
close:MarketSeries.Close[prevIndex]
@admin
admin
29 Nov 2012, 16:38
You may extend the class name of the robot you are trying to reference.
@admin