Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Quad, TipmyPip), 865 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 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: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
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:
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: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
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: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
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.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1