Closing prohibited - check NFA flag!

Posted By: coinpump

Closing prohibited - check NFA flag! - 01/05/22 17:15

Hi everyone, I'm testing in live mode to better understand. Zorro opened a long trade, and also exited the trade successfully, but I see this message. It did not enter a short position though when it was supposed to.

Closing prohibited - check NFA flag!
[BTCUSDT::L00002] - can't close at attempt 1, 1@46438.16 at 17:11:06

I am using the stock plugin of binance futures. Thank you!


[Wed 22-01-05 17:15] 161 -0.0121 0/1 (46358.13)
Closing prohibited - check NFA flag!
[BTCUSDT::L00002] - can't close at attempt 2, 1@46358.13 at 17:15:00
!BTCUSDT: SELL 0.001 (q1 x la0.001) at MARKET
[BTCUSDT::S00003] Short 1@46358.13 Risk 0 at 17:15:00

(This did not enter a short position, only closed the long)

Here's the code:
Code
	if (crossOver(DEMAShort, DEMALong)) enterLong();
	if (crossUnder(DEMAShort, DEMALong)) enterShort();



Posted By: Spirit

Re: Closing prohibited - check NFA flag! - 01/06/22 09:28

Have you checked the NFA flag?
Posted By: coinpump

Re: Closing prohibited - check NFA flag! - 01/06/22 14:17

Thank you for the well thought out response. I hadn't thought of checking the NFA flag. *eyeroll*
Posted By: AndrewAMD

Re: Closing prohibited - check NFA flag! - 01/06/22 16:10

Good, then it solved the problem.
Posted By: coinpump

Re: Closing prohibited - check NFA flag! - 01/06/22 16:37

No, it did not solve the problem.
Why would closing be prohibited?
Why are you "expert users" so unhelpful to non experts? Borderline hostile... Because you do not want others to succeed?
I do on purpose to post my "stupid questions" here in separate threads so that search engines can find it and other newbies might find it useful. Perhaps that part has escaped you.

"This forum is the right place to post beginner's questions"
Apparently, you're in the wrong forum. Is there a "snippy and unhelpful answers" forum for you to join?
Posted By: AndrewAMD

Re: Closing prohibited - check NFA flag! - 01/06/22 16:47

Well then, you didn't set the NFA flag. Maybe you should set the NFA flag.

If you're using the TradeTest script, enable NFA in the pop-up GUI.

If you're using your own script, make sure set(NFA) is somewhere near the top of run().

The set() function and NFA flag are defined here:
https://zorro-project.com/manual/en/mode.htm

If you're still confused, post your script.
Posted By: jcl

Re: Closing prohibited - check NFA flag! - 01/06/22 19:01

>>Why are you "expert users" so unhelpful to non experts? Borderline hostile...<<

No one is hostile. All want to help. Many are also beginners with algo trading.

The problem: You're asking many questions that you won't have to ask when you even superficially go through the beginners tutorial. This draws sarcastic responses. When you see a message like "check NFA flag", you should be able to look up "NFA flag" in the help file and understand what it is. If then still something is unclear, maybe because the description is not good enough, you have all the right in the world to complain and ask.

Zorro is not an aim-and-click tool. You need to be on a scripting level, and need be able to use a manual.
Posted By: coinpump

Re: Closing prohibited - check NFA flag! - 01/07/22 22:51

I apologize for being impatient.

I have read the manual section about NFA... but I do not understand what it means.
"Directly closing positions is not allowed"

How can you close a position then? You can close a position manually (how else are you supposed to realize a profit?). What is the issue ?

I cannot open a simultaneous long and short position on binance. According to the manual, that means it is NFA compliant. So how do I close a trade?
Can you please provide me with an example how to exit a trade?

I am on a scripting level, but I am neurodivergent and I do not learn the same way as others. I wrote my own trading scripts in python. I also have coded in pinescript. Zorro team has done more than I could do in a lifetime so I am switching to learning Zorro now. Can you please point me to a workshop, or provide a code sample that will enter and exit a trade in live mode?

Code
#include <profile.c>
function run(){
	
	BarPeriod = 1;
	LotAmount = 0.001;

	Stop = 1.233;
	
	vars Close = series(priceClose());

	vars DEMAShort = series(DEMA(Close,7.03));
	vars DEMALong = series(DEMA(Close,32));

	if (crossOver(DEMAShort, DEMALong)) 
		enterLong();

	if (crossUnder(DEMAShort, DEMALong)) 
		enterShort();
	
	
}





Thank you for your time.
Posted By: Grant

Re: Closing prohibited - check NFA flag! - 01/08/22 00:12

By exitLong/exitShort

https://zorro-project.com/manual/en/selllong.htm
Posted By: coinpump

Re: Closing prohibited - check NFA flag! - 01/08/22 00:40

Code
	if (crossOver(DEMAShort, DEMALong)) 
		exitLong();
		enterLong();
	if (crossUnder(DEMAShort, DEMALong)) 
		exitShort();
		enterShort();

like this?

or do I need a condition first that checks if it has an open position?
Posted By: Spirit

Re: Closing prohibited - check NFA flag! - 01/08/22 10:04

No. In your code the brackets are missing. C uses brackets for keeping code together, not indenting like Python. And the exit commands are not needed here because opposite positions are automatically closed anyway. You need exit commands only when you exit a position without opening a new one. Your original code was ok, the new one is not.

And why have you still no NFA flag?
© 2024 lite-C Forums