Hello everyone and @Tomasz
I am trying to get a better understanding of how the Volatile option works in the ApplyStop() formula so I can experiment with new things. However, before I do I like to understand the ins-and-outs. It's better to understand a formula perfectly before moving on.
First, I tried matching up points and percent without volatile and with these two match the trade list is exactly the same.
#1 → ApplyStop(stopTypeProfit,stopModePercent,5,1,0);
#2 → ApplyStop(stopTypeProfit,stopModePoint,BuyPrice*0.05,1,0);
After that I tried using a "dummy" volatile to match the orders above... the idea is to keep the stop the same at execution price plus 5%... I know it's the same, just trying to understand the inner-works to build on that knowledge to improve my strategies.
#3 → ApplyStop(stopTypeProfit,stopModePoint,IIf(Ref(Buy,-1),Open*0.05,BuyPrice*0.05),1,1);
#4 → ApplyStop(stopTypeProfit,stopModePoint,IIf(Buy,Open*0.05,BuyPrice*0.05),1,1);
However #3 or #4 don't match with #1 and #2... would you be able to explain what I am doing wrong in this case? I would like to understand this exactly before I move on to more elaborate things with the Volatile option. Thank you for the help!
I also tried using ValueWhen() just in case... but again different that #1 #2 and #3 #4
This is the code
I used QQQ from 1-1-2010 → 12-31-2023 for testing
SetOption("ActivateStopsImmediately",True);
SetOption("AllowSameBarExit",True);
SetPositionSize(100,spsPercentOfEquity);
SetTradeDelays(1,1,1,1);
Short=Cover=False;
Buy=Cross(RSI(10),50);
BuyPrice=Open;
Sell=False;
SellPrice=False;
// uncomment below one at a time
//ApplyStop(stopTypeProfit,stopModePercent,5,1,0);
//ApplyStop(stopTypeProfit,stopModePoint,BuyPrice*0.05,1,0);
//ApplyStop(stopTypeProfit,stopModePoint,IIf(Ref(Buy,-1),Open*0.05,BuyPrice*0.05),1,True);
//ApplyStop(stopTypeProfit,stopModePoint,IIf(Buy,Open*0.05,BuyPrice*0.05),1,True);
//ApplyStop(stopTypeProfit,stopModePoint,IIf(Buy,Open*0.05,ValueWhen(Buy,Open*0.05)),1,1);
//ApplyStop(stopTypeProfit,stopModePoint,IIf(Ref(Buy,-1),Open*0.05,ValueWhen(Ref(Buy,-1),Open*0.05)),1,1);