Hello all - I have an indicator that is working but i would like to enhance it a bit so that when the profit target from entry price is hit it will stop end.
This is a snippet of code that i'm struggling with how to make work.:
on the pos line for the BUY case, i need to somehow make it that ---else if low < LL[1] or high > ExitTGT then 0. ExitTgt is defined after the pos and EntryPr. EntrPr relies on pos to be defined first.
How can i make this work??
This is a snippet of code that i'm struggling with how to make work.:
Code:
plot entry;
plot exit;
def EntryPr;
def pos;
def co = BarNumber() > Max(SellExit, BuyExit);
def ExitTgt;
switch (BuyorSell) {
case Buy:
entry = QB[1];
exit = LL[1];
pos = if ST_UP and co and high > QB[1] then 1
else if low < LL[1] then 0
else pos[1];
EntryPr = if high > QB[1] and pos == 1 and pos[1] < 1
then QB[1]
else if pos == 0
then Double.NaN
else EntryPr[1];
ExitTgt = EntryPr + (TargetATRMult * 2 * mATR);
case Sell:
entry = QS[1];
exit = HH[1];
pos = if ST_DN and co and low < QS[1] then -1
else if high[1] > HH[2] then 0
else pos[1];
EntryPr = if low < QS[1] and pos == -1 and pos[1] > -1
then QS[1]
else if pos == 0
then Double.NaN
else EntryPr[1];
ExitTgt = EntryPr - (TargetATRMult * 2 * mATR);
on the pos line for the BUY case, i need to somehow make it that ---else if low < LL[1] or high > ExitTGT then 0. ExitTgt is defined after the pos and EntryPr. EntrPr relies on pos to be defined first.
How can i make this work??