How to use hedging with your pinescript strategy.

Hey guys,

So it's pretty common knowledge that you can't code your pinescripts to run both long and short trades on the same instrument, but with that being said, if you use hedging in your trading like I do it can be pretty frustrating when you can't do it with the strategy your using.

A quick work around that I've found and think you might find useful, and it's a hell of a lot more simple than you would think.


COPY AND PASTE YOUR STRATEGY.

So hopefully when you've created your strategy you have allowed it to take long and short trades, and there should be a little tick box in the strategy settings that can allow it to take one or the other or both. If you tick one to take shorts, and the other to take longs then your away.

If you don't have the tick boxes in the settings then the other way to do it which is slightly more complicated but still pretty simple is to remove the instruction in the pinescript itself, so you could remove the part of the code that tells it the conditions to take a long trade in one and remove the short conditions in the other.


In fairness Trading view do say that putting hedging into the system is something they have on their to-do list but it's obviously not a priority at the minute as this was said in the first quarter of 2021.

Hope this helps.
Beyond Technical Analysis

גם על:

כתב ויתור