GRAPH Close returns wrong value
Forums › ProRealTime English forum › ProRealTime platform support › GRAPH Close returns wrong value
- This topic has 14 replies, 3 voices, and was last updated 6 years ago by Vonasi.
-
-
01/12/2018 at 12:34 AM #59130
I was working on a strategy on a 30 minute chart and was using ‘GRAPH close’ along with graphing of one other value but noticed that sometimes the graphed result of close was flat-lining when the close price in the main chart was still clearly moving.
Image attached. I have removed the other variable for clarity.
01/12/2018 at 8:57 AM #59139Maybe trading closed at that time for that instrument?
01/12/2018 at 10:43 AM #5915101/12/2018 at 11:08 AM #5915801/12/2018 at 11:51 AM #59164Very last line.
I did have some IF THEN conditions above it for calculating other graph lines but I have even removed them completely and just left GRAPH close at the very end of the code and I still get bit flat lines all over the place. Image attached.
01/12/2018 at 11:56 AM #5916601/12/2018 at 12:10 PM #59171I have zoomed in and I now can see that the close stops graphing always when in a trade (not at the close of it as I first thought) and then does not start again until a new trade is opened. GRAPH is the very last line in the code and is not within any IF THEN.
01/12/2018 at 1:00 PM #5917501/12/2018 at 1:40 PM #59180Here’s the code. I was just playing around with one of Jebus’s rough codes and trialling out a different style of trailing stop. Sorry there are a lot of // in it due to all the trial and error stuff.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182// Created by JEBUS 05.01.2018//Modified by VonasiDEFPARAM CumulateOrders = falseHighATR = 3500Perc = 0.8//ATRDivi = 3//ATRMultiple = 6//ATR1 = AverageTrueRange[HighATR]//ATR2 = AverageTrueRange[HighATR/ATRDivi]//x = MIN(ATR1, ATR2)*ATRMultiplex = close * (perc/100)Capital = 10000Equity = Capital + StrategyProfitPositionSize = Max(1, Equity * (1/Capital))PositionSize = Round(PositionSize*100)PositionSize = PositionSize/100//PositionSize = 1//Entry Conditionsindicator1 = WilderAverage[6](close)indicator2 = TEMA[100](close)c1 = (indicator1 CROSSES OVER indicator2)indicator3 = WilderAverage[25](medianPrice)indicator4 = WilderAverage[50](medianPrice)c2 = (indicator3 < indicator4)IF Not OnMarket and c1 AND c2 and BarIndex > HighATR THENBUY PositionSize CONTRACT AT MARKETSL = Round(x)//TP = Round(x)ENDIFIF OnMarket and TotalPrice < TotalPrice[1] THENSL = SL - ((TotalPrice[1] - TotalPrice))//TP = TP - ((TotalPrice[1] - TotalPrice)*1)//ELSE//IF OnMarket and TotalPrice > TotalPrice[1] THEN//SL = SL + ((TotalPrice[1] - TotalPrice))//TP = TP + ((TotalPrice - TotalPrice[1]))//ENDIFENDIF// Conditions to exit long positionsindicator5 = WilderAverage[6](close)indicator6 = TEMA[100](close)c3 = (indicator5 CROSSES UNDER indicator6)IF c3 THENSELL AT MARKETENDIFIF SL = 0 THENSL = -1ENDIF//IF TP = 0 THEN//TP = -1//ENDIFSET Stop pLoss SL//SET Target pProfit TP//Graph CalculationsIF OnMarket THENSLG = positionprice - SL//TPG = tradeprice + TPELSEIF Not OnMarket THENSLG = close//TPG = closeENDIFENDIF//Graph TPG coloured(0,128,0)Graph SLG coloured(128,0,0)Graph Close01/12/2018 at 2:12 PM #5918301/12/2018 at 2:29 PM #59185Which leads us neatly onto my other post:
https://www.prorealcode.com/topic/set-stop-ploss-with-negative-value/
I’m a little confused as the code works fine as a trailing stop loss with a negative value for SET STOP pLOSS but you are saying that it stops GRAPH from displaying the correct CLOSE value?
01/12/2018 at 2:48 PM #59188It throws an error somewhere in the system that prevent everything else to compute correctly .. that’s how I interpret it. When something goes weird with ProBacktest, look first at variables values, it usually solves everything! 🙂
01/12/2018 at 3:06 PM #59191Sorry to take up so much of your precious time but I just want to clarify my understanding of SET STOP PLOSS.
I’m thinking that it sends a market order to close a trade at a stop level x pips below your PositionPrice. At the close of each candle you can change the value of x and it sends a new order. If for example candle close is at a price of 2000, your PositionPrice is at 1000 and you set a negative value of -500 as your STOP pLOSS then the stop order is set at 1500. This all seems to work fine when I run the code but the GRAPH function is completely confused by these values.
I guess at the end of the day I’ll just have to give up on my new find of SET STOP pLOSS with negative values and go back to SELL STOP orders which will achieve the same thing.
01/12/2018 at 3:14 PM #59193Even if you can code it, it doesn’t mean that the order will be accepted by the broker server. SET STOP is not meant to accept negative value.
Of course, the probacktest bug you encountered should not exist. I’ll send an email to IT Finance about it.
01/12/2018 at 3:27 PM #59195OK – good point. I have posted a question on the other thread at
https://www.prorealcode.com/topic/set-stop-ploss-with-negative-value/
Sorry to be jumping around!
-
AuthorPosts
Find exclusive trading pro-tools on