strategy profit splitted for long and short
Forums › ProRealTime English forum › ProOrder support › strategy profit splitted for long and short
- This topic has 5 replies, 2 voices, and was last updated 1 year ago by robertogozzi.
-
-
06/17/2023 at 11:56 AM #21638006/17/2023 at 3:58 PM #216388
Not tested:
Separate StrategyProfit for LONG and SHORT trades1234567891011121314151617181920212223242526272829ONCE LongStrategyProfit = 0ONCE ShortStrategyProfit = 0IF StrategyProfit <> StrategyProfit[1] THENEntryPrice = TradePrice[2]ExitPrice = TradePrice[2]Difference = StrategyProfit - StrategyProfit[1]IF LongOnMarket[1] THEN //LONG tradesLongStrategyProfit = LongStrategyProfit[1] + DifferenceELSIF ShortOnmarket[1] THEN //SHORT tradesShortStrategyProfit = ShortStrategyProfit[1] + DifferenceELSE //UNDEFINED trades for which both the Difference and the Entry and Exit prices need to be compared to determine the directionIF Difference > 0 THENIF ExitPrice > EntryPrice THENLongStrategyProfit = LongStrategyProfit[1] + Difference //when it's a PROFIT, a higher EXIT price implies a LONG tradeELSEShortStrategyProfit = ShortStrategyProfit[1] + Difference //when it's a PROFIT, a lower EXIT price implies a SHORT tradeENDIFELSEIF ExitPrice < EntryPrice THENLongStrategyProfit = LongStrategyProfit[1] + Difference //when it's a LOSS, a lower EXIT price implies a LONG tradeELSEShortStrategyProfit = ShortStrategyProfit[1] + Difference //when it's a LOSS, a higher EXIT price implies a SHORT tradeENDIFENDIFENDIFENDIFgraph LongStrategyProfit coloured("Green")graph ShortStrategyProfit coloured("Red")graph LongStrategyProfit + ShortStrategyProfit06/17/2023 at 4:02 PM #216389The last GRAPH should match the ProBacktest calculations, updated to the last closed trade.
06/17/2023 at 4:56 PM #21639206/17/2023 at 5:16 PM #216393Roberto,
I’d like to put it into a strategy and not just a graph or indicator.
I think that from your code is missing the second part, i.e. the one to use it as variable for deciding if increase or decrease the q.ty based on the previous success of the strategy.
06/17/2023 at 10:39 PM #216396That’s not meant for GRAPHING, that’s to have a single STRATEGYPROFIT split into LONG and SHORT data, so that you can decide how to use those split data. There are two variables, you can use them for what you need.
Isn’t that what you asked in your first post?
-
AuthorPosts
Find exclusive trading pro-tools on