strategy profit splitted for long and short
- This topic has 5 replies, 2 voices, and was last updated 1 year ago by .
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
Similar topics:
Forums › ProRealTime English forum › ProOrder support › strategy profit splitted for long and short
Not tested:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
ONCE LongStrategyProfit = 0 ONCE ShortStrategyProfit = 0 IF StrategyProfit <> StrategyProfit[1] THEN EntryPrice = TradePrice[2] ExitPrice = TradePrice[2] Difference = StrategyProfit - StrategyProfit[1] IF LongOnMarket[1] THEN //LONG trades LongStrategyProfit = LongStrategyProfit[1] + Difference ELSIF ShortOnmarket[1] THEN //SHORT trades ShortStrategyProfit = ShortStrategyProfit[1] + Difference ELSE //UNDEFINED trades for which both the Difference and the Entry and Exit prices need to be compared to determine the direction IF Difference > 0 THEN IF ExitPrice > EntryPrice THEN LongStrategyProfit = LongStrategyProfit[1] + Difference //when it's a PROFIT, a higher EXIT price implies a LONG trade ELSE ShortStrategyProfit = ShortStrategyProfit[1] + Difference //when it's a PROFIT, a lower EXIT price implies a SHORT trade ENDIF ELSE IF ExitPrice < EntryPrice THEN LongStrategyProfit = LongStrategyProfit[1] + Difference //when it's a LOSS, a lower EXIT price implies a LONG trade ELSE ShortStrategyProfit = ShortStrategyProfit[1] + Difference //when it's a LOSS, a higher EXIT price implies a SHORT trade ENDIF ENDIF ENDIF ENDIF graph LongStrategyProfit coloured("Green") graph ShortStrategyProfit coloured("Red") graph LongStrategyProfit + ShortStrategyProfit |
The last GRAPH should match the ProBacktest calculations, updated to the last closed trade.
Roberto,
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.
That’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?
Find exclusive trading pro-tools on