1 registered members (opm),
778
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Shift on MA
#478142
09/12/19 21:24
09/12/19 21:24
|
Joined: Sep 2019
Posts: 5 Kalahari Desert, ZA
Fred7
OP
Newbie
|
OP
Newbie
Joined: Sep 2019
Posts: 5
Kalahari Desert, ZA
|
I have an SMA that I shift 1 forward and it plots fine, but when I try the trade it doesn't like it.
vars smaHS = series(SMA,20); \\is my series I use when I plot: plot("SMA High",smaHS[1],0,BLUE); it shows it on the price curve and shifted 1 bar forward, but when I try it as a condition: I get an POINTER:DOUBLE:LONG error. Do I need to specify it as a double somewhere? Thanx
|
|
|
Re: Shift on MA
[Re: Fred7]
#478144
09/13/19 00:53
09/13/19 00:53
|
Joined: Feb 2017
Posts: 1,718 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,718
Chicago
|
I’m assuming Close is a series? If so, you must dereference a particular element of it, like so: In other words, you cannot compare a vars to a var. You must compare a var to a var.
|
|
|
Re: Shift on MA
[Re: AndrewAMD]
#478146
09/13/19 15:06
09/13/19 15:06
|
Joined: Sep 2019
Posts: 5 Kalahari Desert, ZA
Fred7
OP
Newbie
|
OP
Newbie
Joined: Sep 2019
Posts: 5
Kalahari Desert, ZA
|
Thanx AndrewAMD, makes sense yes. Just want to ask, the numbers in [ ] specify how many bars back you want to look but with the MA I'm plotting plot("SMA High",smaHS[2],0,BLUE); it does the shifting 2bars forward which is what I want, but when I do if(Close[1] > smaHS[2] && Close[2]<smaHS[2]) it does not look like it is taking the entries at the right place, or is the code correct for what I want to do?
|
|
|
Re: Shift on MA
[Re: AndrewAMD]
#478154
09/14/19 07:37
09/14/19 07:37
|
Joined: Sep 2019
Posts: 5 Kalahari Desert, ZA
Fred7
OP
Newbie
|
OP
Newbie
Joined: Sep 2019
Posts: 5
Kalahari Desert, ZA
|
On the chart there is a SMA that is shifted 2bars forward. When Close[1] is above the SMA and Close[2] should still be below SMA, then a condition is met
Last edited by Fred7; 09/14/19 07:37.
|
|
|
Re: Shift on MA
[Re: Fred7]
#478159
09/15/19 12:30
09/15/19 12:30
|
Joined: Feb 2017
Posts: 1,718 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,718
Chicago
|
You just regurgitated your code instead of rewriting your entry conditions in a logical paragraph form, which I would have preferred. I say this because your description is possibly wrong, and I have no way to confirm this.
Anyways, if you set Verbose = 7 | DIAG, and set(LOGFILE), add various printf statements, and then read the logs in your log folder, you will be able to troubleshoot your script.
If you're still having trouble, post your **entire** script and not little snippets.
|
|
|
|