I have the following code which enters a short trade and sets an integer "stopShort" at the time of entering the trade.
I then want to use "stopShort" in a later if formula. Basically so I don't keep re-writing the calculation of "stopShort" i.e. Math.Max.............. because it's ugly and I'm sure it's not the most efficient way.
Only problem is, it won't let me do this- error definition highlights I'm creating a conflict with the earlier definition.
Any idea how I can do this? Just trying to be more efficient with the code. I can only define stopShort at the part where I enter the trade, I can't do it earlier like in the State.Historical part (at least I didn't think I could!)
Thanks!
// OPEN: Look for a retest of structure
if (
Conditions are met
)
{
int stopShort=Math.Max(150,((Convert.ToInt32(Math.Roun d((MAXHigh,BarCountOverbought)[0]-Close[0])/TickSize)))+AvTR));
EnterShort "GoShort");
RolA=true;
}
In the next part of the formula
if (RolA && Close[0]<Position.AveragePrice-(1*TickSize*StopShort)
{
Move the stop loss to a new level
}
Comment