Completely new to coding so started a simple test program got error msg to go to prorealcode but thats too complex. Advice welcome
// Conditions to enter long positions
DEFPARAM CumulateOrders = False
DEFPARAM FlatBefore = 065000
DEFPARAM FlatAfter= 203000
mm=ExponentialAverage[20](close)
if mm>mm[1]then
BUY 100 SHARES AT MARKET
SET STOP $LOSS10
endif
AT line 12 leave a blank between LOSS and 10.
Thank you Roberto, one more question… how do I code the stochastic %K passing through %D
cyrillic – I have moved your topic. You posted it in the ‘Welcome New Members’ forum and it is a strategy question so I have moved it to the ProOrder forum. Please try to post in the correct forum with any future topics.
There you go:
// Stochastic(8,4,3)
StocK = Stochastic[8,4](close)
StocD = Average[3,0](StocK)
x = StocK CROSSES OVER StocD //Crossing OVER
y = StocK CROSSES UNDER StocD //Crossing UNDER
Thank you Roberto…..
Also… If I wanted no buy/sell action to be taken until two or more commands
have been completed, would I use several “if” command lines and where would the command
“and” be put ??
Is this what you mean …
If condA AND condB AND condC Then
Buy at Market
Endif
Thanks GraHal ……….. Does the command need to be in one long string ?
Everything seems to need to be just so or it bites you.. great when you know the exact format.
Does the command need to be in one long string ?
Yes, but you can do same / similar to below.
The auto-syntax checker is very good if you make a mistake it will let you know when you try and run the code.
CondA = Average[20] (Close)
CondB = Average[50] (Close)
CondC = CondA crosses over CondB
If condC Then
Buy at Market
Endif
Thanks GraHal, I’m learning…..
Is it possible to plot the %K of the Stochastic on its own or the MACD line on its own ??
Such as against an SMA.
[scode]
Return Stochastic[8,4](close)
[/scode]
This will only return the K line.
You can apply an MA to the indicator, but this will simply replicate the D line That you have previously removed.
Thank you Roberto…
I have just tried to backtest this simple program but the syntax error now
underlined is the > symbol, third line up (>80) What have I done wrong ?
DEFPARAM CumulateOrders = False
DEFPARAM FlatBefore = 081500
DEFPARAM FlatAfter= 160000
StocK = Stochastic[15,3](close)
StocD = Average[3,0](StocK)
y = StocK CROSSES UNDER StocD
If average [50](close)>average[50](3) then
If StocK<20 and y then
Buy at market
Set stop loss 15
Endif
Endif
// sell condition
If StocK = Stochastic[15,3](close)>80 then
Sell at market
Endif
What have I done wrong ?
Try …
If StocK >80 Then
Sell at market
Endif
This could be the error, at line 8:
average[50](3)
what is the number 3 within parentheses? That’s the place where you put the data series on which the average is computed, CLOSE, HIGH, StocK, Rsi….. not 3!
(when omitted, the CLOSE is assumed)
Also, line 15 should be:
If StocK >80 then
// or
If Stochastic[15,3](close)>80 then