Total Beginner
Forums › ProRealTime English forum › ProOrder support › Total Beginner
- This topic has 38 replies, 6 voices, and was last updated 3 years ago by
GraHal.
-
-
10/06/2022 at 9:59 AM #201986
Hi
I am not sure in what TF you let it run. I get much poorer result than you 🙁
I also have another question and I can’t find the ‘thinking’ error I am doing (blond after all! LOL)
The below code opens at random positions although price has moved far away from EMA20. I tried the comands great than and lesser than but the results are not good either.
Appreciate you taking time to help me out.
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
DEFPARAM FLATBEFORE = 083000
DEFPARAM FLATAFTER = 220000// Conditions to enter long positions
indicator1 = ExponentialAverage[20](close)
c1 = (close crosses over indicator1)IF c1 THEN
BUY 0.5 CONTRACT AT MARKET
ENDIF// Conditions to exit long positions
indicator2 = ExponentialAverage[20](close)
c2 = (close CROSSES UNDER indicator1)IF c2 THEN
SELL AT MARKET
ENDIF
SET STOP TRAILING 10// Conditions to enter short positions
indicator1 = ExponentialAverage[20](close)
c3 = (close crosses under indicator1)IF c3 THEN
SELLSHORT 0.5 CONTRACT AT MARKET
ENDIF// Conditions to exit short positions
indicator2 = ExponentialAverage[20](close)
c4 = (close CROSSES OVER indicator1)IF c4 THEN
EXITSHORT AT MARKET
ENDIF
SET STOP TRAILING 1010/06/2022 at 10:02 AM #20199010/06/2022 at 10:09 AM #20199210/06/2022 at 11:32 AM #202001Hi
I try to reduce the variables as much as possible to get a really simple system working.
However when I let the code below run, it always opens random short positions for me, instead of having just one since early morning. I know the issue is with the entry condition c1 and c2, which I have defined as crossing over/under, but for some reason the code then opens random positions that are below indicator1 and have not fullfilled the conditon of crossing. I know there is a fault in my thinking and I can’t figure it out. Greatly appreciate your help! Thanks in advance
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
DEFPARAM FLATBEFORE = 083000
DEFPARAM FLATAFTER = 220000// Conditions to enter long positions
indicator1 = ExponentialAverage[20](close)
c1 = (close crosses over indicator1)IF c1 THEN
BUY 0.5 CONTRACT AT MARKET
ENDIF// Conditions to exit long positions
indicator1 = ExponentialAverage[20](close)
c2 = (close < indicator1)IF c2 THEN
SELL AT MARKET
ENDIF
SET STOP TRAILING 10// Conditions to enter short positions
indicator1 = ExponentialAverage[20](close)
c3 = (close crosses under indicator1)IF c3 THEN
SELLSHORT 0.5 CONTRACT AT MARKET
ENDIF// Conditions to exit short positions
indicator2 = ExponentialAverage[20](close)
c4 = (close > indicator1)IF c4 THEN
EXITSHORT AT MARKET
ENDIF
SET STOP TRAILING 1010/06/2022 at 12:19 PM #202004You don’t say in the post above an Instrument or Timeframe.
Anyway I got attached curve with attached .itf (Note attached is on 1K bars only for quickness in optimising for me. A12, A13 are variables in the optimiser … my quick way of id notation)
It may help motivation and understanding if you see a profit developing … I know it does with me!! 🙂
Import the .itf into your Algo area of platform.
1 user thanked author for this post.
10/06/2022 at 12:58 PM #202007it always opens random short positions for me
By random do you mean NOT when crosses under occurs?
If you insert below in your code you can see when C3 = True / 1
IF c3 THEN
SELLSHORT 0.5 CONTRACT AT MARKET
ENDIFGRAPH C3
1 user thanked author for this post.
10/06/2022 at 1:35 PM #202008Thank you very much. I know that I need to clearly define as the only short scenario the bar crossing over the indicator.
I tried your idea but I couldn’t make it work.
Appreciate your help. Looks like this system would work nicely once this fault is eliminated.
10/06/2022 at 1:38 PM #202010I still can’t get it to work with only one indicator and such a simple strategy. What am I missing? I know the error is somewhere in the definition of crossing over or under but how can I define this precise? I tried with close [0] open [0] and close [1] none did eliminate the mistake.
Thank you very much.
10/06/2022 at 2:09 PM #202011Code on your screen shot above is not replicating what I specified using GRAPH
https://www.prorealcode.com/documentation/graph/
10/06/2022 at 2:16 PM #202012I know the error is somewhere in the definition of crossing over or under
No … as seen by my .itf I provided … which is why I posted the .itf to show that the crossing over / under can and does work.
It’s more your original strategy – re Sell and ExitShort – that are not working … if we cross under EA20 then chances are we might – for a while – get whipsawed out again due to price > EA 20.
Above is why I rem’d out your Sell and Exitshort conditions in your original strategy.
1 user thanked author for this post.
10/06/2022 at 2:26 PM #202014I still can’t get it to work
What do you mean by “get it to work”?
If you mean get your code to do what the code states it should do? Then by using GRAPH you can analyse what it is doing and when etc.
If you mean … doesn’t make profit, then my comments in my previous post above are more relevant.
(Do not go Live with REAL money and any Algo until tested in Demo Account for > min of 50 trades and 1 month; preferable 100’s of trades and 6 to 12 months in Demo! 🙁 )
1 user thanked author for this post.
10/06/2022 at 2:46 PM #202015Trader Sab, change that line of code (see attachment) into :
1If C3 = True then // 1That will avoid that error. It is just a syntax error.
1 user thanked author for this post.
10/06/2022 at 9:23 PM #202030@GraHal
Good evening
Thanks for the improved code and I run the new code on DJI with 1k on 5 min chart, however I got a dismal result. I am not sure why back testing can give such different results with on the same instrument when performed at different times.
In the code with only the EMA20 as signal line, I tried to work with your suggestion but it returns an error message. I figured out that I need to define the crossing candle differently to set it apart from the other candles that open below the EMA20. However non of the candles that opened positions after the initial crossing fulfilled the close crosses over/ under EMA20 but the system still opened the position
I truly appreciate your help, I am a bit lost but enjoy the learning tremendously.
Have a great evening
10/06/2022 at 9:28 PM #202035Well I tried your suggestion but it still returns an error.
I know I have to define that only the first candle is the signal to open a new position but I am not sure how to do this.
Thank you so much for your help
10/06/2022 at 11:36 PM #202040 -
AuthorPosts
Find exclusive trading pro-tools on