Hi All,
I usually find what I look for or the solution to my problem, but I getting a headache searching or working on the small problem. This is my first asking/posting for help.
When trading or scalping, I usually focus on the current candle. I thought it would be easier if I see a live/real-time bubble on the current candle with the price, p/l, and my target percent gain/exit in mind. I also added a momentum indicator that would help me exit and determine to stay long. The bubble turns green if buy and red if sell on the last trade sale. I am happy with it and it does help.
Now, my issue is the pisky "N/A". This only shows on the percent column when I do not own the position. The data is filled when I own the position. Can someone give me some ideas to fix or solutions for my issue, please?
Below is my code for P/L and some screenshots. If you have any questions, let me know. Thank you in advance.
I usually find what I look for or the solution to my problem, but I getting a headache searching or working on the small problem. This is my first asking/posting for help.
When trading or scalping, I usually focus on the current candle. I thought it would be easier if I see a live/real-time bubble on the current candle with the price, p/l, and my target percent gain/exit in mind. I also added a momentum indicator that would help me exit and determine to stay long. The bubble turns green if buy and red if sell on the last trade sale. I am happy with it and it does help.
Now, my issue is the pisky "N/A". This only shows on the percent column when I do not own the position. The data is filled when I own the position. Can someone give me some ideas to fix or solutions for my issue, please?
Below is my code for P/L and some screenshots. If you have any questions, let me know. Thank you in advance.
Code:
# Label if Profiting or Losing
# cabe1332
def GetOpenPL = GetOpenPL();
def GetAveragePrice = GetAveragePrice();
def AvgPrice = if GetAveragePrice != 0 then close - GetAveragePrice else 0;
AddLabel(yes, " P/L: $ " + Round(GetOpenPL) + " | "
+ (round((AvgPrice/GetAveragePrice)*100,2) + " %") # This shows N/A if you don't own the position, want it to be 0.
, if GetOpenPL >= 0 then Color.green else Color.red);
Last edited by a moderator: