Hello,
I know this seems like a stupid question...
I'm having some difficulties with the Applystop function. I'm trying to incorporate Stop Loss into my code instead of using the "Stops" tab in the Settings window. This is also because I want to use a Stop based on the ATR indicator.
I tried to use the Applystop function but I must be doing somethig wrong. So I created a simple MA crossover code with the exact same Applystop parameters I had on my original code to test it. And indeed it's not working, as it only exits a position if a contrary signal is found - hence it keeps inverting buy and sell positions instead of using a trailig StopLoss based on the ATR, as intended.
Could anyone please help?
W=EMA(C,20);
X=EMA(C,50);
Buy = Ref(W,-1)<Ref(X,-1) AND Ref(W,0)>Ref(X,0);
Sell = Ref(W,-1)>Ref(X,-1) AND Ref(W,0)<Ref(X,0);
Short = 0;
Cover = 0;
ApplyStop(stopTypeTrailing , stopModePoint, ATR(14), 1);
Thank you.
Best
Claudio