Hello,
I am trying to create a loop for my stops. I found a lot of good
examples in the previous postings.
The "j" loop works well without adding the "k" loop.
The idea is to have the stop moved at breakeven when the market moves
in my favor.
The idea is simple. One fixed stoploss point, one profit target point
and stoploss point moved after a certain profit.
I would appreciate any suggestions.
In other words - How do I escape from loop k and go back to loop j?
(I don't know if yahoo will let me keep the formating)
for (i = 1; i < BarCount; i++)
{
if (EntryLongSignal[ i ])
{
Buy[ i ] = 1;
BuyPrice[ i ] = O[ i ];
for (j = i + 1; j < BarCount; j++)
{
if (L[ j ] <= (BuyPrice[ i ]-StopLoss))
{
Sell[ j ] = 1;
SellPrice[ j ] = BuyPrice[ i ]-StopLoss;
i = j;
j = BarCount;
}
else if (H[ j ] >= (BuyPrice[ i ] +
BreakevenMove))
{
for (k = j + 1; k < BarCount; k++)
{
if (L [ k ] <= BuyPrice [ i ] + 0.0002)
{
Sell[ k ] = 1;
SellPrice[ k ] = BuyPrice[ i ];
j = k;
k = BarCount;
}
else if (H[ k ] >= BuyPrice[ i ] +
TakeProfit)
{
Sell[ k ] = 1;
SellPrice[ k ] = BuyPrice[ i ] +
TakeProfit;
j = k;
k = BarCount;
}
}
}
else if (ExitLongPosition[ j ])
{
Sell[ j ] = 1;
SellPrice[ j ] = O[ j ];
i = j;
j = BarCount;
}
else if (j == BarCount - 1)
{
Buy[ i ] = 0;
i = BarCount;
}
}
}
}