[CODE HELP] PSAR and supertrend indicator open position code

 

Hi everyone I try create a plain strategy using PSAR and supertrend indicator.

this is code for PSAR indicator.

if(sar(shift+1)>Bid && sar(shift)<Bid) >>>> BUY
if(sar(shift+1)<Bid && sar(shift)>Bid) >>>> SELL

this is code for supertrend indicator (indicator attached).

if(supertrendUP(shift+1)==EMPTY_VALUE && supertrendUP(shift)!=EMPTY_VALUE) >>>> BUY
if(supertrendDown(shift+1)==EMPTY_VALUE && supertrendDOWN(shift)!=EMPTY_VALUE) >>>> SELL

usually I work with line indicator like MA, MACD or stochastic and quite known how to open position (like crossover or crossing over). This is my first time trying to open position using these indicator. Does my code isn't a correct way to open a position with this indicator?

Files:
 

Don't double post! You already had another thread open.

          General rules and best pratices of the Forum. - General - MQL5 programming forum (2017)
using EMPTY_VALUE to open trade in supertrend indicator
using EMPTY_VALUE to open trade in supertrend indicator
  • 2021.10.21
  • www.mql5.com
Hi everyone, I've a strategy using a supertrend indicator. This supertrend indicator have 2 buffer which is supertrend up and supertrend down...