Basically I want to be able to have two completely separate positions within the same strategy, same contract, have brackets, and be able to scale in and out each of them.
Would it work? would setStopLoss&Target adapt to the change in contracts quantity?
Is there a fundamental error in this code that you may notice or the approach basically correct.
Thank you!.
G
Below is the basic structure of the would be code:
Assuming a code for Long Entry Only.
I am thinking to create a strategy based on this structure:
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
EntriesPerDirection = 2;
EntryHandling = EntryHandling.UniqueEntries; // Hope I am correct on this one
}
OnOrderUpdate()
{
SetStopLoss("trade1", CalculationMode.Ticks, (stop1 * tickSize_), false ) ;
SetStopLoss("trade2", CalculationMode.Ticks, (stop2 * tickSize_), false ) ;;
SetProfitTarget("trade1", CalculationMode.Ticks, (target1 * tickSize_));
SetProfitTarget("trade2", CalculationMode.Ticks, (target2 * tickSize_));
If (condition1_for_trade1) EnterLong(1, "trade1") ;
If (condition2_for_trade1) EnterLong(1, "trade1") ;
If (condition1_for_trade2) EnterLong(1, "trade2") ;
If (condition2_for_trade2) EnterLong(1, "trade2") ;
If (condition3_for_trade1) Exit(1, "trade2") ;
If (condition3_for_trade2) Exit(1, "trade2") ;
If (condition4_for_trade1) ExitLong("", "trade2") ;
If (condition4_for_trade2) ExitLong("", "trade2") ;
}

Comment