Gamestudio Links
Zorro Links
Newest Posts
file_write var array ?
by laz. 10/22/19 16:00
SAV_STATS
by MatPed. 10/22/19 13:57
Instrument Price Zorro Chart
by jcl. 10/22/19 10:39
Accessing All Historical Price Data
by jcl. 10/22/19 10:37
Calculating with price series
by AndrewAMD. 10/21/19 14:31
Error E355: Startup failure
by Dooley. 10/21/19 06:47
Today real live account blown - my experience
by Clifford_B. 10/19/19 17:09
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
14 registered members (JamesHH, AndrewAMD, alibaba, jenGs, FLD, jyd, MatPed, Dalla, 3 invisible), 672 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
VillageTalkies, line7, Shutch, Clifford_B, Paulius
18310 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Shift on MA #478142
09/12/19 21:24
09/12/19 21:24
Joined: Sep 2019
Posts: 5
Kalahari Desert, ZA
Fred7 Offline OP
Newbie
Fred7  Offline 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.
Code
vars smaHS = series(SMA,20); \\is my series I use


when I plot:
Code
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:
Code
 if(Close>smaHS[1]) 
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: 774
Chicago
AndrewAMD Online
User
AndrewAMD  Online
User

Joined: Feb 2017
Posts: 774
Chicago
I’m assuming Close is a series?

If so, you must dereference a particular element of it, like so:
Code
if(Close[0]>smaHS[1])

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 Offline OP
Newbie
Fred7  Offline 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
Code
plot("SMA High",smaHS[2],0,BLUE);
it does the shifting 2bars forward which is what I want, but when I do
Code
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: Fred7] #478147
09/13/19 15:20
09/13/19 15:20
Joined: Feb 2017
Posts: 774
Chicago
AndrewAMD Online
User
AndrewAMD  Online
User

Joined: Feb 2017
Posts: 774
Chicago
Can you describe your intended entry conditions?

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 Offline OP
Newbie
Fred7  Offline 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: 774
Chicago
AndrewAMD Online
User
AndrewAMD  Online
User

Joined: Feb 2017
Posts: 774
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.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1