I think I may be close but on back tests is only entering the primary pair and not the secondary (it should enter both at the same time and exit both at the same time). It does seem to be exiting when the profit target is achieved but im not sure if it will work when both pairs are entered properly.
If anyone can look at the following and give some tips I would really apprieciat it.
Please excuse my ignorance, this is my first try at this.
Thank You,
#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
#endregion
///<summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
///</summary>
protectedoverridevoid Initialize()
{
// Add an $USDCHF 2 minute Bars object to the strategy
Add("$USDCHF", PeriodType.Minute, 2);
// Note: Bars are added to the BarsArray and can be accessed via an index value
// E.G. BarsArray[1] ---> Accesses the 1 minute Bars added above
// Add ZeroLagStochs indicator to the chart for display
// This only displays the indicator for the pimary Bars object (main instrument) on the chart
Add(ZeroLagStochs());
CalculateOnBarClose = true;
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
// OnBarUpdate() will be called on incoming tick events on all Bars objects added to the strategy
// We only want to process events on our primary Bars object (main instrument) (index = 0) which
// is set when adding the strategy to a chart
if (BarsInProgress != 0)
return;
// Condition set 1
if (CrossAbove(ZeroLagStochs().Mov, 75, 1))
{
//Submits buy market order for EURUSD
EnterLong(100000, "long");
//Submits buy market order for USDCHF
EnterLong(120000, "BUY $USDCHF");
}
// Condition set 2
if (Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) >= 200)
{
//Exits EURUSD long position when total unrealized P&L reaches $200.00
ExitLong("", "long");
//Exit CHF
ExitLong("", "Buy $USDCHF");
}
}
#region Properties
#endregion
}
}
Comment