Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 02/23/26 19:08
WFO Training with parallel cores Zorro64
by Martin_HH. 02/23/26 15:29
Camera always moves upwards?
by clonman. 02/21/26 09:29
Zorro version 3.0 prerelease!
by TipmyPip. 02/20/26 13:22
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
4 registered members (TipmyPip, tomaslolo, AndrewAMD, Martin_HH), 5,190 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Stop Loss HH(60) or LL(60)?? #422587
05/13/13 11:23
05/13/13 11:23
Joined: Apr 2013
Posts: 107
UK
G
Geek Offline OP
Member
Geek  Offline OP
Member
G

Joined: Apr 2013
Posts: 107
UK
Hi, i am just trying to understand why the stop loss method I have chosen seems to not be working properly in this test script?

Quote:
function run()
{
BarPeriod = 1;
asset("EUR/USD");

vars Close = series(priceClose());


if (WillR(3) < -70.5 && RSI(Close,2) < 20)

enterLong();

Stop = LL(60) - 1*PIP;
TakeProfit = 10*PIP;


if (RSI(Close,4) > 80)

exitLong();
}


I basically want to place the stop 1 pip below the lowest low of the past 60 candles or vise versa for highest high, so in this case 1 hour as it's 1 minute Bar period.

I am running this live on demo to test but the actual stops for instance are being placed very far away for instance just now I had a trade opened at 1.29855 with the stop being placed at 0.79842 so way out..

I am sure this is just a simple error on my part?




Last edited by Geek; 05/13/13 11:29.
Re: Stop Loss HH(60) or LL(60)?? [Re: Geek] #422588
05/13/13 11:47
05/13/13 11:47
Joined: Jul 2000
Posts: 28,075
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,075
Frankfurt
For opening a trade with a stop loss, you must set the "Stop" variable before entering the trade. In programming it's just as in real life: for buying a train ticket you must know your destination beforehand and not afterwards.


Re: Stop Loss HH(60) or LL(60)?? [Re: jcl] #422589
05/13/13 11:54
05/13/13 11:54
Joined: Apr 2013
Posts: 107
UK
G
Geek Offline OP
Member
Geek  Offline OP
Member
G

Joined: Apr 2013
Posts: 107
UK
Understood laugh

I have just put the stop before but I still get the exact same problem?

The stop is placed around 5000 points away at 0.79897 and not the lowest low of the past 60 bars away...

Last edited by Geek; 05/13/13 11:57.
Re: Stop Loss HH(60) or LL(60)?? [Re: Geek] #422590
05/13/13 11:59
05/13/13 11:59
Joined: Jul 2000
Posts: 28,075
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,075
Frankfurt
How do you know where the stop is placed? The stop that you see in the trade platform is not the real stop. For printing the real stop you'll need a trade function.

Which value has the Stop variable when you enter the trade?

Re: Stop Loss HH(60) or LL(60)?? [Re: jcl] #422591
05/13/13 12:08
05/13/13 12:08
Joined: Apr 2013
Posts: 107
UK
G
Geek Offline OP
Member
Geek  Offline OP
Member
G

Joined: Apr 2013
Posts: 107
UK
I am checking where the stop is placed in the FXCM demo account when it opens the trades.

The value is just 1...

Am I just missing part of the code for instance...

var *LL = series(priceLow());

and then replace with: Stop = priceLow(60); ?

Thanks for your help jcl, this placing the stop is bugging me and I can't quite figure it out yet.

Edit, when you say a trade function do you mean adding.

TradeStopLimit?

Last edited by Geek; 05/13/13 12:19.
Re: Stop Loss HH(60) or LL(60)?? [Re: Geek] #422592
05/13/13 12:14
05/13/13 12:14
Joined: Jul 2000
Posts: 28,075
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,075
Frankfurt
No, LL(60) was already correct. priceLow(60) is wrong - it's the low price of 60 candles ago.

For seeing the stop value, do this:

Stop = LL(60) - 1*PIP;
printf("\nStop = %.5f",Stop);
....

Your FXCM demo account does not know about this stop. That's why you can not see it there. The stops on your account are not the stops that you set with the Stop variable.

Re: Stop Loss HH(60) or LL(60)?? [Re: jcl] #422596
05/13/13 13:03
05/13/13 13:03
Joined: Apr 2013
Posts: 107
UK
G
Geek Offline OP
Member
Geek  Offline OP
Member
G

Joined: Apr 2013
Posts: 107
UK
Ok, I am getting the correct stop being displayed in Zorro and it seems to be working but..

Is there any reason why the stop displayed FXCM is not matched to the same a Zorro as I find using the chart display in FXCM can be useful whilst Zorro is running.. This is what I would like to put into code if possible..

Is it just the case of just adding a trade function like you say and then the stop with be correctly displayed in FXCM?

So the code will go something like...? (sorry if it's already incorrect)

function run()
{
BarPeriod = 1;
asset("EUR/USD");
LookBack = 300;

vars Close = series(priceClose());

Stop = LL(60) - 1*PIP;
printf("\nStop = %.5f",Stop);


if (WillR(3) < 50.5 && RSI(Close,2) < 60)

enterLong();


if (RSI(Close,4) > 80)

exitLong();
}

Thanks, i am still learning via trial and error, I am already a Zorro believer though laugh

Edit.. I have tried again with the TradeStopLimit but the stop in FXCM is still not displayed.. Back to the manual it is, but a gentle push would no be forgotten. wink





Last edited by Geek; 05/14/13 13:17.
Re: Stop Loss HH(60) or LL(60)?? [Re: Geek] #422604
05/13/13 14:48
05/13/13 14:48
Joined: Apr 2013
Posts: 107
UK
G
Geek Offline OP
Member
Geek  Offline OP
Member
G

Joined: Apr 2013
Posts: 107
UK
Well after some time I still can't get the result after trying many different lines of code. I still get the 5000 point difference in FXCM..

That is entirely my fault as being a novice programmer... Arrghh.

Could you please explain in code how to get the stop loss to display in FXCM without this 5000 point difference but the same as what is displayed in Zorro?

I have tried to implement various lines of code from the manual and even but it just does not want to work in the way i would like it to, the stop just get displayed just like before.

It's probably something so very simple?

Thanks again.

Re: Stop Loss HH(60) or LL(60)?? [Re: Geek] #422606
05/13/13 15:30
05/13/13 15:30
Joined: Jul 2000
Posts: 28,075
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,075
Frankfurt
Don't worry, the very distant stop in FXCM is not your fault as a programmer. The trades are not stopped by FXCM. It's Zorro that stops the trades. You do not display the stop loss in FXCM, you display it with the printf statement.

Your first version of the code was already correct, except for the wrong order of the stop setting. Your following attempts with "priceLow" or "TradeStopLimit" were wrong.

Re: Stop Loss HH(60) or LL(60)?? [Re: jcl] #422607
05/13/13 15:43
05/13/13 15:43
Joined: Apr 2013
Posts: 107
UK
G
Geek Offline OP
Member
Geek  Offline OP
Member
G

Joined: Apr 2013
Posts: 107
UK
Great, thanks jcl, appreciated, keep up the excellent work with Zorro.

Page 1 of 2 1 2

Moderated by  Petra 

Gamestudio download | 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