currentprice_MA crossover
Forums › ProRealTime English forum › ProBuilder support › currentprice_MA crossover
- This topic has 6 replies, 2 voices, and was last updated 4 years ago by robertogozzi.
Tagged: MA crossover
Viewing 7 posts - 1 through 7 (of 7 total)
-
-
11/09/2018 at 8:26 AM #84457price-ema cross_over12345678910111213141516171819202122// Conditions to enter long positionsindicator1 = Average[50](close)if (close crosses over indicator1) thenc2=0endifif (close crosses under indicator1) thenc2=0endifif close>=indicator1 thenc3= close-indicator1+c2endifif close<= indicator1 thenc3= -close+indicator1+c2endifreturn c311/09/2018 at 8:28 AM #8445911/09/2018 at 9:05 AM #84465
Lines 3 through 10 are useless, since you never assign C2 any value.
C3 is the distance between CLOSE and the indicator for that single bar.
If you want the distance from CLOSE and the crossover then you’ll have to save the value of the indicator, or its BarIndex, when the crossover occurs.
11/09/2018 at 9:27 AM #84468I have corrected the code
it works fine
12345678910// Conditions to enter long positionsindicator1 = Average[50](close)if (close crosses over indicator1) thenc2=indicator1endifif close>Average[50](close) thenc3=close-c2[1]endifreturn c311/09/2018 at 10:50 AM #84472Line 7 should reference c2 (not c2[1]), because when there is a crossover it would return the value of the previous crossover. From the candle following the crossover on it wouldn’t make any difference (despite it is logically wrong).
04/17/2020 at 7:51 AM #12646804/17/2020 at 8:49 AM #126481There you go:
12345678910111213141516// Conditions to enter long positionsindicator1 = Average[50](close)if (close crosses over indicator1) thenc2=indicator1MyBar = barindexendifif close>Average[50](close) thenc3=close-c2endifif c3 > 500*pipsize And (barindex - MyBar) > 5 thenMyBar = barindexc2=indicator1Elsec3 = 0endifreturn c3 -
AuthorPosts
Viewing 7 posts - 1 through 7 (of 7 total)
Find exclusive trading pro-tools on
Similar topics: