How do i add multiple sell conditions

#1
Hi,
I have the following strategy for sell. Condition1 needs to occur first and then condition2

Condition1 : MACD bearish crossover in previous bar
Condition2: current bar Low is below previous bar low

Once condition1 is met then I don't care about condition1. Once Condition1
is met I am only concerned about Condition2 irrespective of whether condition1 is still true or not for the current bar.

When I write
Buy=condition1 and condition2;

Lets say on the 10thbar the macd bearish crossover happens but on 12 th bar again macd bullish crossover happen. Now on 12 th bar condition2 is met but condition1 is false so Sell is not triggered.

I want that once condition1 becomes true then the same is held till sell is triggered. Is this possible? I would prefer to not use loop ;)

Thankyou
 

mohan.sic

Well-Known Member
#2
Hi,
I have the following strategy for sell. Condition1 needs to occur first and then condition2

Condition1 : MACD bearish crossover in previous bar
Condition2: current bar Low is below previous bar low

Once condition1 is met then I don't care about condition1. Once Condition1
is met I am only concerned about Condition2 irrespective of whether condition1 is still true or not for the current bar.

When I write
Buy=condition1 and condition2;

Lets say on the 10thbar the macd bearish crossover happens but on 12 th bar again macd bullish crossover happen. Now on 12 th bar condition2 is met but condition1 is false so Sell is not triggered.

I want that once condition1 becomes true then the same is held till sell is triggered. Is this possible? I would prefer to not use loop ;)

Thankyou
I am novice in coding part but i think you should give some more details so that coding experts can help you.

Is it EOD or Intraday day
If intraday - is it continuous data or the data on your chart is limited to current day ?
 
#3
it is intraday. I have live data; that means data is continuous. Although I feel this has nothing to do with it.

Basically What i want is: Once bearish crosover occurs I want to ride the trade till the current price goes below the previous bar low. This is for riding the trend as long as possible.
 

mohan.sic

Well-Known Member
#4
Hi,
I have the following strategy for sell. Condition1 needs to occur first and then condition2

Condition1 : MACD bearish crossover in previous bar
Condition2: current bar Low is below previous bar low

Once condition1 is met then I don't care about condition1. Once Condition1
is met I am only concerned about Condition2 irrespective of whether condition1 is still true or not for the current bar.

When I write
Buy=condition1 and condition2;

Lets say on the 10thbar the macd bearish crossover happens but on 12 th bar again macd bullish crossover happen. Now on 12 th bar condition2 is met but condition1 is false so Sell is not triggered.

I want that once condition1 becomes true then the same is held till sell is triggered. Is this possible? I would prefer to not use loop ;)

Thankyou
When you have continous data ( more than current days data ), you will see many bearish crossover's. If you have 15 days 1 mt data on your chart, you may see the first bearish crossover on day 1. So your condition 1 is met on that day. How will that help you ..
 
#5
Lets say my condition is sell on bearish crossover. See I am just giving an example. See my original post. Condition1 is to be met. that mean bearish crossover. Then condition2 is to be met. that means the low of the bar should be below the previous bar low. The moment condition2 is met i SELL. After condition1 is met I don't care if condition1 is still true or not.
 

mohan.sic

Well-Known Member
#6
Lets say my condition is sell on bearish crossover. See I am just giving an example. See my original post. Condition1 is to be met. that mean bearish crossover. Then condition2 is to be met. that means the low of the bar should be below the previous bar low. The moment condition2 is met i SELL. After condition1 is met I don't care if condition1 is still true or not.
That is the problem...
See someone here will help you in that code but that wont serve your purpose.

Cond1: Lowest value of xxxx is less than zero ( for bearish crossover)

But what use would it be when you are using continuous data.
If you have 20 days data on chart and when you scan it, obviously cond 1 will be met...
 
#7
That is the problem...
Cond1: Lowest value of xxxx is less than zero ( for bearish crossover)
Why would it be zero? why can't it be 50 or 65?
I don't think you understand my requirement.

If lets say Condition1 is met at 65 then i want to trail till the price goes below the low of he previous bar. My strategy is very simple. I don't know how you are confused?
 

LOVEENAJYOTHI

Well-Known Member
#8
Hi,
I have the following strategy for sell. Condition1 needs to occur first and then condition2

Condition1 : MACD bearish crossover in previous bar
Condition2: current bar Low is below previous bar low

Once condition1 is met then I don't care about condition1. Once Condition1
is met I am only concerned about Condition2 irrespective of whether condition1 is still true or not for the current bar.

When I write
Buy=condition1 and condition2;

Lets say on the 10thbar the macd bearish crossover happens but on 12 th bar again macd bullish crossover happen. Now on 12 th bar condition2 is met but condition1 is false so Sell is not triggered.

I want that once condition1 becomes true then the same is held till sell is triggered. Is this possible? I would prefer to not use loop ;)

Thankyou
Hey,
Looks Like u need BarsSince function, smthng like,
Condtn1=ur MACD Condition
Condtn1TRUE=(BarsSince Condtn1 is met) >0
Condtn2=ur 2nd condition
Sell=Condn1TRUE & Condn2

Hope u get some idea to proceed further

Loveena
 

mohan.sic

Well-Known Member
#9
:mad:
Why would it be zero? why can't it be 50 or 65?
I don't think you understand my requirement.

If lets say Condition1 is met at 65 then i want to trail till the price goes below the low of he previous bar. My strategy is very simple. I don't know how you are confused?
Macd crossovers occur at zero line ....this is what I know...what is your understanding about macd crossover.
 

Similar threads