Course Name: Trading using Options Sentiment Indicators, Section No: 3, Unit No: 12, Unit type: WaterMarkVideo
Hi team,
How profit is calculated on PCR based sentiment indicator seems to be flawed under if…elif block ? Can you please double check logic , it seems profit at some place is calculated otherway around then it should have been. Thanks so much. I am talking above profit calcualtion in code below.
if (UBB_cross and (not buy_flag) and flag ==1): #…places “BUY” oPCR crosses upper bollinger band to open a trade
flag = 0
buy_flag = True
sell_flag = False
transaction_start_price = future_cost #…price at which S&P 500 future bought when order is placed
order_details = [1,“Buy” , “UBB crossed” , “0” , “position taken”]
elif (LBB_cross and (not sell_flag) and flag ==1): #.......places "SELL" order if PCR crosses lower bollinger band to open a trade
flag = 0
sell_flag = True
buy_flag = False
transaction_start_price = future_cost
order_details = [-1,"Sell" , "LBB crossed" , "0" , "position taken"]
elif (mAvg_cross_up and flag==0 and (not buy_flag)) : #........places "BUY" order if PCR crosses mAvg from low to high to close a trade
flag = 1
buy_flag = False
sell_flag = False
pro = future_cost -transaction_start_price
order_details = [1,"Buy" , "mAvg crossed" , "0" , "position closed"]
elif( LSL_cross and flag == 0 and (not buy_flag)):#......places "BUY" order if PCR crosses lower stoploss band to close a trade
flag = 1
buy_flag = False
sell_flag = False
pro = future_cost - transaction_start_price
order_details = [1,"Buy" , "LSB crossed" , "stoploss executed" , "position closed"]
elif( (future_cost - transaction_start_price) > abs_SL and flag == 0 and (not buy_flag)):#......places "BUY " order if PCR crosses lower stoploss absolute value
flag = 1
buy_flag = False
sell_flag = False
pro = future_cost - transaction_start_price
order_details = [1,"Buy" , "LSB crossed" , "stoploss executed abs" , "position closed"]
elif (mAvg_cross_down and flag==0 and (not sell_flag)):#.....places "SELL" order if PCR crosses mAvg from high to low to close a trade
flag = 1
sell_flag = False
buy_flag = False
pro = -(Data['future'][i] - transaction_start_price)
order_details = [-1,"Sell" , "mAvg crossed (h to l)" , "0" , "position closed"]
elif(USL_cross and flag==0 and (not sell_flag)):# ..places "SELL" order if PCR crosses upper stoploss band to close a trade
flag = 1
sell_flag = False
buy_flag = False
pro = -(Data['future'][i] - transaction_start_price)
order_details = [-1,"Sell" , "USB crossed" , "stoploss executed" , "position closed"]
elif((-future_cost + transaction_start_price) > abs_SL and flag==0 and (not sell_flag)):# ..places "SELL" order if PCR crosses upper stoploss absolute value
flag = 1
sell_flag = False
buy_flag = False
pro = -(Data['future'][i] - transaction_start_price)
order_details = [-1,"Sell" , "USB crossed" , "stoploss executed_abs" , "position closed"]