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
5 registered members (AndrewAMD, monk12, TipmyPip, Quad, aliswee), 1,029 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
TradeVars not working with pending trades #476375
02/21/19 14:01
02/21/19 14:01
Joined: Oct 2018
Posts: 79
S
SnoopySniff Offline OP
Junior Member
SnoopySniff  Offline OP
Junior Member
S

Joined: Oct 2018
Posts: 79
I need to store some parameters for pending trades. I am using for this the TradeVar's. But unfortunately the TradeVar are not keeping the values. With open trades it's working but not with pending trades.

I tried to assign the pending trade to the ThisTrade variable. But when I do so my script is crashing.

ThisTrade = enterLong(1, -2*PIP);

What can I do?

Last edited by SnoopySniff; 02/21/19 14:34.
Re: TradeVars not working with pending trades [Re: SnoopySniff] #476377
02/21/19 17:06
02/21/19 17:06
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
Find why it does not work or crash, then make it work and fix the crash. ThisTrade is zero when the enterLong failed.

https://manual.zorro-project.com/trouble.htm

BTW, its the 3rd time I had to move your topic. Please post such questions here in Starting. Not in the Scripts forum. That is for working scripts only.

Re: TradeVars not working with pending trades [Re: Spirit] #476398
02/22/19 10:09
02/22/19 10:09
Joined: Oct 2018
Posts: 79
S
SnoopySniff Offline OP
Junior Member
SnoopySniff  Offline OP
Junior Member
S

Joined: Oct 2018
Posts: 79
Originally Posted By: Spirit
Find out why it does not work or does crash, then make it work and fix the crash. ThisTrade is zero when the enterLong failed.

https://manual.zorro-project.com/trouble.htm

BTW, its the 3rd time I had to move your topic. Please post such questions here in Starting. Not in the Scripts forum. That is for working scripts only.


I am sorry. I didn't know that you were moving my topics. I thought I put it here by mistake and so I moved it back.

I am working on finding out why it's not working. I am investing hours for that. Believe me I don't try to make it easy for me.

Re: TradeVars not working with pending trades [Re: SnoopySniff] #476399
02/22/19 10:21
02/22/19 10:21
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
It can be easier when you post your script when asking for help with it. Otherwise no one can see whats wrong. You get then only advices like "find the bug and fix it".

Re: TradeVars not working with pending trades [Re: Spirit] #476401
02/22/19 11:09
02/22/19 11:09
Joined: Oct 2018
Posts: 79
S
SnoopySniff Offline OP
Junior Member
SnoopySniff  Offline OP
Junior Member
S

Joined: Oct 2018
Posts: 79
Originally Posted By: Spirit
It can be easier when you post your script when asking for help with it. Otherwise no one can see whats wrong. You get then only advices like "find the bug and fix it".


I get it. Here it comes! I appreciate it!

When I use the TradeVar's for the pending trades my script crashes.

-------
// This is the error message:

MyCode4Forum compiling............
##### priceClose 0.00000, myATR 0.00051, Spread 0.00001, EntryLong -0.00051, EntryShort -0.00051

--> enterLong EUR/USD pending at -0.00051

--> enterShort EUR/USD pending at -0.00051
Error 111: Crash in function: algo_crashes() at bar 0

-------
// This is the script tailored to the error I get.

#define MyEntryPrice TradeVar[0]
#define MyTradeSetBreakEven TradeVar[1]

