I have developed a custom strategy that uses SetProfitTrarget, SetTrailStop, EnterLong, EnterShort. It works ok but I cannot figure out how to mimic an ATM behavior e.g. add Profit trigger to auto trail and implement an Auto Breakeven. I am ok with changing the code approach without using SetProfit/SetTrail methods as long as I can mimic an ATM with auto trail and auto breakeven.
I would appreciate any help or pointer to a sample code.
Pseudocode:
OnBarUpdate()
{
.....
//Pseudocode
double p1ProfitTicks = (currentAtr * 40);
double p2ProfitTicks = (currentAtr * 60);
SetTrailStop(@"P1",CalculationMode.Ticks, p1TailStopTicks, false);
SetProfitTarget(@"P1", CalculationMode.Ticks, p1ProfitTicks);
if (long condition && Position.MarketPosition == MarketPosition.Flat)
{
EnterLong(1, @"P1");
}
if (short condition && Position.MarketPosition == MarketPosition.Flat)
{
EnterShort(1, @"P1");
}
.....
}
Thank you!
Comment