ending a program-what to typeView all attachments
12/06/2017 at 5:32 PM #54906
Ive written a program but when i try to backtest it i get a message “syntax error line 35 character 1 please complete the syntax of this line ” but there’s nothing in line 35. what should I type there ?? The last line is the stoploss value. Please advise12/06/2017 at 6:12 PM #54908
Place your cursor after the last character of your strategy, then keep the DEL key pressed for a while, just in case there’s some garbage you can’t see!
Another way is to copy the whole strategy, from the first character to the last one, then cancel the strategy, then again paste it in a new strategy.
I don’t know if either works but it’s worth trying!
Roberto12/06/2017 at 8:55 PM #54917
I’ve done that but it still comes back with the same thing and there’s nothing on the line.
The previous line was the stoploss which was accepted by the syntax indicator on the left.
What is the last thing you guys write into your programs ??
As you can guess I am a complete newcomer to programming, I find it very interesting but
I just don’t understand this last bit. Also what are BBCodes ??
Regards Paul12/06/2017 at 10:21 PM #5492712/07/2017 at 12:51 AM #5493412/07/2017 at 10:30 AM #54951
Thanks Roberto and Vonasi that’s what I have done, so now it backtests but the result is nil over a year so it looks like I’ve screwed up somewhere. Wow, this is quite a learning curve. This is my first attempt (fail) can you see what’s wrong with it please
DEFPARAM CumulateOrders = False
DEFPARAM FlatBefore = 065000
DEFPARAM FlatAfter= 160000
// Conditions to enter long positions
if sto=20 then
if a then
BUY 1 CONTRACTS AT MARKET
// Conditions to exit long positions
if close CROSSES UNDER ema then
SELL AT MARKET
// Conditions to enter short positions
if sto=80 then
if a>average(close) then
SELLSHORT 1 CONTRACTS AT MARKET
// Conditions to exit short positions
if a>average(close) then
if sto=20 then
EXITSHORT AT MARKET
SET STOP $LOSS1012/07/2017 at 10:38 AM #54952
Your “if sto=20” and “if sto=80” will almost never happen, most of the time it will cross over or under those levels without ever being exactly equal to 20 or 80, so what’s inside your if statement wouldn’t be visited.
>> For clarity of messages on ProRealCode’s forums, please use the “<>” (insert PRT code) button in the message editor toolbar to separate the text of the code part! Thank you! <<12/07/2017 at 8:25 PM #55011
Thank you Nooywan, I have changed the symbol but it now seems to backtest but there is no result, only a flat line, and that’s over a year so I must still be doing something dire.
Is there a strict protocol for constructing a procedure ?
This PRT code doesnt seem to copy/paste too accurately, i will repeat in normal code if you wish.12345678910111213141516171819202122232425262728293031323334DEFPARAM CumulateOrders = FalseDEFPARAM FlatBefore = 065000DEFPARAM FlatAfter= 160000// Conditions to enter long positionssto=Stochastic[15,3](close)if sto<=20 thenma=Average(close)a=ma>maif a thenBUY 1 CONTRACTS AT MARKETENDIFENDIF// Conditions to exit long positionsema=ExponentialAverage(close)if close CROSSES UNDER ema thenSELL AT MARKETENDIF// Conditions to enter short positionsif sto>=80 thena=Average(close)if a>average(close) thenSELLSHORT 1 CONTRACTS AT MARKETENDIFENDIF// Conditions to exit short positionsif a>average(close) thenif sto<=20 thenEXITSHORT AT MARKETENDIFENDIFSET STOP $LOSS1012/07/2017 at 11:34 PM #5501712/08/2017 at 5:45 PM #55171
I have to modify it but ATT i’m having problems with the backtest. First it displayed just a flat line, but now every time I click on a share it goes through the backtest routine and has changed the graph from candlestick to line chart. It does this with every chart. How do I get it back to candlestick display and turn off this backtest routine. It must be here somewhere but I can’t find it.12/13/2017 at 8:59 PM #55606
When writing code , does it have to be presented in a certain sequence, could you please check this piece of a simple program and tell me what is wrong with it ?123456789101112131415161718192021222324252627DEFPARAM CumulateOrders = FalseDEFPARAM FlatBefore = 083000DEFPARAM FlatAfter= 200000// Conditions to enter long positionssto=Stochastic[15,3](close)ma=Average(close)if sto<=20 thena=ma>=maif a thenbuy 2 contracts at marketif sto>=78 thensell at marketSET STOP $LOSS15ma=Average(close)if sto>= 78 thena=ma<=maif a thenbuy 1 contracts at marketif sto<=20 thensell at marketSET STOP $LOSS15endifendifendifENDIFENDIFendif
I ran it against todays(13th) GBPCAD using 1000 units and 2 min timeframe.
Visibly I see strikes at 1138, out at 1156
1258, out at 1316, 1350 (loss), 1557 out at 1612, 1821 out at 1850
The backtest showed 1 strike which was not correct so am I writing the code in the wrong order? Please advise.12/13/2017 at 9:41 PM #55607123456789101112131415161718192021222324252627282930313233343536373839404142434445// Definition of code parametersDEFPARAM CumulateOrders = FalseDEFPARAM FlatBefore = 083000DEFPARAM FlatAfter= 200000// Conditions to enter long positionsindicator1 = Stochastic[15,3](close)c1 = (indicator1 <= 20)indicator2 = Average(close)indicator3 = Average(close)c2 = (indicator2 >= indicator3)IF c1 AND c2 THENBUY 2 CONTRACT AT MARKETENDIF// Conditions to exit long positionsindicator4 = Stochastic[15,3](close)c3 = (indicator4 >= 78)IF c3 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator5 = Stochastic[15,3](close)c4 = (indicator5 >= 78)indicator6 = Average(close)indicator7 = Average(close)c5 = (indicator6 <= indicator7)IF c4 AND c5 THENSELLSHORT 1 CONTRACT AT MARKETENDIF// Conditions to exit short positionsindicator8 = Stochastic[15,3](close)c6 = (indicator8 <= 20)IF c6 THENEXITSHORT AT MARKETENDIF// Stops and targetsSET STOP $LOSS 15
try this , i assume the second buy is a short given the parameters12/13/2017 at 10:22 PM #5561012/13/2017 at 10:28 PM #55614