Zerocode closings

 

I want to make a strategy where they have different closing methods.

What I mean is for example when its a buy then to close the indiactor has to go from x>0 to x<=0 and if sell then x=0. My problem is that Im not sure where to input that. Should I just not put anything in the close and then go in the code and add the line manually?

Thanks in advance

 

This will need a little auto and also manual work.

1. Add logics as in attached screenshot.

2. Find in code

IsClosing = (IsBuying == True)
and (x <= 0)

3. Add parenthesis

IsClosing = ((IsBuying == True)
and (x <= 0))

4. Compile in MT editor. That's it

Files:
 

Wow thanks,

now I see you put for IsBuying, should I also add it to IsSelling as well or is it purposely left out?

 

Yes, you can, but it's the same for this case. In case you need to change something, you should wrap the logics belong to IsSelling as well.

 

I have another question, I am not sure if this will work but i will try after i post this. Can I put two:

AND IsBuying = True

AND x<=0

OR y<=0

OR Is Buying = True

AND x>=0

OR y>=0

Would this keep the y<=0 with the IsBuying or not?

Thanks

 

Hah I think I actually answered my own question, just put everything that works with IsBuying or IsSelling in that paranthesis. Sorry that was a mistake on my part I wasnt thinking too clearly.

Im going to test this right now.

Thanks again scorpion

 

Hi to one and all on this great site. Still wading around in the shallows just getting my feet wet as I try to find my way around and how to eat this big elephant one day at a time bit by bit. Just trying to draw trendlines and support and resistance lines and how to identify patterns.

Will be gratful if I can be pointed in the right direction.

Thanks!

Reason: