if (Position.MarketPosition == MarketPosition.Flat && XYZ < 0) { EnterLongLimit(Convert.ToInt32(DefaultQuantity), GetCurrentBid(0), "Buy1"); SetProfitTarget("Buy1", CalculationMode.Percent, PT1); CandleOutlineBrush = Brushes.CornflowerBlue; } if (Position.MarketPosition == MarketPosition.Long) { if (Close[0] > Position.AveragePrice * (1+ Target1)) { EnterLongLimit(Convert.ToInt32(DefaultQuantity), GetCurrentBid(0), "Buy2"); SetProfitTarget("Buy2", CalculationMode.Percent, PT2); }
I'm trying to "average up." If close > (buy1.averagePrice + X) {enter long}.
The above code works, but it seems because buy2 condition is true even when my buy1 position is flat because my profit target for buy1 got him.
Because of the condition "if market is long" enterlong; it causes it to be true even when buy1 is flat. How can I code so that buy2 condition is:
if market is long and buy1 position is not flat {enter long}?
I lookedup iorder but that's only for n7, and the current suggestion for n8 seemed confusing. Would appreciate a sample code! Thanks
Again, i'm trying to check to see if my intial buy1 position is flat or live so that I can include that condition in my second argument for buy2.
Comment