How put Stop loss in this afl code

Its option shorting: I want to put stop loss if the present candle closes over the value of shorting candle by 10 points.OR High - Low of shorting candle

Short = Cond SELL ;

if( SelectedValue( Short ) )
{
R1= C + ( H - L );
SLR= C > R1;
}

Cover = CondBUY OR SLR ;

HERE ERROR is coming as it is not able to recognise SLR value as not entering the loop.

Look at what you have coded.

SLR equals Close Bigger than R1

You could do something like SLR equals Close + R1 but not what you want to do.

Can't easily explain but the = can not go with a > this way.

ps: you can put your code in code blocks. Makes your question more readable. Maybe someone will come along to point you to the "how to ask a good question" thread... I have no idea where it is but you can find it probably.

@Sam1 , Do you have SLR declared or set earlier in the code? If it is just part of the "if" processing, it may not be defined, and therefore when "if" not processed the SLR value is undefined when you try to reference it.

Additionally, your "if" processing makes no logical sense (to me).
You set R1 to be Close Plus Something.
Then you TEST if Close is Greater than R1.
From my understanding, Close will NEVER be greater than Close (plus something - even if H=L, you are still testing Close > Close).

Why not?

= is assigning and == is equals to (condition) symbol.
So SLR=C>R1; => 1 if true, 0 if false and those values are assigned to SLR.

1 Like

Thanks Doubt.

What he is doing still always will be false so it is not usefull but for me, you learned me something :wink:

1 Like

You're welcome
Yes like @snoopy.pa30 mentioned already C can never be greater than C+something indeed.

BTW is that discord still active? i'm interested but couldn't get accepted.

PS sorry to go off topic but i have no other choice as PM is not possible for me.
EDIT; This post just made it possible so i will sent you PM lol

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.