Overall Statistics Total Trades 3 Average Win 0% Average Loss 0% Compounding Annual Return 0.000% Drawdown 0.000% Expectancy 0 Net Profit 0.000% Sharpe Ratio 0.57 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -49.178 Tracking Error 0 Treynor Ratio 0.142 Total Fees \$0.00
```namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Basic template algorithm simply initializes the date range and cash. This is a skeleton
/// framework you can use for designing an algorithm.
/// </summary>
public class BasicTemplateAlgorithm : QCAlgorithm
{
private Symbol _eurusd;
private RelativeStrengthIndex _rsi;
private DateTime startdate;
private DateTime enddate;
private OrderTicket order;
private OrderTicket limit;
private OrderTicket stop;

/// <summary>
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
/// </summary>
public override void Initialize()
{
startdate = new DateTime(2017,1,1);
enddate = new DateTime(2018,12,20);
SetStartDate(startdate);  //Set Start Date
SetEndDate(enddate);    //Set End Date
SetCash(100000);             //Set Strategy Cash
SetBrokerageModel(BrokerageName.OandaBrokerage);

var lot = Securities["EURUSD"].SymbolProperties.LotSize;

Debug("the lot size is "+ lot);

var orderQuantity = 20180.12m;
var order = Securities["EURUSD"].SymbolProperties.ContractMultiplier;

Debug("the order size is "+ Math.Round(orderQuantity/lot)*lot);

_eurusd = QuantConnect.Symbol.Create("EURUSD", SecurityType.Forex, Market.Oanda);
_rsi = RSI(_eurusd,14,MovingAverageType.Wilders,Resolution.Hour);
}

/// <summary>
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
/// </summary>
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
public override void OnData(Slice data)
{
return;
}
QuoteBar quote = data[_eurusd];
Decimal price = quote.Close;
Log(_rsi +" "+ price);
return;
}
decimal p =  1.001m;
if (_rsi <= 30 && _rsi >= 25){
decimal limit = price+0.0046m;
decimal stop = price-0.0050m;
order = MarketOrder(_eurusd,1,false);
//Log("the price is " + price);
//Log("the limit is "+ limit);
//Log("the stop is "+ stop);
//Console.WriteLine("limit: "+limit);
//Console.WriteLine("stop: "+stop);
this.limit = LimitOrder(_eurusd,1,limit);
this.stop = StopMarketOrder(_eurusd,1,stop);
//LimitOrder(_eurusd,1,limit);
}
if (_rsi >= 70 && _rsi <= 75){
decimal limit = price-0.0046m;
decimal stop = price+0.0050m;
//Log("the direction is Sell");
//Log("the price is "+ price);
//Log("the limit is "+ limit);
//Log("the stop is "+ stop);
order = MarketOrder(_eurusd,1,false);
this.limit = LimitOrder(_eurusd,1,limit);
this.stop = StopMarketOrder(_eurusd,1,stop);
//Log("The orderid for market order is "+ order.OrderId);
//Log("the order id for limit order is "+ this.limit.OrderId);
//Log("the order id for stop order is "+ this.stop.OrderId);
}
}

public override void OnOrderEvent(OrderEvent orderevent){
//return;
//Log("OrderEvent occured");
//Log("OrderEvent Status " + orderevent.Status);
//Log("The Order Id is " + orderevent.OrderId);
if (orderevent.OrderId == 2){
if (orderevent.Status != null){
if (orderevent.Status == OrderStatus.Filled){
Transactions.CancelOrder(1);
Transactions.CancelOrder(2);
Transactions.CancelOrder(3);
}
}
}
//Log("OrderStatus marketorder" + order.Status);
//Log("OrderStatus limitorder" + limit.Status);
//Log("OrderStatus stoporder" + stop.Status);
//Console.WriteLine("an order event happened");
//Console.WriteLine("the order status: "+orderevent.Status);
//Console.WriteLine("the order fillprice "+orderevent.FillPrice);
/*if (orderevent.Status == OrderStatus.Filled){
order.Cancel();
}*/
}
}
}                        ```