function algo_crashes() {

var myATR = 5*PIP+Spread;
var myEntryPriceLong = myATR*-1;
var myEntryPriceShort = myATR*-1;

printf("n ##### priceClose %.5f, myATR %.5f, Spread %.5f, EntryLong %.5f, EntryShort %.5f", priceClose(0), myATR, Spread, myEntryPriceLong, myEntryPriceShort);

if(NumOpenLong == 0 && NumPendingLong == 0 ) {
printf("nn --> enterLong %s pending at %.5f", Asset, myEntryPriceLong);

ThisTrade = enterLong(1, myEntryPriceLong, myATR, 0, Spread);
// MyEntryPrice = myEntryPriceLong; // I quoted it because the script would crash here.
// MyTradeSetBreakEven = 0;

}

if(NumOpenShort == 0 && NumPendingShort == 0) {
printf("nn --> enterShort %s pending at %.5f", Asset, myEntryPriceShort);

ThisTrade = enterShort(1, myEntryPriceShort, myATR, 0, Spread);
MyEntryPrice = myEntryPriceShort; // The script is crashing here. When I quote it there is no crash.
MyTradeSetBreakEven = 0;

}
}

function run() {

if(is(INITRUN)) {

Verbose = 3;

Capital = 1000;
Balance = slider(1,1000,1,1000,"Balance","Balance");
// LookBack = 150;

StartDate = 20190214;
EndDate = 20190214;
BarPeriod = 1;
EntryTime = 1*60*24*5;

set(LOGFILE+TESTNOW+TICKS);
UpdateDays = -1;

Hedge = 2;

}
algo_crashes();
}

Last edited by SnoopySniff; 02/22/19 11:10.
Re: TradeVars not working with pending trades [Re: SnoopySniff] #476402
02/22/19 11:15
02/22/19 11:15
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
Yes this will crash. when you look on the troubleshooting page under "crash" you see that its the third most frequent beginners mistake listed there.

The fix:

Code:
ThisTrade = enterShort(1, myEntryPriceShort, myATR, 0, Spread);
if(ThisTrade) {
  MyEntryPrice = myEntryPriceShort; // The script is crashing here. When I quote it there is no crash.
  MyTradeSetBreakEven = 0;
}


Re: TradeVars not working with pending trades [Re: Spirit] #476405
02/22/19 18:46
02/22/19 18:46
Joined: Oct 2018
Posts: 79
S
SnoopySniff Offline OP
Junior Member
SnoopySniff  Offline OP
Junior Member
S

Joined: Oct 2018
Posts: 79
Originally Posted By: Spirit
Yes this will crash. when you look on the troubleshooting page under "crash" you see that its the third most frequent beginners mistake listed there.

The fix:

Code:
ThisTrade = enterShort(1, myEntryPriceShort, myATR, 0, Spread);
if(ThisTrade) {
  MyEntryPrice = myEntryPriceShort; // The script is crashing here. When I quote it there is no crash.
  MyTradeSetBreakEven = 0;
}



Yes, it's working when I am starting the script in "Trade"-Mode. But it differs from the Test-Mode. In the Test-Mode the lines in the If-Statement are skipped. In Trade-Mode they are executed. That's what I need. But it's confusing. It's not logic to me but working. Is it perhaps because of there is just a TradeID when the trade is opened with the broker which is not happening in Test-Mode?

Last edited by SnoopySniff; 02/22/19 19:02.
Re: TradeVars not working with pending trades [Re: SnoopySniff] #476407
02/23/19 07:17
02/23/19 07:17
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
ThisTrade is valid or not when the trade was entered or not. It has nothing to do with pending or trade mode, but with market hours or lookback periods. Please read about enterLong in the manual, and read also the troubleshooting page. There you can learn to see what your script is doing - it will make life much easier when you're not helpless in such a situation.

Re: TradeVars not working with pending trades [Re: jcl] #476435
02/25/19 23:00
02/25/19 23:00
Joined: Oct 2018
Posts: 79
S
SnoopySniff Offline OP
Junior Member
SnoopySniff  Offline OP
Junior Member
S

Joined: Oct 2018
Posts: 79
Thank you, jcl. Sometimes I read it and later I read it and I understand something new. Sometimes I read the solution but I don't perceive it. It's like I can't see the single tree because of the wood. So, sorry for sometimes asking stupid basic beginner stuff. But I am getting better and now I got it and solved all my troubles. :-)


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1