How to read the FloatingPL indicator

Englewood85

New member
I'm using the built-in Stochastic strategy on the USD/GBP. I'm displaying the 1 hour chart. Here is the strategy's code:

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2013-2020
#

input priceH = high;
input priceL = low;
input priceC = close;
input kPeriod = 10;
input slowing_period = 3;
input over_bought = 80;
input over_sold = 20;
input averageType = AverageType.SIMPLE;

def fullK = reference StochasticFull("k period" = kPeriod, "price h" = priceH, "price l" = priceL, "price c" = priceC, "slowing period" = slowing_period, "average type" = averageType).FullK;

AddOrder(OrderType.BUY_AUTO, fullK crosses above over_sold, tickColor = GetColor(8), arrowColor = GetColor(8), name = "StochasticLE");
AddOrder(OrderType.SELL_AUTO, fullK crosses below over_bought, tickColor = GetColor(6), arrowColor = GetColor(6), name = "StochasticSE");

I also have the FloatingPL indicator displayed on the lower graph.

1. Some bars are light green, some are dark green. What does this signify?
2. On 09/15 at 9:00 AM, there is a sell signal. On 09/17 at 2:00 AM, there is a buy signal.
a. Is the 09/15 sell signal a sell to open or sell to close? How can you tell?
b. If the 09/15 signal is sell to open, how can there be green FloatingPL bars all the way until the 09/17 buy signal? During most of that time, the price is
higher than the 09/15 sell price, which means most of the FloatingPL bars should be red right?
c. If the 09/15 signal is sell to close, this means that there is no open position between 09/15 thru 09/17, which means there shouldn't be green or red
FloatingPL bars, but there are green bars (light and dark) present. How can this be?
 

BenTen

Administrative
Staff
VIP
Since you're new to backtesting strategy, the easiest way to read the signals and its P/L report is to separate buying (go long) and shorting (going short) into two different strategies.

Go long (buy to open and sell to close)

Code:
AddOrder(OrderType.BUY_TO_OPEN, fullK crosses above over_sold, tickColor = GetColor(8), arrowColor = GetColor(8), name = "StochasticLE");
AddOrder(OrderType.SELL_TO_CLOSE, fullK crosses below over_bought, tickColor = GetColor(6), arrowColor = GetColor(6), name = "StochasticSE");

Go short (sell to open and buy to close)

Code:
AddOrder(OrderType.Sell_TO_OPEN, fullK crosses above over_sold, tickColor = GetColor(8), arrowColor = GetColor(8), name = "StochasticLE");
AddOrder(OrderType.Buy_TO_CLOSE, fullK crosses below over_bought, tickColor = GetColor(6), arrowColor = GetColor(6), name = "StochasticSE");

I hope that helps.
 

Englewood85

New member
@BenTen I tried your suggestion many times and I get the same exact performance report in each case. I tried this with EUR/USD. I changed to a new currency, then back to EUR/USD to refresh the chart just to be sure. I still get the same result using both types of code. Is there a refresh button that you're supposed to click? I noticed how the orders are opposite and I did enter it correctly.

I don't know what I'm overlooking.
 

BenTen

Administrative
Staff
VIP
@Englewood85 I just notice the conditions for buy and sell are the same for both scenarios. That is why the P/L reports are the same.

This should be the correct code for your short strategy.

Code:
AddOrder(OrderType.Sell_TO_OPEN, fullK crosses above over_bought, tickColor = GetColor(8), arrowColor = GetColor(8), name = "STO");
AddOrder(OrderType.Buy_TO_CLOSE, fullK crosses below over_sold, tickColor = GetColor(6), arrowColor = GetColor(6), name = "BTC");
 

Englewood85

New member
Thank you. Here is my code now. This is not showing up on my chart for some reason.

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2013-2020
#

input priceH = high;
input priceL = low;
input priceC = close;
input kPeriod = 10;
input slowing_period = 3;
input over_bought = 80;
input over_sold = 20;
input averageType = AverageType.SIMPLE;

def fullK = reference StochasticFull("k period" = kPeriod, "price h" = priceH, "price l" = priceL, "price c" = priceC, "slowing period" = slowing_period, "average type" = averageType).FullK;


AddOrder(OrderType.BUY_TO_OPEN, fullK crosses above over_sold, tickColor = GetColor(8), arrowColor = GetColor(8), name = "BTC");
AddOrder(OrderType.SELL_TO_CLOSE, fullK crosses below over_bought, tickColor = GetColor(6), arrowColor = GetColor(6), name = "STO");

#AddOrder(OrderType.Sell_TO_OPEN, fullK crosses above over_bought, tickColor = GetColor(8), arrowColor = GetColor(8), name = "STO");
#AddOrder(OrderType.Buy_TO_CLOSE, fullK crosses below over_sold, tickColor = GetColor(6), arrowColor = GetColor(6), name = "BTC");
 

Englewood85

New member
As far as I can tell, I do have it as a strategy. I used the same method with another strategy and that other one worked. The difference between a study and a strategy is the presence of the AddOrder( ) right? Just to be sure, what steps are you taking to add this as a strategy and not a study?
 

BenTen

Administrative
Staff
VIP
@Englewood85 Correct. I added it as a strategy and it works for me.

UlMAEIl.png
 

Englewood85

New member
That was the mistake I was making. Your picture helped. Thank you for posting that. I was able to download performance reports. I downloaded AUTO, Buy to Open and Sell to Open. I am trying to reconcile the BTO and STO tabs with the AUTO tab.

On the EUR/USD 1 hour chart, I am trying to make sense out of the trades from 09.15.2020 - 09.17.2020.

1. For the BTO trades on these dates, I can locate them on the AUTO tab.
2. I am unable to identify a single STO trade between these dates on the AUTO tab.
3. On the AUTO tab between these dates, there are trades that I can't make sense out of.
4. I understand the Trade P/L column, but I can't make sense out of how the P/L column is calculated either.

I can't find adequate documentation that would answer my questions. Can you offer any insight into this and/or direct me to any good sources?
 

Similar threads

Top