Welcome to the forum!
You could possibly be suffering from Celiac Disease/Ulcerative Colitis/Irritable Bowel Syndrome/ Crohn’s disease. All these result in tender abdomen, loose stool or loose stools alternating with constipation, abdominal distention, cramps, blood per rectum etc. Parasites in the gut like threadworm, tape worm, giardiasis etc can behave this way. Hence a stool test is a must.
A number of times a gastroenterologist is able to diagnose these conditions by clinical examination and detailed medical history. Blood tests to rule out anemia, stool test to look for white blood cells, sigmoidoscopy, colonoscopy etc are used to diagnose ulcerative colitis. Braium meal and follow through, endoscopy etc are done to rule out GERD, Crohn’s disease etc. Irritable bowel syndrome is diagnosed by elimination of other causes. Gluten is a complex protein present in four main grains---wheat, rye, barley and oats. If you have gluten intolerance, then you probably have celiac disease or Non Celiac gluten sensitivity. There are blood tests called celiac test to detect gluten intolerance.
I would strongly recommend you to see a gastroenterologist (a specialist who looks after the diseases of our digestive system). It is difficult to comment beyond this at this stage. Please let me know if there is any thing else and do keep me posted. Take care!