Skip to content
Advertisement

How to set condition rules

I have coded this buy/sell strategy in Pine Editor/TradingView:

JavaScript

While in a long or short position, it changes position when opposite condition become true, but i want it to keep in position until it hits profit or stop loss. Then it can enter any position that fits again. How can i code this rule?

Advertisement

Answer

Maybe you want to replace your:

JavaScript

by:

JavaScript

When you create buy_condition, it compute the result at this moment, not later. So if a<b at this line, it will always be True later.

If you pass those functions to your strategy.exit method, you have to call the function with somethink like by_condition(a, b).

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement