Topics
Replies
admin
09 Jan 2013, 15:34
Thank you for the suggestion. If you need a horizontal line it is easily implemented by either using the Levels attribute for indicators or setting a constant value to an Outpout Indicator Result, e.g.
[Output("Main")]
public IndicatorDataSeries Result { get; set; }
public override void Calculate(int index)
{
Result[index] = 1;
}
@admin
admin
04 Jan 2013, 17:24
The reason this is, is that the Stop Loss and Take Profit are set right after the OnPosistionOpened event. The workaround for this would be to modify the SL/TP in another function called if a Position field set in the OnPositionOpened is not null.
i.e.
Position _pos;
protected override void OnTick()
{
if (Trade.IsExecuting) return;
double targetPrice = Symbol.Ask + Symbol.PipSize;
if (Account.PendingOrders.Count == 0 && Account.Positions.Count == 0)
Trade.CreateBuyLimitOrder(Symbol, 1000, targetPrice, targetPrice - Symbol.PipSize, targetPrice + Symbol.PipSize, Server.Time.AddMinutes(10));
if (_pos != null)
{
// call method to modify SL/TP
Print("Stop Loss {0}", _pos.StopLoss);
Print("Take Profit {0}", _pos.TakeProfit);
}
}
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)
{
_pos = openedPosition;
}
@admin
admin
04 Jan 2013, 11:05
Hello,
The example here is using the OnTick event but you may also use the OnBar instead.
protected override void OnTick()
{
if(X < previousBid)
{
//...
}
else if (X > previousOffer)
{
//...
}
previousBid = Symbol.Bid;
}
X and previousOffer are declared as fields and will be set according to your algorithm.
@admin
admin
04 Jan 2013, 10:52
Yes, please use
using System.Collections.Generic;
see this example: /forum/calgo-reference-samples/56
@admin


admin
09 Jan 2013, 15:58
Thank you for your suggestions. Could you please state where exactly only one open order is visible without scrolling?
We are aware of the issue of moving the t/p and s/l bands on the chart and are working on a solution for it.
@admin